gst: stream: Destroy stream before clearing variable

`pw_stream_destroy()` chains up to `on_remove_buffer()` in
GstPipeWireSrc which again needs the stream to still be around to call
`pw_stream_queue_buffer()` on it. By using `g_clear_pointer()` it will
already have been cleared, causing crashes.

Revert to the behavior from before the commit mentioned below and add a
comment in order to avoid regressing in a future cleanup.

Fixes: 0c40c0147 (gst: factor out the stream management and some common variables in a new class)
This commit is contained in:
Robert Mader 2024-07-02 20:30:48 +02:00
parent d08df293a9
commit 2fcb90f661

View file

@ -158,7 +158,12 @@ gst_pipewire_stream_close (GstPipeWireStream * self)
/* destroy the pw stream */
pw_thread_loop_lock (self->core->loop);
g_clear_pointer (&self->pwstream, pw_stream_destroy);
if (self->pwstream) {
/* Do not use g_clear_pointer() here as pw_stream_destroy() may chain up to
* code requiring the pointer to still be around */
pw_stream_destroy (self->pwstream);
self->pwstream = NULL;
}
pw_thread_loop_unlock (self->core->loop);
/* release the core */