[pulseaudio-discuss] [PATCH] resampler: Always remix mono-only streams

Tanu Kaskinen tanuk at iki.fi
Thu Mar 21 02:41:40 PDT 2013


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

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 0a3a678..0a235c7 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -203,6 +203,8 @@ pa_resampler* pa_resampler_new(
         pa_resample_flags_t flags) {
 
     pa_resampler *r = NULL;
+    unsigned ic;
+    bool input_is_mono_only;
 
     pa_assert(pool);
     pa_assert(a);
@@ -269,6 +271,19 @@ 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 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. */
+    for (ic = 0; ic < r->i_ss.channels; ic++) {
+        if (r->i_cm.map[ic] != PA_CHANNEL_POSITION_MONO) {
+            input_is_mono_only = false;
+            break;
+        }
+    }
+
+    if (input_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