Fix a hang in sync
authorjstebbins <jstebbins.hb@gmail.com>
Mon, 7 Feb 2011 22:46:01 +0000 (22:46 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Mon, 7 Feb 2011 22:46:01 +0000 (22:46 +0000)
If one stream has no content and other streams have almost no content,
we were hanging while waiting for the first pts in the streams.

This could be reproduced by attempting to encode only the last 0-length chapter
of a DVD.

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

libhb/sync.c

index 322dc783f4a12f4d81b4da8ff302abc69e1a899e..ad26fb6569a27d95a5957151b89cdcffe1b691bc 100644 (file)
@@ -297,6 +297,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         {
             *buf_out = next;
             pv->common->start_found = 1;
+            pv->common->first_pts[0] = INT64_MAX - 1;
             hb_cond_broadcast( pv->common->next_frame );
 
             /*
@@ -366,6 +367,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
             *buf_out = hb_buffer_init( 0 );
 
             pv->common->start_found = 1;
+            pv->common->first_pts[0] = INT64_MAX - 1;
             hb_cond_broadcast( pv->common->next_frame );
 
             /*
@@ -396,6 +398,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     {
         hb_buffer_close( &next );
 
+        pv->common->first_pts[0] = INT64_MAX - 1;
         cur->start = sync->next_start;
         cur->stop = cur->start + 90000. / ((double)job->vrate / (double)job->vrate_base);
 
@@ -952,6 +955,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     {
         hb_buffer_close( &buf );
         *buf_out = hb_buffer_init( 0 );
+        pv->common->first_pts[sync->index+1] = INT64_MAX - 1;
         return HB_WORK_DONE;
     }