[PATCH RFC 3/4] sink: Inherit the volume from the active port.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since the port now holds the volume information we can simply inherit
the volume from the active port if the volume isn't set while creating
the sink.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=55262
---
 src/pulsecore/sink.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index a8a91d6..37cabb6 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -276,7 +276,6 @@ pa_sink* pa_sink_new(
     s->n_corked = 0;
     s->input_to_master = NULL;
 
-    s->reference_volume = s->real_volume = data->volume;
     pa_cvolume_reset(&s->soft_volume, s->sample_spec.channels);
     s->base_volume = PA_VOLUME_NORM;
     s->n_volume_steps = PA_VOLUME_NORM+1;
@@ -309,10 +308,18 @@ pa_sink* pa_sink_new(
                 s->active_port = p;
     }
 
-    if (s->active_port)
+    if (s->active_port) {
         s->latency_offset = s->active_port->latency_offset;
-    else
+
+        if (pa_cvolume_valid(&s->active_port->volume) && !data->volume_is_set)
+            s->reference_volume = s->real_volume = s->active_port->volume;
+        else
+            s->reference_volume = s->real_volume = data->volume;
+
+    } else {
         s->latency_offset = 0;
+        s->reference_volume = s->real_volume = data->volume;
+    }
 
     s->save_volume = data->save_volume;
     s->save_muted = data->save_muted;
@@ -1976,6 +1983,7 @@ void pa_sink_set_volume(
         }
 
         pa_cvolume_remap(&new_reference_volume, &s->channel_map, &root_sink->channel_map);
+        pa_device_port_set_volume(s->active_port, new_reference_volume);
 
         if (update_reference_volume(root_sink, &new_reference_volume, &root_sink->channel_map, save)) {
             if (pa_sink_flat_volume_enabled(root_sink)) {
-- 
1.8.1



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux