BugFix Clear state and unref playbin

This commit is contained in:
Bruno Herbelin
2024-01-27 12:02:07 +01:00
parent d41b8a7c24
commit fe623d93a1

View File

@@ -451,8 +451,7 @@ void MediaPlayer::execute_open()
// set playbin sink // set playbin sink
g_object_set ( G_OBJECT (pipeline_), "video-sink", sink, NULL); g_object_set ( G_OBJECT (pipeline_), "video-sink", sink, NULL);
// done with ref to sink // done with ref to caps
gst_object_unref (sink);
gst_caps_unref (caps); gst_caps_unref (caps);
#ifdef USE_GST_OPENGL_SYNC_HANDLER #ifdef USE_GST_OPENGL_SYNC_HANDLER
@@ -708,16 +707,13 @@ void MediaPlayer::Frame::unmap()
void delayed_terminate( GstElement *p ) void delayed_terminate( GstElement *p )
{ {
GstObject *__pipeline = (GstObject *) gst_object_ref(p);
// end pipeline // end pipeline
gst_element_set_state ( GST_ELEMENT(__pipeline), GST_STATE_NULL); gst_element_set_state ( p, GST_STATE_NULL);
// unref to free pipeline // unref to free pipeline
gst_object_unref ( __pipeline ); gst_object_unref ( p );
} }
void MediaPlayer::close() void MediaPlayer::close()
{ {
// not opened? // not opened?
@@ -743,7 +739,7 @@ void MediaPlayer::close()
// clean up GST // clean up GST
if (pipeline_ != nullptr) { if (pipeline_ != nullptr) {
// end pipeline asynchronously // TODO more stress test? // end pipeline asynchronously
std::thread(delayed_terminate, pipeline_).detach(); std::thread(delayed_terminate, pipeline_).detach();
pipeline_ = nullptr; pipeline_ = nullptr;