mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
gst: do a sync before disconnect
This makes sure we first nicely remove the stream from the server and then close the socket. If we don't do this, the disconnect might not have flushed out our disconnect and the server is left with a non-responsive node, especially if the disconnect on the core was done with a socket from the portal that is still open.
This commit is contained in:
parent
48dea3d5ea
commit
6eba010d38
4 changed files with 81 additions and 12 deletions
|
|
@ -954,6 +954,30 @@ static const struct pw_stream_events stream_events = {
|
|||
.process = on_process,
|
||||
};
|
||||
|
||||
static void on_core_done (void *object, uint32_t id, int seq)
|
||||
{
|
||||
GstPipeWireSrc * pwsrc = object;
|
||||
if (id == PW_ID_CORE) {
|
||||
pwsrc->last_seq = seq;
|
||||
pw_thread_loop_signal (pwsrc->loop, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
PW_VERSION_CORE_EVENTS,
|
||||
.done = on_core_done,
|
||||
};
|
||||
|
||||
static void do_sync(GstPipeWireSrc * pwsrc)
|
||||
{
|
||||
pwsrc->pending_seq = pw_core_sync(pwsrc->core, 0, pwsrc->pending_seq);
|
||||
while (true) {
|
||||
if (pwsrc->last_seq == pwsrc->pending_seq || pwsrc->last_error < 0)
|
||||
break;
|
||||
pw_thread_loop_wait (pwsrc->loop);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_pipewire_src_open (GstPipeWireSrc * pwsrc)
|
||||
{
|
||||
|
|
@ -972,6 +996,11 @@ gst_pipewire_src_open (GstPipeWireSrc * pwsrc)
|
|||
if (pwsrc->core == NULL)
|
||||
goto connect_error;
|
||||
|
||||
pw_core_add_listener(pwsrc->core,
|
||||
&pwsrc->core_listener,
|
||||
&core_events,
|
||||
pwsrc);
|
||||
|
||||
if (pwsrc->properties) {
|
||||
props = pw_properties_new (NULL, NULL);
|
||||
gst_structure_foreach (pwsrc->properties, copy_properties, props);
|
||||
|
|
@ -989,7 +1018,6 @@ gst_pipewire_src_open (GstPipeWireSrc * pwsrc)
|
|||
&stream_events,
|
||||
pwsrc);
|
||||
|
||||
|
||||
pwsrc->clock = gst_pipewire_clock_new (pwsrc->stream, pwsrc->last_time);
|
||||
pw_thread_loop_unlock (pwsrc->loop);
|
||||
|
||||
|
|
@ -1018,8 +1046,6 @@ no_stream:
|
|||
static void
|
||||
gst_pipewire_src_close (GstPipeWireSrc * pwsrc)
|
||||
{
|
||||
pw_thread_loop_stop (pwsrc->loop);
|
||||
|
||||
pwsrc->last_time = gst_clock_get_time (pwsrc->clock);
|
||||
|
||||
gst_element_post_message (GST_ELEMENT (pwsrc),
|
||||
|
|
@ -1030,11 +1056,19 @@ gst_pipewire_src_close (GstPipeWireSrc * pwsrc)
|
|||
g_clear_object (&pwsrc->clock);
|
||||
GST_OBJECT_UNLOCK (pwsrc);
|
||||
|
||||
pw_stream_destroy (pwsrc->stream);
|
||||
pwsrc->stream = NULL;
|
||||
pw_thread_loop_lock (pwsrc->loop);
|
||||
if (pwsrc->stream) {
|
||||
pw_stream_destroy (pwsrc->stream);
|
||||
pwsrc->stream = NULL;
|
||||
}
|
||||
if (pwsrc->core) {
|
||||
do_sync(pwsrc);
|
||||
pw_core_disconnect (pwsrc->core);
|
||||
pwsrc->core = NULL;
|
||||
}
|
||||
pw_thread_loop_unlock (pwsrc->loop);
|
||||
|
||||
pw_core_disconnect (pwsrc->core);
|
||||
pwsrc->core = NULL;
|
||||
pw_thread_loop_stop (pwsrc->loop);
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue