In case a port has not yet been saved, which is e g often the case
if a sink/source has only one port, reading volume/mute will be done
without port, whereas writing volume/mute will be done with port.

Work around this by setting a default port before the fixate hook,
so module-device-restore can read volume/mute for the correct port.

BugLink: https://bugs.launchpad.net/bugs/1289515
Signed-off-by: David Henningsson <david.hennings...@canonical.com>
---
 src/pulsecore/sink.c   |   11 +++++++++++
 src/pulsecore/source.c |   11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 08143e9..9c4b0c3 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -235,6 +235,17 @@ pa_sink* pa_sink_new(
     pa_device_init_icon(data->proplist, true);
     pa_device_init_intended_roles(data->proplist);
 
+    if (!data->active_port && !data->save_port) {
+        void *state;
+        pa_device_port *p, *p2 = NULL;
+
+        PA_HASHMAP_FOREACH(p, data->ports, state)
+            if (!p2 || p->priority > p2->priority) {
+                p2 = p;
+                pa_sink_new_data_set_port(data, p2->name);
+            }
+    }
+
     if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0) {
         pa_xfree(s);
         pa_namereg_unregister(core, name);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 2a600e2..94533df 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -222,6 +222,17 @@ pa_source* pa_source_new(
     pa_device_init_icon(data->proplist, false);
     pa_device_init_intended_roles(data->proplist);
 
+    if (!data->active_port && !data->save_port) {
+        void *state;
+        pa_device_port *p, *p2 = NULL;
+
+        PA_HASHMAP_FOREACH(p, data->ports, state)
+            if (!p2 || p->priority > p2->priority) {
+                p2 = p;
+                pa_source_new_data_set_port(data, p2->name);
+            }
+    }
+
     if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], data) < 0) {
         pa_xfree(s);
         pa_namereg_unregister(core, name);
-- 
1.7.9.5

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1289515

Title:
  Sound volume resets after making a call

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1289515/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to