diff options
Diffstat (limited to 'src/combined/ffmpeg/ff_audio_decoder.c')
-rw-r--r-- | src/combined/ffmpeg/ff_audio_decoder.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c index 7ecf8290d..4e64378b6 100644 --- a/src/combined/ffmpeg/ff_audio_decoder.c +++ b/src/combined/ffmpeg/ff_audio_decoder.c @@ -22,7 +22,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" -#include "../../libffmpeg/ffmpeg_config.h" #endif #include <stdlib.h> @@ -38,9 +37,9 @@ #define LOG */ -#include "xine_internal.h" -#include "buffer.h" -#include "xineutils.h" +#include <xine/xine_internal.h> +#include <xine/buffer.h> +#include <xine/xineutils.h> #include "bswap.h" #include "ffmpeg_decoder.h" #include "ffmpeg_compat.h" @@ -163,13 +162,14 @@ static void ff_audio_init_codec(ff_audio_decoder_t *this, unsigned int codec_typ this->context->codec_type = this->codec->type; this->context->codec_tag = _x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC); - /* Use parser for AAC LATM and MPEG. + /* Use parser for EAC3, AAC LATM and MPEG. * Fixes: * - DVB streams where multiple AAC LATM frames are packed to single PES * - DVB streams where MPEG audio frames do not follow PES packet boundaries */ #if AVPARSE > 1 if (codec_type == BUF_AUDIO_AAC_LATM || + codec_type == BUF_AUDIO_EAC3 || codec_type == BUF_AUDIO_MPEG) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, @@ -316,6 +316,10 @@ static void ff_handle_header_buffer(ff_audio_decoder_t *this, buf_element_t *buf this->context->extradata_size); break; } + + case BUF_AUDIO_EAC3: + break; + default: xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "ffmpeg_audio_dec: unknown header with buf type 0x%X\n", codec_type); @@ -342,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, @@ -449,7 +465,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) /* pad input data */ memset(&this->buf[this->size], 0, FF_INPUT_BUFFER_PADDING_SIZE); - while (this->size>0) { + while (this->size>=0) { decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; bytes_consumed = @@ -467,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; @@ -605,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); @@ -648,18 +672,6 @@ static audio_decoder_t *ff_audio_open_plugin (audio_decoder_class_t *class_gen, return &this->audio_decoder; } -static char *ff_audio_get_identifier (audio_decoder_class_t *this) { - return "ffmpeg audio"; -} - -static char *ff_audio_get_description (audio_decoder_class_t *this) { - return "ffmpeg based audio decoder plugin"; -} - -static void ff_audio_dispose_class (audio_decoder_class_t *this) { - free (this); -} - void *init_audio_plugin (xine_t *xine, void *data) { ff_audio_class_t *this ; @@ -667,9 +679,9 @@ void *init_audio_plugin (xine_t *xine, void *data) { this = calloc(1, sizeof (ff_audio_class_t)); this->decoder_class.open_plugin = ff_audio_open_plugin; - this->decoder_class.get_identifier = ff_audio_get_identifier; - this->decoder_class.get_description = ff_audio_get_description; - this->decoder_class.dispose = ff_audio_dispose_class; + this->decoder_class.identifier = "ffmpeg audio"; + this->decoder_class.description = N_("ffmpeg based audio decoder plugin"); + this->decoder_class.dispose = default_audio_decoder_class_dispose; pthread_once( &once_control, init_once_routine ); |