Commit 976a366c authored by Hui Wang's avatar Hui Wang Committed by Tanu Kaskinen
Browse files

device-port: moving streams since active_port on source changes status



When the active port of a source becomes unavailable, all streams from
that source should be moved to the default source.

When the active port of a source changes state from unavailable, all
streams that have their preferred_source set to this source should be
moved to this source.
Signed-off-by: Hui Wang's avatarHui Wang <hui.wang@canonical.com>
parent 1cea7ab3
......@@ -110,6 +110,16 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
else
pa_core_move_streams_to_newly_available_preferred_sink(p->core, sink);
}
} else {
pa_source *source;
source = pa_device_port_get_source(p);
if (source && p == source->active_port) {
if (source->active_port->available == PA_AVAILABLE_NO)
pa_source_move_streams_to_default_source(p->core, source);
else
pa_core_move_streams_to_newly_available_preferred_source(p->core, source);
}
}
pa_subscription_post(p->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, p->card->index);
......@@ -249,3 +259,16 @@ pa_sink *pa_device_port_get_sink(pa_device_port *p) {
}
return rs;
}
pa_source *pa_device_port_get_source(pa_device_port *p) {
pa_source *rs = NULL;
pa_source *source;
uint32_t state;
PA_IDXSET_FOREACH(source, p->card->sources, state)
if (p == pa_hashmap_get(source->ports, p->name)) {
rs = source;
break;
}
return rs;
}
......@@ -89,4 +89,6 @@ pa_device_port *pa_device_port_find_best(pa_hashmap *ports);
pa_sink *pa_device_port_get_sink(pa_device_port *p);
pa_source *pa_device_port_get_source(pa_device_port *p);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment