ffplay: remove redundant silence buffer

Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
This commit is contained in:
Lukasz Marek 2016-03-17 18:26:09 +01:00
parent 6e65b9bb1f
commit df34b70098

View File

@ -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;