From f060b8b6f3cb58ca49934a8466d572a6d1605eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 13 Aug 2022 11:49:08 +0300 Subject: [PATCH] play: Fix object construction Ideally new() functions should simply call g_object_new() and not much else, so let's do that here and handle all the construction properly in a GObject way. Now a play object created via g_object_new() is actually usable. Part-of: --- .../gst-libs/gst/play/gstplay.c | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c b/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c index c26cc708f6..63bbf64e9a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c @@ -212,6 +212,8 @@ static void gst_play_constructed (GObject * object); static gpointer gst_play_main (gpointer data); +static void gst_play_set_playbin_video_sink (GstPlay * self); + static void gst_play_seek_internal_locked (GstPlay * self); static void gst_play_stop_internal (GstPlay * self, gboolean transient); static gboolean gst_play_pause_internal (gpointer user_data); @@ -509,6 +511,8 @@ gst_play_constructed (GObject * object) self->thread = g_thread_new ("GstPlay", gst_play_main, self); while (!self->loop || !g_main_loop_is_running (self->loop)) g_cond_wait (&self->cond, &self->lock); + + gst_play_set_playbin_video_sink (self); g_mutex_unlock (&self->lock); G_OBJECT_CLASS (parent_class)->constructed (object); @@ -612,7 +616,14 @@ gst_play_set_property (GObject * object, guint prop_id, g_mutex_lock (&self->lock); g_clear_object (&self->video_renderer); self->video_renderer = g_value_dup_object (value); - gst_play_set_playbin_video_sink (self); + + // When the video_renderer is a GstPlayerWrappedVideoRenderer it cannot be set + // at construction time because it requires a valid pipeline which is created + // only after GstPlay has been constructed. That is why the video renderer is + // set *after* GstPlay has been constructed. + if (self->thread) { + gst_play_set_playbin_video_sink (self); + } g_mutex_unlock (&self->lock); break; case PROP_URI:{ @@ -2648,15 +2659,8 @@ gst_play_new (GstPlayVideoRenderer * video_renderer) g_once (&once, gst_play_init_once, NULL); - self = g_object_new (GST_TYPE_PLAY, NULL); + self = g_object_new (GST_TYPE_PLAY, "video-renderer", video_renderer, NULL); - // When the video_renderer is a GstPlayerWrappedVideoRenderer it cannot be set - // at construction time because it requires a valid pipeline which is created - // only after GstPlay has been constructed. That is why the video renderer is - // set *after* GstPlay has been constructed. - if (video_renderer != NULL) { - g_object_set (self, "video-renderer", video_renderer, NULL); - } gst_object_ref_sink (self); if (video_renderer)