device-port: send sink and source change events when availability changes

The lack of change events caused GUIs to not update the port status.

Related bug report:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/941
This commit is contained in:
Tanu Kaskinen 2020-07-22 13:28:47 +03:00 committed by Arun Raghavan
parent 1f1fb8eb6b
commit 414644dff1

View file

@ -107,8 +107,20 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
* be created before port objects, and then p->card could be non-NULL for
* the whole lifecycle of pa_device_port. */
if (p->card && p->card->linked) {
pa_sink *sink;
pa_source *source;
pa_subscription_post(p->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, p->card->index);
sink = pa_device_port_get_sink(p);
source = pa_device_port_get_source(p);
if (sink)
pa_subscription_post(p->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, sink->index);
if (source)
pa_subscription_post(p->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, source->index);
pa_hook_fire(&p->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED], p);
/* A sink or source whose active port is unavailable can't be the
* default sink/source, so port availability changes may affect the
* default sink/source choice. */
@ -118,9 +130,6 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
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) {
if (p->core->rescue_streams)
@ -129,9 +138,6 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
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) {
if (p->core->rescue_streams)