summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
authorvan <[email protected]>2008-07-30 22:27:33 +0000
committervan <[email protected]>2008-07-30 22:27:33 +0000
commitbec5dee00e2b3f3c1cd0c9797e281eabeb19a4d7 (patch)
tree48c9d6273dce15f3af53737c4461e831834fff03 /libhb/work.c
parentdff2e8c7a540f22a5a1157199c7aef26c4a4ffa2 (diff)
Fix two problems that would cause HB to hang in the muxer whenever the input content's video finished before audio:
- sync has to keep processing until all its input fifos report eof otherwise it won't send an eof on all its output fifos. - do_job has to wait for muxer to finish. Waiting for anything earlier in the pipeline (we were waiting for the video encoder) can cause other parts of the pipeline to get terminated early which will result in lost data & no eofs. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1597 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/libhb/work.c b/libhb/work.c
index f7d050b6a..5dddf26cb 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -125,11 +125,9 @@ static void do_job( hb_job_t * job, int cpu_count )
hb_title_t * title;
int i, j;
hb_work_object_t * w;
- hb_work_object_t * final_w = NULL;
hb_audio_t * audio;
hb_subtitle_t * subtitle;
- int done;
unsigned int subtitle_highest = 0;
unsigned int subtitle_highest_id = 0;
unsigned int subtitle_lowest = -1;
@@ -265,7 +263,7 @@ static void do_job( hb_job_t * job, int cpu_count )
}
hb_log (" + PixelRatio: %d, width:%d, height: %d",job->pixel_ratio,job->width, job->height);
- job->fifo_mpeg2 = hb_fifo_init( 128 );
+ job->fifo_mpeg2 = hb_fifo_init( 256 );
job->fifo_raw = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
job->fifo_sync = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
job->fifo_render = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
@@ -287,15 +285,6 @@ static void do_job( hb_job_t * job, int cpu_count )
hb_list_add( job->list_work, ( w = hb_get_work( WORK_RENDER ) ) );
w->fifo_in = job->fifo_sync;
w->fifo_out = job->fifo_render;
- if ( job->indepth_scan )
- {
- /*
- * if we're doing a subtitle scan the last thread in the
- * processing pipeline is render - remember it so we can
- * wait for its completion below.
- */
- final_w = w;
- }
if( !job->indepth_scan )
{
@@ -327,13 +316,6 @@ static void do_job( hb_job_t * job, int cpu_count )
w->config = &job->config;
hb_list_add( job->list_work, w );
-
- /*
- * if we're not doing a subtitle scan the last thread in the
- * processing pipeline is the encoder - remember it so we can
- * wait for its completion below.
- */
- final_w = w;
}
if( job->select_subtitle && !job->indepth_scan )
@@ -661,17 +643,12 @@ static void do_job( hb_job_t * job, int cpu_count )
// init routines so we have to init the muxer last.
job->muxer = job->indepth_scan? NULL : hb_muxer_init( job );
- done = 0;
w = hb_list_item( job->list_work, 0 );
- w->thread_sleep_interval = 50;
+ w->thread_sleep_interval = 10;
w->init( w, job );
while( !*job->die )
{
- if ( !done && ( w->status = w->work( w, NULL, NULL ) ) == HB_WORK_DONE )
- {
- done = 1;
- }
- if( done && final_w->status == HB_WORK_DONE )
+ if ( ( w->status = w->work( w, NULL, NULL ) ) == HB_WORK_DONE )
{
break;
}
@@ -680,9 +657,14 @@ static void do_job( hb_job_t * job, int cpu_count )
hb_list_rem( job->list_work, w );
w->close( w );
free( w );
- job->done = 1;
cleanup:
+ /* Stop the write thread (thread_close will block until the muxer finishes) */
+ if( job->muxer != NULL )
+ hb_thread_close( &job->muxer );
+
+ job->done = 1;
+
/* Close work objects */
while( ( w = hb_list_item( job->list_work, 0 ) ) )
{
@@ -697,11 +679,9 @@ cleanup:
hb_list_close( &job->list_work );
- /* Stop read & write threads */
+ /* Stop the read thread */
if( job->reader != NULL )
hb_thread_close( &job->reader );
- if( job->muxer != NULL )
- hb_thread_close( &job->muxer );
/* Close fifos */
hb_fifo_close( &job->fifo_mpeg2 );