aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/ModplugDecoderPlugin.cxx
diff options
context:
space:
mode:
authorSebastian Thorarensen <sebth@naju.se>2013-10-19 15:39:04 +0200
committerMax Kellermann <max@duempel.org>2013-10-19 16:12:17 +0200
commitdb44a6e94819ec106daa5de726968d9c881107f3 (patch)
treeec3b43a698fd71305cd86453ec07e576b5d05dcf /src/decoder/ModplugDecoderPlugin.cxx
parentd6553fc6a73ce458aa1fabe78dbb45b5b6a1ac12 (diff)
downloadmpd-db44a6e94819ec106daa5de726968d9c881107f3.tar.gz
mpd-db44a6e94819ec106daa5de726968d9c881107f3.tar.xz
mpd-db44a6e94819ec106daa5de726968d9c881107f3.zip
decoder/modplug: Add "loop_count" parameter
The "loop_count" configuration parameter allows the user to set how many times a module with backward loops shall loop. "0" (the default) means a module is not allowed to use backward loops at all. "-1" enables inifinite looping.
Diffstat (limited to 'src/decoder/ModplugDecoderPlugin.cxx')
-rw-r--r--src/decoder/ModplugDecoderPlugin.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx
index 685675350..e3779a66a 100644
--- a/src/decoder/ModplugDecoderPlugin.cxx
+++ b/src/decoder/ModplugDecoderPlugin.cxx
@@ -22,6 +22,7 @@
#include "DecoderAPI.hxx"
#include "InputStream.hxx"
#include "tag/TagHandler.hxx"
+#include "system/FatalError.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
@@ -38,6 +39,19 @@ static constexpr size_t MODPLUG_PREALLOC_BLOCK = 256 * 1024;
static constexpr size_t MODPLUG_READ_BLOCK = 128 * 1024;
static constexpr input_stream::offset_type MODPLUG_FILE_LIMIT = 100 * 1024 * 1024;
+static int modplug_loop_count;
+
+static bool
+modplug_decoder_init(const config_param &param)
+{
+ modplug_loop_count = param.GetBlockValue("loop_count", 0);
+ if (modplug_loop_count < -1)
+ FormatFatalError("Invalid loop count in line %d: %i",
+ param.line, modplug_loop_count);
+
+ return true;
+}
+
static GByteArray *
mod_loadfile(struct decoder *decoder, struct input_stream *is)
{
@@ -114,6 +128,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
settings.mChannels = 2;
settings.mBits = 16;
settings.mFrequency = 44100;
+ settings.mLoopCount = modplug_loop_count;
/* insert more setting changes here */
ModPlug_SetSettings(&settings);
@@ -192,7 +207,7 @@ static const char *const mod_suffixes[] = {
const struct decoder_plugin modplug_decoder_plugin = {
"modplug",
- nullptr,
+ modplug_decoder_init,
nullptr,
mod_decode,
nullptr,