summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetri Hintukainen <phintuka@users.sourceforge.net>2011-11-02 13:57:35 +0200
committerPetri Hintukainen <phintuka@users.sourceforge.net>2011-11-02 13:57:35 +0200
commit9fa54f15e1b4b79730e2cefc089805206ec2fb38 (patch)
tree08a7f80813d65dd399b93b39ee3489a20fd5ff04 /src
parent9b7a019a6b3b8b7a8b04adff159f528ee8b025a1 (diff)
downloadxine-lib-9fa54f15e1b4b79730e2cefc089805206ec2fb38.tar.gz
xine-lib-9fa54f15e1b4b79730e2cefc089805206ec2fb38.tar.bz2
ff_audio_decoder: open audio out after decoding the data
- Fixes detecting audio parameters when audio packet is splitted to multiple buffers - Simplifies the code (decode function is called only once for each audio frame)
Diffstat (limited to 'src')
-rw-r--r--src/combined/ffmpeg/ff_audio_decoder.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c
index 01b5875fa..2515d657c 100644
--- a/src/combined/ffmpeg/ff_audio_decoder.c
+++ b/src/combined/ffmpeg/ff_audio_decoder.c
@@ -376,38 +376,6 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
this->size += buf->size;
- if (!this->output_open) {
- if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
- int ret;
-
- decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-
- ret = ff_audio_decode(this->stream->xine, this->context,
- (int16_t *)this->decode_buffer, &decode_buffer_size,
- this->buf, this->size);
-
- this->audio_bits = this->context->bits_per_sample;
- this->audio_sample_rate = this->context->sample_rate;
- this->audio_channels = this->context->channels;
- if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
- xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- _("ffmpeg_audio_dec: cannot read codec parameters from packet\n"));
-
- /* We can't use this packet, so we must discard it
- * and wait for another one. */
- this->size = 0;
- return;
- }
- }
- this->output_open = (this->stream->audio_out->open) (this->stream->audio_out,
- this->stream, this->audio_bits, this->audio_sample_rate,
- _x_ao_channels2mode(this->audio_channels));
- }
-
- /* if the audio still isn't open, bail */
- if (!this->output_open)
- return;
-
if (buf->decoder_flags & BUF_FLAG_FRAME_END) { /* time to decode a frame */
offset = 0;
@@ -432,6 +400,30 @@ 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->audio_sample_rate || !this->audio_channels) {
+ this->audio_bits = this->context->bits_per_sample;
+ this->audio_sample_rate = this->context->sample_rate;
+ this->audio_channels = this->context->channels;
+ if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ _("ffmpeg_audio_dec: cannot read codec parameters from packet\n"));
+
+ /* We can't use this packet, so we must discard it
+ * and wait for another one. */
+ this->size = 0;
+ return;
+ }
+ }
+ this->output_open = (this->stream->audio_out->open) (this->stream->audio_out,
+ this->stream, this->audio_bits, this->audio_sample_rate,
+ _x_ao_channels2mode(this->audio_channels));
+ }
+
+ /* if the audio still isn't open, bail */
+ if (!this->output_open)
+ return;
+
/* dispatch the decoded audio */
out = 0;
while (out < decode_buffer_size) {