From 7cd3b216443482163c68e01fe48755f5763a7053 Mon Sep 17 00:00:00 2001 From: Rodeo Date: Wed, 15 Aug 2012 15:43:33 +0000 Subject: Don't send empty audio packets downstream, as empty buffers are assumed to mark the end of stream. Such packets can result from samplerate or other types of audio conversion. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4906 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/audio_resample.c | 6 ++++-- libhb/sync.c | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'libhb') diff --git a/libhb/audio_resample.c b/libhb/audio_resample.c index 94ab3b531..ced6d69fd 100644 --- a/libhb/audio_resample.c +++ b/libhb/audio_resample.c @@ -174,9 +174,11 @@ hb_buffer_t* hb_audio_resample(hb_audio_resample_t *resample, (void**)&samples, resample->in.linesize, nsamples); - if (out_samples < 0) + if (out_samples <= 0) { - hb_log("hb_audio_resample: avresample_convert() failed"); + if (out_samples < 0) + hb_log("hb_audio_resample: avresample_convert() failed"); + // don't send empty buffers downstream (EOF) hb_buffer_close(&out); return NULL; } diff --git a/libhb/sync.c b/libhb/sync.c index 73a1071e3..9c202c250 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -1085,6 +1085,13 @@ static hb_buffer_t * OutputAudioFrame( hb_audio_t *audio, hb_buffer_t *buf, } hb_buffer_close( &buf_raw ); + if (sync->data.output_frames_gen <= 0) + { + // XXX: don't send empty buffers downstream (EOF) + // possibly out-of-sync audio is better than no audio at all + hb_buffer_close(&buf); + return NULL; + } buf->size = sync->data.output_frames_gen * sample_size; duration = (double)( sync->data.output_frames_gen * 90000 ) / audio->config.out.samplerate; -- cgit v1.2.3