[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] device-port: send sink and source change events when availability changes

Arun Raghavan gitlab at gitlab.freedesktop.org
Wed Jul 22 22:58:03 UTC 2020



Arun Raghavan pushed to branch master at PulseAudio / pulseaudio


Commits:
414644df by Tanu Kaskinen at 2020-07-22T22:53:54+00:00
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

- - - - -


1 changed file:

- src/pulsecore/device-port.c


Changes:

=====================================
src/pulsecore/device-port.c
=====================================
@@ -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)



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/414644dff1abd32294db3be1fde001f56ec9e65a

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/414644dff1abd32294db3be1fde001f56ec9e65a
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20200722/f4914829/attachment-0001.htm>


More information about the pulseaudio-commits mailing list