mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
device-port: moving streams due to changing the status of active_port
When the active port of a sink becomes unavailable, all streams from that sink should be moved to the default sink. When the active port of a sink changes state from unavailable, all streams that have their preferred_sink set to this sink should be moved to this sink. Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
parent
b886836630
commit
60d948618e
2 changed files with 27 additions and 0 deletions
|
|
@ -100,6 +100,18 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
|
|||
else
|
||||
pa_core_update_default_source(p->core);
|
||||
|
||||
if (p->direction == PA_DIRECTION_OUTPUT) {
|
||||
pa_sink *sink;
|
||||
|
||||
sink = pa_device_port_get_sink(p);
|
||||
if (sink && p == sink->active_port) {
|
||||
if (sink->active_port->available == PA_AVAILABLE_NO)
|
||||
pa_sink_move_streams_to_default_sink(p->core, sink);
|
||||
else
|
||||
pa_core_move_streams_to_newly_available_preferred_sink(p->core, sink);
|
||||
}
|
||||
}
|
||||
|
||||
pa_subscription_post(p->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, p->card->index);
|
||||
pa_hook_fire(&p->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED], p);
|
||||
}
|
||||
|
|
@ -224,3 +236,16 @@ pa_device_port *pa_device_port_find_best(pa_hashmap *ports)
|
|||
|
||||
return best;
|
||||
}
|
||||
|
||||
pa_sink *pa_device_port_get_sink(pa_device_port *p) {
|
||||
pa_sink *rs = NULL;
|
||||
pa_sink *sink;
|
||||
uint32_t state;
|
||||
|
||||
PA_IDXSET_FOREACH(sink, p->card->sinks, state)
|
||||
if (p == pa_hashmap_get(sink->ports, p->name)) {
|
||||
rs = sink;
|
||||
break;
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,4 +87,6 @@ void pa_device_port_set_preferred_profile(pa_device_port *p, const char *new_pp)
|
|||
|
||||
pa_device_port *pa_device_port_find_best(pa_hashmap *ports);
|
||||
|
||||
pa_sink *pa_device_port_get_sink(pa_device_port *p);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue