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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7392>
This commit is contained in:
Jan Schmidt 2024-08-20 22:09:13 +10:00
parent 389f7e0d7b
commit 6cf3d32886

View file

@ -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);
}