From 0c26928f7cda6f68bd86ab4b11abb4b5af63df51 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 29 Aug 2012 11:39:11 +0300 Subject: ff_audio_decoder: re-open audio output when codec params change --- src/combined/ffmpeg/ff_audio_decoder.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c index 5e3322030..4e64378b6 100644 --- a/src/combined/ffmpeg/ff_audio_decoder.c +++ b/src/combined/ffmpeg/ff_audio_decoder.c @@ -346,6 +346,18 @@ static void ff_audio_reset_parser(ff_audio_decoder_t *this) } } +static void ff_audio_output_close(ff_audio_decoder_t *this) +{ + if (this->output_open) { + this->stream->audio_out->close (this->stream->audio_out, this->stream); + this->output_open = 0; + } + + this->audio_bits = 0; + this->audio_sample_rate = 0; + this->audio_channels = 0; +} + static int ff_audio_decode(xine_t *xine, AVCodecContext *ctx, AVCodecParserContext *parser_ctx, @@ -471,6 +483,16 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) return; } + if (this->output_open) { + if (this->audio_bits != this->context->bits_per_sample || + this->audio_sample_rate != this->context->sample_rate || + this->audio_channels != this->context->channels) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + _("ffmpeg_audio_dec: codec parameters changed\n")); + ff_audio_output_close(this); + } + } + if (!this->output_open) { if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) { this->audio_bits = this->context->bits_per_sample; @@ -609,9 +631,7 @@ static void ff_audio_dispose (audio_decoder_t *this_gen) { pthread_mutex_unlock (&ffmpeg_lock); } - if (this->output_open) - this->stream->audio_out->close (this->stream->audio_out, this->stream); - this->output_open = 0; + ff_audio_output_close(this); free16 (this->buf); free16 (this->decode_buffer); -- cgit v1.2.3