source-output: Fix source-output volume after move of virtual source stream
authorGeorg Chini <georg@chini.tk>
Wed, 17 Feb 2021 20:36:07 +0000 (21:36 +0100)
committerGeorg Chini <georg@chini.tk>
Wed, 17 Feb 2021 20:42:14 +0000 (21:42 +0100)
When the source-output of a virtual source with volume sharing disabled is moved,
the source output volume is reset to 100%. This patch fixes the problem by
applying the virtual source volume to the source-output after the move.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/509>

src/pulsecore/source-output.c

index 92f74d4..248698a 100644 (file)
@@ -1512,6 +1512,16 @@ static void update_volume_due_to_moving(pa_source_output *o, pa_source *dest) {
             pa_source_output_set_volume_direct(o, &o->reference_ratio);
             o->real_ratio = o->reference_ratio;
             pa_sw_cvolume_multiply(&o->soft_volume, &o->real_ratio, &o->volume_factor);
+
+            /* If this is a virtual source stream, we have to apply the source volume
+             * to the source output. */
+            if (o->destination_source) {
+                pa_cvolume vol;
+
+                vol = o->destination_source->real_volume;
+                pa_cvolume_remap(&vol, &o->destination_source->channel_map, &o->channel_map);
+                pa_source_output_set_volume(o, &vol, o->destination_source->save_volume, true);
+            }
         }
     }