[pulseaudio-discuss] [PATCH v2] resampler: Always remix between mono and non-mono

Tanu Kaskinen tanuk at iki.fi
Thu Mar 21 03:36:45 PDT 2013


---
 src/pulsecore/resampler.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 0a3a678..7e92e6e 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -203,6 +203,9 @@ pa_resampler* pa_resampler_new(
         pa_resample_flags_t flags) {
 
     pa_resampler *r = NULL;
+    unsigned c;
+    bool input_is_mono_only;
+    bool output_is_mono_only;
 
     pa_assert(pool);
     pa_assert(a);
@@ -269,6 +272,28 @@ pa_resampler* pa_resampler_new(
     else if (!pa_channel_map_init_auto(&r->o_cm, r->o_ss.channels, PA_CHANNEL_MAP_DEFAULT))
         goto fail;
 
+    /* If the input or output is mono-only, we ignore the NO_REMIX flag,
+     * because even if remixing is otherwise disabled, it's probably still
+     * desirable to be able to play mono inputs to non-mono outputs and
+     * non-mono inputs to mono outputs. */
+
+    for (c = 0; c < r->i_ss.channels; c++) {
+        if (r->i_cm.map[c] != PA_CHANNEL_POSITION_MONO) {
+            input_is_mono_only = false;
+            break;
+        }
+    }
+
+    for (c = 0; c < r->o_ss.channels; c++) {
+        if (r->o_cm.map[c] != PA_CHANNEL_POSITION_MONO) {
+            output_is_mono_only = false;
+            break;
+        }
+    }
+
+    if (input_is_mono_only || output_is_mono_only)
+        r->flags &= ~PA_RESAMPLER_NO_REMIX;
+
     r->i_fz = pa_frame_size(a);
     r->o_fz = pa_frame_size(b);
 
-- 
1.7.10.4



More information about the pulseaudio-discuss mailing list