diff options
author | Max Kellermann <max@duempel.org> | 2009-02-18 18:18:29 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-18 18:18:29 +0100 |
commit | 2bc0fabe73e292ac84047f65a5af24ed96aa3724 (patch) | |
tree | f5e03c8209a9f7780f562a58707bfa45d8b66a44 | |
parent | 47e3eab8722a9a131b40e86a315c692e806d73b1 (diff) | |
download | mpd-2bc0fabe73e292ac84047f65a5af24ed96aa3724.tar.gz mpd-2bc0fabe73e292ac84047f65a5af24ed96aa3724.tar.xz mpd-2bc0fabe73e292ac84047f65a5af24ed96aa3724.zip |
mp4ff: call decoder_initialized() after libfaad initialization
Don't wait for the first frame to be decoded. We already have the
sample rate and the channel count from faacDecInit2().
-rw-r--r-- | src/decoder/mp4ff_plugin.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/src/decoder/mp4ff_plugin.c b/src/decoder/mp4ff_plugin.c index 26dbda89a..e12e82d6e 100644 --- a/src/decoder/mp4ff_plugin.c +++ b/src/decoder/mp4ff_plugin.c @@ -111,6 +111,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) float file_time, total_time; int32_t scale; faacDecHandle decoder; + struct audio_format audio_format; faacDecFrameInfo frame_info; faacDecConfigurationPtr config; unsigned char *mp4_buffer; @@ -139,7 +140,6 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) uint16_t bit_rate = 0; bool seeking = false; double seek_where = 0; - bool initialized = false; enum decoder_command cmd = DECODE_COMMAND_NONE; mp4fh = mp4ff_open_read(&callback); @@ -204,6 +204,26 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) seek_table = g_malloc(sizeof(float) * num_samples); + audio_format = (struct audio_format){ + .bits = 16, + .channels = channels, + .sample_rate = sample_rate, + }; + + if (!audio_format_valid(&audio_format)) { + g_warning("Invalid audio format: %u:%u:%u\n", + audio_format.sample_rate, + audio_format.bits, + audio_format.channels); + faacDecClose(decoder); + mp4ff_close(mp4fh); + return; + } + + decoder_initialized(mpd_decoder, &audio_format, + input_stream->seekable, + total_time); + for (sample_id = 0; sample_id < num_samples && cmd != DECODE_COMMAND_STOP; sample_id++) { @@ -268,31 +288,20 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) break; } - if (!initialized) { - struct audio_format audio_format = { - .bits = 16, - .channels = frame_info.channels, - }; + if (frame_info.channels != audio_format.channels) { + g_warning("channel count changed from %u to %u", + audio_format.channels, frame_info.channels); + break; + } - channels = frame_info.channels; #ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE - scale = frame_info.samplerate; -#endif - audio_format.sample_rate = scale; - - if (!audio_format_valid(&audio_format)) { - g_warning("Invalid audio format: %u:%u:%u\n", - audio_format.sample_rate, - audio_format.bits, - audio_format.channels); - break; - } - - decoder_initialized(mpd_decoder, &audio_format, - input_stream->seekable, - total_time); - initialized = true; + if (frame_info.samplerate != audio_format.sample_rate) { + g_warning("sample rate changed from %u to %lu", + audio_format.sample_rate, + (unsigned long)frame_info.samplerate); + break; } +#endif if (channels * (unsigned long)(dur + offset) > frame_info.samples) { dur = frame_info.samples / channels; |