gst: stop the thread loop before destroying objects

When we destroy the proxy we should either take the thread lock
or stop the thread loop because the destroy might trigger a reply
to remove the object from another thread. This can cause the
refcounting to become invalid and cause double free.

Fixes #286
This commit is contained in:
Wim Taymans 2020-09-11 16:39:05 +02:00
parent 38f8c9c6c8
commit f6bc9113ce

View file

@ -571,6 +571,7 @@ gst_pipewire_device_provider_probe (GstDeviceProvider * provider)
GST_DEBUG_OBJECT (self, "disconnect");
pw_proxy_destroy ((struct pw_proxy*)data->registry);
pw_core_disconnect (self->core);
self->core = NULL;
pw_context_destroy (c);
pw_loop_destroy (l);
@ -660,6 +661,9 @@ gst_pipewire_device_provider_stop (GstDeviceProvider * provider)
GstPipeWireDeviceProvider *self = GST_PIPEWIRE_DEVICE_PROVIDER (provider);
GST_DEBUG_OBJECT (self, "stopping provider");
if (self->loop)
pw_thread_loop_stop (self->loop);
if (self->registry) {
pw_proxy_destroy ((struct pw_proxy*)self->registry);
self->registry = NULL;