From a2c5be631962a8d0dd59b12fa58292d8c042236c Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Wed, 14 Mar 2012 00:54:01 +0100 Subject: [PATCH 1/2] ffplay: reset audio_pkt_temp when opening audio Otherwise we may use the remaining data of the last packet from the previous audio stream. Fixes bug #951. Signed-off-by: Marton Balint --- ffplay.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ffplay.c b/ffplay.c index e831f83901..8a5818f466 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2253,6 +2253,7 @@ static int stream_component_open(VideoState *is, int stream_index) avctx->flags |= CODEC_FLAG_EMU_EDGE; if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { + memset(&is->audio_pkt_temp, 0, sizeof(is->audio_pkt_temp)); env = SDL_getenv("SDL_AUDIO_CHANNELS"); if (env) wanted_channel_layout = av_get_default_channel_layout(SDL_atoi(env)); From ee4b14322155b5808eeceb463f5edcd751eb3a98 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Thu, 15 Mar 2012 00:41:57 +0100 Subject: [PATCH 2/2] ffplay: use frame count based queueing for audio queue This reduces the number of queued frames for audio data but also reduces the amount of A-V difference after changing the audio stream (because less frames are queued). Fixes bug #1035. Signed-off-by: Marton Balint --- ffplay.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ffplay.c b/ffplay.c index 8a5818f466..00be13de43 100644 --- a/ffplay.c +++ b/ffplay.c @@ -64,7 +64,6 @@ const char program_name[] = "ffplay"; const int program_birth_year = 2003; #define MAX_QUEUE_SIZE (15 * 1024 * 1024) -#define MIN_AUDIOQ_SIZE (20 * 16 * 1024) #define MIN_FRAMES 5 /* SDL audio buffer size, in samples. Should be small to have precise @@ -2612,7 +2611,7 @@ static int read_thread(void *arg) /* if the queue are full, no need to read more */ if ( is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE - || ( (is->audioq .size > MIN_AUDIOQ_SIZE || is->audio_stream < 0) + || ( (is->audioq .nb_packets > MIN_FRAMES || is->audio_stream < 0) && (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0) && (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0))) { /* wait 10 ms */