[pulseaudio-discuss] [PATCH 1/2] source-output: do volume_factor_source application before resampling

Tanu Kaskinen tanuk at iki.fi
Thu Jan 7 05:25:40 PST 2016


Applying the volume after resampling means mismatch between the volume
channel map and the data channel map.

volume_factor_source is not currently used anywhere, so this bug
hasn't been causing any problems. I noticed it while reading the code.
---
 src/pulsecore/source-output.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 9000972..26a7123 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -792,14 +792,14 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) {
                 pa_volume_memchunk(&qchunk, &o->source->sample_spec, &o->thread_info.soft_volume);
         }
 
-        if (!o->thread_info.resampler) {
-            if (nvfs) {
-                pa_memchunk_make_writable(&qchunk, 0);
-                pa_volume_memchunk(&qchunk, &o->thread_info.sample_spec, &o->volume_factor_source);
-            }
+        if (nvfs) {
+            pa_memchunk_make_writable(&qchunk, 0);
+            pa_volume_memchunk(&qchunk, &o->source->sample_spec, &o->volume_factor_source);
+        }
 
+        if (!o->thread_info.resampler)
             o->push(o, &qchunk);
-        } else {
+        else {
             pa_memchunk rchunk;
 
             if (mbs == 0)
@@ -810,14 +810,8 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) {
 
             pa_resampler_run(o->thread_info.resampler, &qchunk, &rchunk);
 
-            if (rchunk.length > 0) {
-                if (nvfs) {
-                    pa_memchunk_make_writable(&rchunk, 0);
-                    pa_volume_memchunk(&rchunk, &o->thread_info.sample_spec, &o->volume_factor_source);
-                }
-
+            if (rchunk.length > 0)
                 o->push(o, &rchunk);
-            }
 
             if (rchunk.memblock)
                 pa_memblock_unref(rchunk.memblock);
-- 
2.6.4



More information about the pulseaudio-discuss mailing list