From 6cd5d7360759fdfb3021195134299a5151551ffb Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Wed, 21 Jan 2015 20:33:13 +0100
Subject: [PATCH] pcm/SoxrResampler: allow multi-threaded resampling

---
 NEWS                      |  1 +
 doc/user.xml              | 11 +++++++++++
 src/pcm/SoxrResampler.cxx |  2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index a1e57d65a..edb07f15e 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ ver 0.20 (not yet released)
 * resampler
   - new block "resampler" in configuration file
     replacing the old "samplerate_converter" setting
+  - soxr: allow multi-threaded resampling
 * reset song priority on playback
 * write database and state file atomically
 * remove dependency on GLib
diff --git a/doc/user.xml b/doc/user.xml
index 310b50d53..3fe293ab9 100644
--- a/doc/user.xml
+++ b/doc/user.xml
@@ -2392,6 +2392,17 @@ buffer_size: 16384</programlisting>
                   </itemizedlist>
                 </entry>
               </row>
+
+              <row>
+                <entry>
+                  <varname>threads</varname>
+                </entry>
+                <entry>
+                  The number of <application>libsoxr</application>
+                  threads.  "0" means "automatic".  The default is "1"
+                  which disables multi-threading.
+                </entry>
+              </row>
             </tbody>
           </tgroup>
         </informaltable>
diff --git a/src/pcm/SoxrResampler.cxx b/src/pcm/SoxrResampler.cxx
index df462ed9d..7750afd5c 100644
--- a/src/pcm/SoxrResampler.cxx
+++ b/src/pcm/SoxrResampler.cxx
@@ -103,7 +103,7 @@ pcm_resample_soxr_global_init(const ConfigBlock &block, Error &error)
 		    "soxr converter '%s'",
 		    soxr_quality_name(recipe));
 
-	const unsigned n_threads = 1;
+	const unsigned n_threads = block.GetBlockValue("threads", 1);
 	soxr_runtime = soxr_runtime_spec(n_threads);
 
 	return true;