Commit 1348420b authored by Marton Balint's avatar Marton Balint

ffplay: silence buffer size must be a multiple of frame size

Otherwise the audio channels sometimes would be shifted on output.
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 6f06545b
...@@ -2163,6 +2163,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) ...@@ -2163,6 +2163,7 @@ 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;
int bytes_per_sec; int bytes_per_sec;
int frame_size = av_samples_get_buffer_size(NULL, is->audio_tgt_channels, 1, is->audio_tgt_fmt, 1);
double pts; double pts;
audio_callback_time = av_gettime(); audio_callback_time = av_gettime();
...@@ -2173,7 +2174,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) ...@@ -2173,7 +2174,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
if (audio_size < 0) { if (audio_size < 0) {
/* if error, just output silence */ /* if error, just output silence */
is->audio_buf = is->silence_buf; is->audio_buf = is->silence_buf;
is->audio_buf_size = sizeof(is->silence_buf); is->audio_buf_size = sizeof(is->silence_buf) / frame_size * 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);
......
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