From 6cf3d32886d83b8eb6ed48699721b67ca609edb4 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 20 Aug 2024 22:09:13 +1000 Subject: [PATCH] gstplayer: Check GstPlayerSignalDispatcher type Before trying to retrieve a GMainContext from a provided GstPlayerSignalDispatcher, check that it is actually GstPlayerGMainContextSignalDispatcher. If not, use the default GMainContext for dispatching signals via the adapter Part-of: --- .../gst-libs/gst/player/gstplayer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c b/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c index ad78731ae4..2f6926210f 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c @@ -49,6 +49,7 @@ #include "gstplayer.h" #include "gstplayer-signal-dispatcher-private.h" +#include "gstplayer-g-main-context-signal-dispatcher.h" #include "gstplayer-video-renderer-private.h" #include "gstplayer-media-info-private.h" #include "gstplayer-wrapped-video-renderer-private.h" @@ -576,11 +577,16 @@ gst_player_constructed (GObject * object) if (self->signal_dispatcher != NULL) { GMainContext *context = NULL; - g_object_get (self->signal_dispatcher, "application-context", &context, - NULL); - self->signal_adapter = - gst_play_signal_adapter_new_with_main_context (self->play, context); - g_main_context_unref (context); + if (GST_IS_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER + (self->signal_dispatcher)) { + g_object_get (self->signal_dispatcher, "application-context", &context, + NULL); + self->signal_adapter = + gst_play_signal_adapter_new_with_main_context (self->play, context); + g_main_context_unref (context); + } else { + self->signal_adapter = gst_play_signal_adapter_new (self->play); + } } else { self->signal_adapter = gst_play_signal_adapter_new_sync_emit (self->play); }