[FFmpeg-cvslog] ffplay: fix silence insertion on error or pause
Marton Balint
git at videolan.org
Mon Apr 4 23:59:48 CEST 2016
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Apr 3 21:23:41 2016 +0200| [a07934d51b40b0f48be531a359d39c091c414643] | committer: Marton Balint
ffplay: fix silence insertion on error or pause
Insertion of silence was a bit broken since
df34b700981de606ca4847e1ed0bfdf9ac3e9104 because the info whether or not the
source buffer supposed to be silence must be kept between callbacks. Failing to
do so causes rogue samples from the last buffer to be presented, I guess even a
crash can occur under some circumstances.
This patch uses a NULL audio_buf to keep the silence state across audio
callbacks.
Reviewed-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a07934d51b40b0f48be531a359d39c091c414643
---
ffplay.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index aab03d1..123f4bc 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2531,7 +2531,7 @@ static int audio_decode_frame(VideoState *is)
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{
VideoState *is = opaque;
- int audio_size, len1, silence = 0;
+ int audio_size, len1;
audio_callback_time = av_gettime_relative();
@@ -2540,7 +2540,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
audio_size = audio_decode_frame(is);
if (audio_size < 0) {
/* if error, just output silence */
- silence = 1;
+ is->audio_buf = NULL;
is->audio_buf_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_tgt.frame_size * is->audio_tgt.frame_size;
} else {
if (is->show_mode != SHOW_MODE_VIDEO)
@@ -2552,11 +2552,11 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
len1 = is->audio_buf_size - is->audio_buf_index;
if (len1 > len)
len1 = len;
- if (!is->muted && !silence && is->audio_volume == SDL_MIX_MAXVOLUME)
+ if (!is->muted && is->audio_buf && is->audio_volume == SDL_MIX_MAXVOLUME)
memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
else {
memset(stream, 0, len1);
- if (!is->muted && !silence)
+ if (!is->muted && is->audio_buf)
SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume);
}
len -= len1;
More information about the ffmpeg-cvslog
mailing list