From 2d379bf9080cf10f810e0f2f7e1a7920b47c2841 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 1 May 2024 20:31:39 +0200 Subject: [PATCH] gst: handle some more errors The threadloop might fail to create because of missing plugins, so handle that. The context might fail to create because of some fatal config error or missing plugin, handle that too instead of crashing. See #3994 --- src/gst/gstpipewirecore.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/gst/gstpipewirecore.c b/src/gst/gstpipewirecore.c index ea378a512..6c4fb4b88 100644 --- a/src/gst/gstpipewirecore.c +++ b/src/gst/gstpipewirecore.c @@ -51,7 +51,11 @@ static GstPipeWireCore *make_core (int fd) core->refcount = 1; core->fd = fd; core->loop = pw_thread_loop_new ("pipewire-main-loop", NULL); + if (core->loop == NULL) + goto loop_failed; core->context = pw_context_new (pw_thread_loop_get_loop(core->loop), NULL, 0); + if (core->context == NULL) + goto context_failed; core->last_seq = -1; core->last_error = 0; GST_DEBUG ("loop %p context %p", core->loop, core->context); @@ -78,6 +82,19 @@ static GstPipeWireCore *make_core (int fd) return core; +loop_failed: + { + GST_ERROR ("error creating threadloop"); + g_free (core); + return NULL; + } +context_failed: + { + GST_ERROR ("error creating context"); + pw_thread_loop_destroy (core->loop); + g_free (core); + return NULL; + } mainloop_failed: { GST_ERROR ("error starting mainloop");