From 24a065e5de863ab78cd8dc1e9a1ecf5e24ec6176 Mon Sep 17 00:00:00 2001 From: Johns Date: Sun, 12 Feb 2012 17:50:10 +0100 Subject: [PATCH] Fix bug: audible glitch toggling AC-3 pass-through --- ChangeLog | 1 + Todo | 3 --- codec.c | 13 ++++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 623e9a1..09819e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ User johns Date: + Fix bug: audible glitch when switching AC-3 pass-through <-> none. Fix bug: mpeg stills not displayed. Detect audio stream type only after stream switch. Detect more h264 streams with leading zeros. diff --git a/Todo b/Todo index 9831eb0..66dbec5 100644 --- a/Todo +++ b/Todo @@ -34,8 +34,6 @@ video: subtitle could be asyncron reduce warnings after channel switch grab image with hardware and better scaling support - suspendoutput didn't show logo or black pictures - (must detect video format to show image) hard channel switch OSD can only be shown after some stream could be shown yaepghd changed position is lost on channel switch @@ -86,7 +84,6 @@ audio: add pause support for replay pause Mute should do a real mute and not only set volume to zero. Starting suspended and muted, didn't register the mute. - switching stero/dolby produces klick sound audio/alsa: better downmix of >2 channels on 2 channel hardware diff --git a/codec.c b/codec.c index 6d28348..b59db72 100644 --- a/codec.c +++ b/codec.c @@ -605,6 +605,7 @@ struct _audio_decoder_ /// audio parser to support insane dvb streaks AVCodecParserContext *AudioParser; + int PassthroughAC3; ///< current ac-3 pass-through int SampleRate; ///< current stream sample rate int Channels; ///< current stream channels @@ -621,6 +622,9 @@ static char CodecPassthroughAC3; ///< pass ac3 through //static char CodecPassthroughDTS; ///< pass dts through (unsupported) //static char CodecPassthroughMPA; ///< pass mpa through (unsupported) +#else + +static const int CodecPassthroughAC3 = 0; #endif /** @@ -872,11 +876,13 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt) AudioSetClock(dpkt->pts); } // FIXME: must first play remainings bytes, than change and play new. - if (audio_decoder->SampleRate != audio_ctx->sample_rate + if (audio_decoder->PassthroughAC3 != CodecPassthroughAC3 + || audio_decoder->SampleRate != audio_ctx->sample_rate || audio_decoder->Channels != audio_ctx->channels) { int err; int isAC3; + audio_decoder->PassthroughAC3 = CodecPassthroughAC3; // FIXME: use swr_convert from swresample (only in ffmpeg!) // FIXME: tell ac3 decoder to use downmix if (audio_decoder->ReSample) { @@ -887,14 +893,11 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt) audio_decoder->SampleRate = audio_ctx->sample_rate; audio_decoder->HwSampleRate = audio_ctx->sample_rate; audio_decoder->Channels = audio_ctx->channels; -#ifdef USE_PASSTHROUGH // SPDIF/HDMI passthrough if (CodecPassthroughAC3 && audio_ctx->codec_id == CODEC_ID_AC3) { audio_decoder->HwChannels = 2; isAC3 = 1; - } else -#endif - { + } else { audio_decoder->HwChannels = audio_ctx->channels; isAC3 = 0; }