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.
---
 NEWS                                 |  1 +
 doc/user.xml                         | 31 +++++++++++++++++++++++++++++++
 src/decoder/ModplugDecoderPlugin.cxx | 17 ++++++++++++++++-
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 1b575dd..c66d91e 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ ver 0.18 (2012/??/??)
   - opus: new decoder plugin for the Opus codec
   - vorbis: skip 16 bit quantisation, provide float samples
   - mikmod: add "loop" configuration parameter
+  - modplug: add "loop_count" configuration parameter
   - mp4ff: obsolete plugin removed
 * encoder:
   - opus: new encoder plugin for the Opus codec
diff --git a/doc/user.xml b/doc/user.xml
index b3ab8d4..cebc4ca 100644
--- a/doc/user.xml
+++ b/doc/user.xml
@@ -1001,6 +1001,37 @@ systemctl start mpd.socket</programlisting>
       </section>
 
       <section>
+        <title><varname>modplug</varname></title>
+
+        <para>
+          Module player based on MODPlug.
+        </para>
+
+        <informaltable>
+          <tgroup cols="2">
+            <thead>
+              <row>
+                <entry>Setting</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry>
+                  <varname>loop_count</varname>
+                </entry>
+                <entry>
+                  Number of times to loop the module if it uses backward loops.
+                  Default is <parameter>0</parameter> which prevents looping.
+                  <parameter>-1</parameter> loops forever.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </informaltable>
+      </section>
+
+      <section>
         <title><varname>wildmidi</varname></title>
 
         <para>
diff --git a/src/decoder/ModplugDecoderPlugin.cxx 
b/src/decoder/ModplugDecoderPlugin.cxx
index 6856753..e3779a6 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,
-- 
1.8.1.5

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to