summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetri Hintukainen <phintuka@users.sourceforge.net>2012-08-29 11:39:11 +0300
committerPetri Hintukainen <phintuka@users.sourceforge.net>2012-08-29 11:39:11 +0300
commit0c26928f7cda6f68bd86ab4b11abb4b5af63df51 (patch)
treec0b74a444734ab8963b41275d049fcd4b27cd12e /src
parentbe3e478bc71c03e5a2f6ac502d73c511f2926e28 (diff)
downloadxine-lib-0c26928f7cda6f68bd86ab4b11abb4b5af63df51.tar.gz
xine-lib-0c26928f7cda6f68bd86ab4b11abb4b5af63df51.tar.bz2
ff_audio_decoder: re-open audio output when codec params change
Diffstat (limited to 'src')
-rw-r--r--src/combined/ffmpeg/ff_audio_decoder.c26
1 files changed, 23 insertions, 3 deletions
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);