]> granicus.if.org Git - handbrake/commitdiff
libhb: fix hang that can occur under certain error conditions
authorjstebbins <jstebbins.hb@gmail.com>
Sun, 16 Jun 2013 16:16:52 +0000 (16:16 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Sun, 16 Jun 2013 16:16:52 +0000 (16:16 +0000)
audio and video sync are in wait loops when they first start.
if an error happens during this period, the hang would happen.
check w->done in these loops to break out in case of error.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5592 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/sync.c

index 3e88c40e5279d6ae30507c18c30f330014ebf0e5..a5158f738717269761c235b6882b8ee7075132ca 100644 (file)
@@ -273,7 +273,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     {
         pv->common->first_pts[0] = next->s.start;
         hb_lock( pv->common->mutex );
-        while( pv->common->pts_offset == INT64_MIN )
+        while( pv->common->pts_offset == INT64_MIN && !*w->done )
         {
             // Full fifos will make us wait forever, so get the
             // pts offset from the available streams if full
@@ -741,7 +741,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     {
         pv->common->first_pts[sync->index+1] = buf->s.start;
         hb_lock( pv->common->mutex );
-        while( pv->common->pts_offset == INT64_MIN )
+        while( pv->common->pts_offset == INT64_MIN && !*w->done)
         {
             // Full fifos will make us wait forever, so get the
             // pts offset from the available streams if full
@@ -761,7 +761,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     /* Wait for start frame if doing point-to-point */
     hb_lock( pv->common->mutex );
     start = buf->s.start - pv->common->audio_pts_slip;
-    while ( !pv->common->start_found )
+    while ( !pv->common->start_found && !*w->done )
     {
         if ( pv->common->audio_pts_thresh < 0 )
         {
@@ -777,7 +777,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
             return HB_WORK_OK;
         }
         while ( !pv->common->start_found && 
-                buf->s.start >= pv->common->audio_pts_thresh )
+                buf->s.start >= pv->common->audio_pts_thresh && !*w->done )
         {
             hb_cond_timedwait( pv->common->next_frame, pv->common->mutex, 10 );
             // There is an unfortunate unavoidable deadlock that can occur.