Commit df34b700 authored by Lukasz Marek's avatar Lukasz Marek

ffplay: remove redundant silence buffer

Signed-off-by: 's avatarLukasz Marek <lukasz.m.luki2@gmail.com>
parent 6e65b9bb
...@@ -243,7 +243,6 @@ typedef struct VideoState { ...@@ -243,7 +243,6 @@ typedef struct VideoState {
AVStream *audio_st; AVStream *audio_st;
PacketQueue audioq; PacketQueue audioq;
int audio_hw_buf_size; int audio_hw_buf_size;
uint8_t silence_buf[SDL_AUDIO_MIN_BUFFER_SIZE];
uint8_t *audio_buf; uint8_t *audio_buf;
uint8_t *audio_buf1; uint8_t *audio_buf1;
unsigned int audio_buf_size; /* in bytes */ unsigned int audio_buf_size; /* in bytes */
...@@ -2532,7 +2531,7 @@ static int audio_decode_frame(VideoState *is) ...@@ -2532,7 +2531,7 @@ static int audio_decode_frame(VideoState *is)
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{ {
VideoState *is = opaque; VideoState *is = opaque;
int audio_size, len1; int audio_size, len1, silence = 0;
audio_callback_time = av_gettime_relative(); audio_callback_time = av_gettime_relative();
...@@ -2541,8 +2540,8 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) ...@@ -2541,8 +2540,8 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
audio_size = audio_decode_frame(is); audio_size = audio_decode_frame(is);
if (audio_size < 0) { if (audio_size < 0) {
/* if error, just output silence */ /* if error, just output silence */
is->audio_buf = is->silence_buf; silence = 1;
is->audio_buf_size = sizeof(is->silence_buf) / is->audio_tgt.frame_size * is->audio_tgt.frame_size; is->audio_buf_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_tgt.frame_size * is->audio_tgt.frame_size;
} else { } else {
if (is->show_mode != SHOW_MODE_VIDEO) if (is->show_mode != SHOW_MODE_VIDEO)
update_sample_display(is, (int16_t *)is->audio_buf, audio_size); 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) ...@@ -2553,11 +2552,11 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
len1 = is->audio_buf_size - is->audio_buf_index; len1 = is->audio_buf_size - is->audio_buf_index;
if (len1 > len) if (len1 > len)
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); memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
else { else {
memset(stream, is->silence_buf[0], len1); memset(stream, 0, len1);
if (!is->muted) if (!is->muted && !silence)
SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume); SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume);
} }
len -= len1; len -= len1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment