aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-12 01:47:07 +0200
committerMax Kellermann <max@duempel.org>2014-07-12 01:47:07 +0200
commitda599e3f1af9ff12c2cf468a2ea40c5bc2d784fb (patch)
tree45072f77e900cf393475f544f720de2f415b162a /src
parent4c7b0b935b5391ae771f2e9385ad312a1d811a4c (diff)
downloadmpd-da599e3f1af9ff12c2cf468a2ea40c5bc2d784fb.tar.gz
mpd-da599e3f1af9ff12c2cf468a2ea40c5bc2d784fb.tar.xz
mpd-da599e3f1af9ff12c2cf468a2ea40c5bc2d784fb.zip
decoder/faad: split faad_stream_decode()
Eliminate duplicate cleanup code.
Diffstat (limited to 'src')
-rw-r--r--src/decoder/plugins/FaadDecoderPlugin.cxx26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx
index 7025536d6..1fdc7def0 100644
--- a/src/decoder/plugins/FaadDecoderPlugin.cxx
+++ b/src/decoder/plugins/FaadDecoderPlugin.cxx
@@ -360,17 +360,11 @@ faad_get_file_time(InputStream &is)
}
static void
-faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
+faad_stream_decode(Decoder &mpd_decoder, InputStream &is,
+ DecoderBuffer *buffer, const NeAACDecHandle decoder)
{
- DecoderBuffer *buffer =
- decoder_buffer_new(&mpd_decoder, is,
- FAAD_MIN_STREAMSIZE * MAX_CHANNELS);
const float total_time = faad_song_duration(buffer, is);
- /* create the libfaad decoder */
-
- const NeAACDecHandle decoder = faad_decoder_new();
-
while (!decoder_buffer_is_full(buffer) && !is.LockIsEOF() &&
decoder_get_command(mpd_decoder) == DecoderCommand::NONE) {
adts_find_frame(buffer);
@@ -383,8 +377,6 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
AudioFormat audio_format;
if (!faad_decoder_init(decoder, buffer, audio_format, error)) {
LogError(error);
- NeAACDecClose(decoder);
- decoder_buffer_free(buffer);
return;
}
@@ -448,6 +440,20 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
(size_t)frame_info.samples * 2,
bit_rate);
} while (cmd != DecoderCommand::STOP);
+}
+
+static void
+faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
+{
+ DecoderBuffer *buffer =
+ decoder_buffer_new(&mpd_decoder, is,
+ FAAD_MIN_STREAMSIZE * MAX_CHANNELS);
+
+ /* create the libfaad decoder */
+
+ const NeAACDecHandle decoder = faad_decoder_new();
+
+ faad_stream_decode(mpd_decoder, is, buffer, decoder);
/* cleanup */