[Musicpd-dev-team] [PATCH 2/2] decoder/modplug: Add loop_count parameter

2013-10-19 Thread Sebastian Thorarensen
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
+titlevarnamemodplug/varname/title
+
+para
+  Module player based on MODPlug.
+/para
+
+informaltable
+  tgroup cols=2
+thead
+  row
+entrySetting/entry
+entryDescription/entry
+  /row
+/thead
+tbody
+  row
+entry
+  varnameloop_count/varname
+/entry
+entry
+  Number of times to loop the module if it uses backward loops.
+  Default is parameter0/parameter which prevents looping.
+  parameter-1/parameter loops forever.
+/entry
+  /row
+/tbody
+  /tgroup
+/informaltable
+  /section
+
+  section
 titlevarnamewildmidi/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=60135031iu=/4140/ostg.clktrk
___
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team


[Musicpd-dev-team] [PATCH 0/2] decoder/modplug: Add loop_count parameter

2013-10-19 Thread Sebastian Thorarensen
Hi again,

This is a set of patches similiar to the patch I sent for the Mikmod
decoder. It adds a configuration parameter called loop_count for the
Modplug decoder, which allows the user to set how many times the decoder
should loop modules which uses backward loops.

Mikmod only allows for disabling and enabling backward loops, but Modplug
can set a limit on the number of loops, a nice feature.

The patch for ConfigData is to enable signed integers in the
configuration, so that the user can set loop_count to -1, which
gives infinite looping.

Please consider applying these patches as well :)

Sebastian Thorarensen (2):
  ConfigData: Add support for signed integers
  decoder/modplug: Add loop_count parameter

 NEWS |  1 +
 doc/user.xml | 31 +++
 src/ConfigData.cxx   | 21 +++--
 src/ConfigData.hxx   |  6 ++
 src/decoder/ModplugDecoderPlugin.cxx | 17 -
 5 files changed, 73 insertions(+), 3 deletions(-)

-- 
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=60135031iu=/4140/ostg.clktrk
___
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team


Re: [Musicpd-dev-team] [PATCH 1/2] ConfigData: Add support for signed integers

2013-10-19 Thread Sebastian Thorarensen
On Sat, 19 Oct 2013, Max Kellermann wrote:

 This explicitly limits the range of unsigned integers to 2^31.  Why
 that?

To save three lines of code and but I missed that it would limit the
range, so it was by mistake.

-- 
Sebastian Thorarensen

--
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=60135031iu=/4140/ostg.clktrk
___
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team


[Musicpd-dev-team] [PATCH] decoder/mikmod: Add loop configuration parameter

2013-10-17 Thread Sebastian Thorarensen
Hi,

This patch allows the user to configure the mikmod decoder plugin to loop
modules. It adds a configuration parameter to the mikmod decoder called
loop which can be no (the old behaviour, default) or yes to allow
modules to use backward loops.

Please consider applying this patch.

-- 
Sebastian Thorarensen


---
 doc/user.xml|   10 ++
 src/decoder/MikmodDecoderPlugin.cxx |5 +++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/doc/user.xml b/doc/user.xml
index 61d02c1..b3ab8d4 100644
--- a/doc/user.xml
+++ b/doc/user.xml
@@ -978,6 +978,16 @@ systemctl start mpd.socket/programlisting
 tbody
   row
 entry
+  varnameloop/varname
+  parameteryes|no/parameter
+/entry
+entry
+  Allow backward loops in modules.  Default is
+ parameterno/parameter.
+/entry
+  /row
+  row
+entry
   varnamesample_rate/varname
 /entry
 entry
diff --git a/src/decoder/MikmodDecoderPlugin.cxx 
b/src/decoder/MikmodDecoderPlugin.cxx
index fb82eb7..6f2fd03 100644
--- a/src/decoder/MikmodDecoderPlugin.cxx
+++ b/src/decoder/MikmodDecoderPlugin.cxx
@@ -104,6 +104,7 @@ static MDRIVER drv_mpd = {
VC_VoiceRealVolume
 };
 
+static bool mikmod_loop;
 static unsigned mikmod_sample_rate;
 
 static bool
@@ -111,6 +112,7 @@ mikmod_decoder_init(const config_param param)
 {
static char params[] = ;
 
+   mikmod_loop = param.GetBlockValue(loop, false);
mikmod_sample_rate = param.GetBlockValue(sample_rate, 44100u);
if (!audio_valid_sample_rate(mikmod_sample_rate))
FormatFatalError(Invalid sample rate in line %d: %u,
@@ -161,8 +163,7 @@ mikmod_decoder_file_decode(struct decoder *decoder, const 
char *path_fs)
return;
}
 
-   /* Prevent module from looping forever */
-   handle-loop = 0;
+   handle-loop = mikmod_loop;
 
const AudioFormat audio_format(mikmod_sample_rate, SampleFormat::S16, 
2);
assert(audio_format.IsValid());
-- 
1.7.8.6

--
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=60135031iu=/4140/ostg.clktrk
___
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team