summaryrefslogtreecommitdiff
path: root/src/pulsecore/sink.c
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2014-03-21 10:19:19 +0100
committerDavid Henningsson <david.henningsson@canonical.com>2014-03-28 10:59:03 +0100
commite0e6bf687573ea8ee3b6b53f8e44bcb30f4914ec (patch)
treefaec384e17375f539ddc7bc600d7da5b6104ca3d /src/pulsecore/sink.c
parent633bc529e2643adbcd09a211887e0b788a69e6c2 (diff)
sink/source: Initialize port before fixate hook (fixes volume/mute not saved)
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.henningsson@canonical.com>
Diffstat (limited to 'src/pulsecore/sink.c')
-rw-r--r--src/pulsecore/sink.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 08143e9b1..872d4473a 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -235,6 +235,12 @@ pa_sink* pa_sink_new(
pa_device_init_icon(data->proplist, true);
pa_device_init_intended_roles(data->proplist);
+ if (!data->active_port) {
+ pa_device_port *p = pa_device_port_find_best(data->ports);
+ if (p)
+ pa_sink_new_data_set_port(data, p->name);
+ }
+
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0) {
pa_xfree(s);
pa_namereg_unregister(core, name);
@@ -300,23 +306,10 @@ pa_sink* pa_sink_new(
if ((s->active_port = pa_hashmap_get(s->ports, data->active_port)))
s->save_port = data->save_port;
- if (!s->active_port) {
- void *state;
- pa_device_port *p;
-
- PA_HASHMAP_FOREACH(p, s->ports, state) {
- if (p->available == PA_AVAILABLE_NO)
- continue;
-
- if (!s->active_port || p->priority > s->active_port->priority)
- s->active_port = p;
- }
- if (!s->active_port) {
- PA_HASHMAP_FOREACH(p, s->ports, state)
- if (!s->active_port || p->priority > s->active_port->priority)
- s->active_port = p;
- }
- }
+ /* Hopefully the active port has already been assigned in the previous call
+ to pa_device_port_find_best, but better safe than sorry */
+ if (!s->active_port)
+ s->active_port = pa_device_port_find_best(s->ports);
if (s->active_port)
s->latency_offset = s->active_port->latency_offset;