From 0142ce6f245253b0f8d2af6bf16f04d78fbfb93e Mon Sep 17 00:00:00 2001 From: van Date: Tue, 8 Jul 2008 20:34:06 +0000 Subject: [PATCH] Fix mkv A/V sync problem created by R1542. git-svn-id: svn://localhost/HandBrake/trunk@1559 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/muxcommon.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index 13a89922..b3337b7b 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -27,7 +27,7 @@ typedef struct } hb_track_t; -static hb_track_t * GetTrack( hb_list_t * list ) +static hb_track_t * GetTrack( hb_list_t * list, hb_job_t *job ) { hb_buffer_t * buf; hb_track_t * track = NULL, * track2; @@ -40,6 +40,18 @@ static hb_track_t * GetTrack( hb_list_t * list ) buf = hb_fifo_see( track2->fifo ); if( !buf ) { + // XXX libmkv uses a very simple minded muxer that will fail if the + // audio & video are out of sync. To keep them in sync we require + // that *all* fifos have a buffer then we take the oldest. + // Unfortunately this means we can hang in a deadlock with the + // reader process filling the fifos. With the current libmkv + // there's no way to avoid occasional deadlocks & we can only + // suggest that users evolve to using mp4s. + if ( job->mux == HB_MUX_MKV ) + { + return NULL; + } + // To make sure we don't camp on one fifo & prevent the others // from making progress we take the earliest data of all the // data that's currently available but we don't care if some @@ -143,7 +155,7 @@ static void MuxerFunc( void * _mux ) int thread_sleep_interval = 50; while( !*job->die && !job->done ) { - if( !( track = GetTrack( list ) ) ) + if( !( track = GetTrack( list, job ) ) ) { hb_snooze( thread_sleep_interval ); continue; -- 2.11.0