From fe623d93a14b1169336f4f8e137160053bd66658 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sat, 27 Jan 2024 12:02:07 +0100 Subject: [PATCH] BugFix Clear state and unref playbin --- src/MediaPlayer.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/MediaPlayer.cpp b/src/MediaPlayer.cpp index 31855e9..06fb050 100644 --- a/src/MediaPlayer.cpp +++ b/src/MediaPlayer.cpp @@ -451,8 +451,7 @@ void MediaPlayer::execute_open() // set playbin sink g_object_set ( G_OBJECT (pipeline_), "video-sink", sink, NULL); - // done with ref to sink - gst_object_unref (sink); + // done with ref to caps gst_caps_unref (caps); #ifdef USE_GST_OPENGL_SYNC_HANDLER @@ -708,16 +707,13 @@ void MediaPlayer::Frame::unmap() void delayed_terminate( GstElement *p ) { - GstObject *__pipeline = (GstObject *) gst_object_ref(p); - // end pipeline - gst_element_set_state ( GST_ELEMENT(__pipeline), GST_STATE_NULL); + gst_element_set_state ( p, GST_STATE_NULL); // unref to free pipeline - gst_object_unref ( __pipeline ); + gst_object_unref ( p ); } - void MediaPlayer::close() { // not opened? @@ -743,7 +739,7 @@ void MediaPlayer::close() // clean up GST if (pipeline_ != nullptr) { - // end pipeline asynchronously // TODO more stress test? + // end pipeline asynchronously std::thread(delayed_terminate, pipeline_).detach(); pipeline_ = nullptr;