OSDN Git Service

Fix a hang in sync
[handbrake-jp/handbrake-jp-git.git] / libhb / muxcommon.c
index 05f49d4..f47b442 100644 (file)
@@ -244,10 +244,13 @@ static int muxWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         return HB_WORK_OK;
     }
 
+    int more = mux->rdy;
     // all tracks have at least 'interleave' ticks of data. Output
     // all that we can in 'interleave' size chunks.
-    while ( ( mux->rdy & mux->allRdy ) == mux->allRdy )
+    while ( (( mux->rdy & mux->allRdy ) == mux->allRdy && more) ||
+            ( mux->eof == mux->allEof ) ) 
     {
+        more = 0;
         for ( i = 0; i < mux->ntracks; ++i )
         {
             track = mux->track[i];
@@ -270,6 +273,10 @@ static int muxWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
             {
                 mux->rdy &=~ ( 1 << i );
             }
+            if ( track->mf.out != track->mf.in )
+            {
+                more |= ( 1 << i );
+            }
         }
 
         // if all the tracks are at eof we're just purging their
@@ -444,16 +451,8 @@ hb_work_object_t * hb_muxer_init( hb_job_t * job )
         switch( job->mux )
         {
         case HB_MUX_MP4:
-        case HB_MUX_PSP:
-        case HB_MUX_IPOD:
             mux->m = hb_mux_mp4_init( job );
             break;
-        case HB_MUX_AVI:
-            mux->m = hb_mux_avi_init( job );
-            break;
-        case HB_MUX_OGM:
-            mux->m = hb_mux_ogm_init( job );
-            break;
         case HB_MUX_MKV:
             mux->m = hb_mux_mkv_init( job );
             break;