diff options
author | Lukasz Marek <lukasz.m.luki2@gmail.com> | 2016-03-17 18:26:09 +0100 |
---|---|---|
committer | Lukasz Marek <lukasz.m.luki2@gmail.com> | 2016-03-22 00:04:21 +0100 |
commit | df34b700981de606ca4847e1ed0bfdf9ac3e9104 (patch) | |
tree | 7704683c4190996753bbadf26d5d8188fa4183c5 /ffplay.c | |
parent | 6e65b9bb1f55d2ffffa234bd212459a1395ca7e5 (diff) | |
download | ffmpeg-df34b700981de606ca4847e1ed0bfdf9ac3e9104.tar.gz |
ffplay: remove redundant silence buffer
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Diffstat (limited to 'ffplay.c')
-rw-r--r-- | ffplay.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -243,7 +243,6 @@ typedef struct VideoState { AVStream *audio_st; PacketQueue audioq; int audio_hw_buf_size; - uint8_t silence_buf[SDL_AUDIO_MIN_BUFFER_SIZE]; uint8_t *audio_buf; uint8_t *audio_buf1; unsigned int audio_buf_size; /* in bytes */ @@ -2532,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; + int audio_size, len1, silence = 0; audio_callback_time = av_gettime_relative(); @@ -2541,8 +2540,8 @@ 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 */ - is->audio_buf = is->silence_buf; - is->audio_buf_size = sizeof(is->silence_buf) / is->audio_tgt.frame_size * is->audio_tgt.frame_size; + silence = 1; + 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) update_sample_display(is, (int16_t *)is->audio_buf, audio_size); @@ -2553,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 && is->audio_volume == SDL_MIX_MAXVOLUME) + if (!is->muted && !silence && is->audio_volume == SDL_MIX_MAXVOLUME) memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1); else { - memset(stream, is->silence_buf[0], len1); - if (!is->muted) + memset(stream, 0, len1); + if (!is->muted && !silence) SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume); } len -= len1; |