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>
This commit is contained in:
David Henningsson 2014-03-21 10:19:19 +01:00
parent 633bc529e2
commit e0e6bf6875
4 changed files with 49 additions and 35 deletions

View file

@ -176,3 +176,30 @@ void pa_device_port_set_latency_offset(pa_device_port *p, int64_t offset) {
pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, p->card->index);
pa_hook_fire(&core->hooks[PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED], p);
}
pa_device_port *pa_device_port_find_best(pa_hashmap *ports)
{
void *state;
pa_device_port *p, *best = NULL;
if (!ports)
return NULL;
/* First run: skip unavailable ports */
PA_HASHMAP_FOREACH(p, ports, state) {
if (p->available == PA_AVAILABLE_NO)
continue;
if (!best || p->priority > best->priority)
best = p;
}
/* Second run: if only unavailable ports exist, still suggest a port */
if (!best) {
PA_HASHMAP_FOREACH(p, ports, state)
if (!best || p->priority > best->priority)
best = p;
}
return best;
}