diff options
author | Max Kellermann <max@duempel.org> | 2013-10-21 20:19:27 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-21 20:19:27 +0200 |
commit | 10196496f397488fbd859512ec41c7169f1f9e0b (patch) | |
tree | fed9750c2799da6e2a5c31b5cffe09061a0435ea /src/decoder | |
parent | 86f08862e4248ae264149fe03b167dfbbba7d548 (diff) | |
download | mpd-10196496f397488fbd859512ec41c7169f1f9e0b.tar.gz mpd-10196496f397488fbd859512ec41c7169f1f9e0b.tar.xz mpd-10196496f397488fbd859512ec41c7169f1f9e0b.zip |
decoder/modplug: move code to LoadModPlugFile()
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/ModplugDecoderPlugin.cxx | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx index e3779a66a..fc0fe827e 100644 --- a/src/decoder/ModplugDecoderPlugin.cxx +++ b/src/decoder/ModplugDecoderPlugin.cxx @@ -106,22 +106,27 @@ mod_loadfile(struct decoder *decoder, struct input_stream *is) return bdatas; } +static ModPlugFile * +LoadModPlugFile(struct decoder *decoder, struct input_stream *is) +{ + const auto bdatas = mod_loadfile(decoder, is); + if (!bdatas) { + LogWarning(modplug_domain, "could not load stream"); + return nullptr; + } + + ModPlugFile *f = ModPlug_Load(bdatas->data, bdatas->len); + g_byte_array_free(bdatas, TRUE); + return f; +} + static void mod_decode(struct decoder *decoder, struct input_stream *is) { - ModPlugFile *f; ModPlug_Settings settings; - GByteArray *bdatas; int ret; char audio_buffer[MODPLUG_FRAME_SIZE]; - bdatas = mod_loadfile(decoder, is); - - if (!bdatas) { - LogWarning(modplug_domain, "could not load stream"); - return; - } - ModPlug_GetSettings(&settings); /* alter setting */ settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; /* RESAMP */ @@ -132,9 +137,8 @@ mod_decode(struct decoder *decoder, struct input_stream *is) /* insert more setting changes here */ ModPlug_SetSettings(&settings); - f = ModPlug_Load(bdatas->data, bdatas->len); - g_byte_array_free(bdatas, TRUE); - if (!f) { + ModPlugFile *f = LoadModPlugFile(decoder, is); + if (f == nullptr) { LogWarning(modplug_domain, "could not decode stream"); return; } @@ -173,15 +177,7 @@ static bool modplug_scan_stream(struct input_stream *is, const struct tag_handler *handler, void *handler_ctx) { - ModPlugFile *f; - GByteArray *bdatas; - - bdatas = mod_loadfile(nullptr, is); - if (!bdatas) - return false; - - f = ModPlug_Load(bdatas->data, bdatas->len); - g_byte_array_free(bdatas, TRUE); + ModPlugFile *f = LoadModPlugFile(nullptr, is); if (f == nullptr) return false; |