aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/FaadDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-11 23:30:14 +0200
committerMax Kellermann <max@duempel.org>2014-07-12 00:17:43 +0200
commit18787ebe8f4159d68dc9bb283a6a6ddcbb2f15e7 (patch)
tree0f479ea8c58ca48c5c22d0f7799d39e5e7df9080 /src/decoder/FaadDecoderPlugin.cxx
parent47e8fcf37e775b0069f8facb9544520f6ca11414 (diff)
downloadmpd-18787ebe8f4159d68dc9bb283a6a6ddcbb2f15e7.tar.gz
mpd-18787ebe8f4159d68dc9bb283a6a6ddcbb2f15e7.tar.xz
mpd-18787ebe8f4159d68dc9bb283a6a6ddcbb2f15e7.zip
decoder/faad: move code to faad_decoder_new()
Merge some duplicate code.
Diffstat (limited to '')
-rw-r--r--src/decoder/FaadDecoderPlugin.cxx31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx
index 5ced8a8fb..60d95d626 100644
--- a/src/decoder/FaadDecoderPlugin.cxx
+++ b/src/decoder/FaadDecoderPlugin.cxx
@@ -217,6 +217,21 @@ faad_song_duration(DecoderBuffer *buffer, InputStream &is)
return -1;
}
+static NeAACDecHandle
+faad_decoder_new()
+{
+ const NeAACDecHandle decoder = NeAACDecOpen();
+
+ NeAACDecConfigurationPtr config =
+ NeAACDecGetCurrentConfiguration(decoder);
+ config->outputFormat = FAAD_FMT_16BIT;
+ config->downMatrix = 1;
+ config->dontUpSampleImplicitSBR = 0;
+ NeAACDecSetConfiguration(decoder, config);
+
+ return decoder;
+}
+
/**
* Wrapper for NeAACDecInit() which works around some API
* inconsistencies in libfaad.
@@ -297,12 +312,7 @@ faad_get_file_time_float(InputStream &is)
if (length < 0) {
AudioFormat audio_format;
- NeAACDecHandle decoder = NeAACDecOpen();
-
- NeAACDecConfigurationPtr config =
- NeAACDecGetCurrentConfiguration(decoder);
- config->outputFormat = FAAD_FMT_16BIT;
- NeAACDecSetConfiguration(decoder, config);
+ NeAACDecHandle decoder = faad_decoder_new();
decoder_buffer_fill(buffer);
@@ -344,14 +354,7 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
/* create the libfaad decoder */
- const NeAACDecHandle decoder = NeAACDecOpen();
-
- NeAACDecConfigurationPtr config =
- NeAACDecGetCurrentConfiguration(decoder);
- config->outputFormat = FAAD_FMT_16BIT;
- config->downMatrix = 1;
- config->dontUpSampleImplicitSBR = 0;
- NeAACDecSetConfiguration(decoder, config);
+ const NeAACDecHandle decoder = faad_decoder_new();
while (!decoder_buffer_is_full(buffer) && !is.LockIsEOF() &&
decoder_get_command(mpd_decoder) == DecoderCommand::NONE) {