[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] device-port: fire port available changed hook after streams are moved

Tanu Kaskinen gitlab at gitlab.freedesktop.org
Tue Oct 20 14:39:18 UTC 2020



Tanu Kaskinen pushed to branch master at PulseAudio / pulseaudio


Commits:
44c53176 by Igor V. Kovalenko at 2020-10-20T17:31:29+03:00
device-port: fire port available changed hook after streams are moved

If port becomes unavailable then PA_CORE_HOOK_PORT_AVAILABLE_CHANGED
callbacks may eventually destroy related source or sink object. Call
this hook after stream is moved to prevent crash reading from freed
memory.

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1008

- - - - -


1 changed file:

- src/pulsecore/device-port.c


Changes:

=====================================
src/pulsecore/device-port.c
=====================================
@@ -119,8 +119,6 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
         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. */
@@ -146,6 +144,11 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
                     pa_core_move_streams_to_newly_available_preferred_source(p->core, source);
             }
         }
+
+        /* This may cause the sink and source pointers to become invalid, if
+         * the availability change causes the card profile to get switched. If
+         * you add code after this line, remember to take that into account. */
+        pa_hook_fire(&p->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED], p);
     }
 }
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/44c531762400b561304d35e64f1997e9e06ec1fb

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/44c531762400b561304d35e64f1997e9e06ec1fb
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/20201020/b007dc8d/attachment.htm>


More information about the pulseaudio-commits mailing list