From 10fee807b9a32f1e7e81866874495bee42db2a54 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Fri, 11 Mar 2022 15:13:21 +0100 Subject: [PATCH] qmlglsrc: Fix deadlock when stopping This fix makes sure that streaming thread stops waiting when the qmlglsrc element transitions from playing to paused. Part-of: --- subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc | 2 ++ subprojects/gst-plugins-good/ext/qt/qtwindow.cc | 12 ++++++++++++ subprojects/gst-plugins-good/ext/qt/qtwindow.h | 1 + 3 files changed, 15 insertions(+) diff --git a/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc b/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc index 57fb9907c4..615a42ba8c 100644 --- a/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc +++ b/subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc @@ -513,6 +513,8 @@ gst_qt_src_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: + if (qt_src->window) + qt_window_stop (qt_src->window); break; case GST_STATE_CHANGE_PAUSED_TO_READY: break; diff --git a/subprojects/gst-plugins-good/ext/qt/qtwindow.cc b/subprojects/gst-plugins-good/ext/qt/qtwindow.cc index a2d931b290..16104e4df4 100644 --- a/subprojects/gst-plugins-good/ext/qt/qtwindow.cc +++ b/subprojects/gst-plugins-good/ext/qt/qtwindow.cc @@ -450,3 +450,15 @@ qt_window_use_default_fbo (QtGLWindow * qt_window, gboolean useDefaultFbo) g_mutex_unlock (&qt_window->priv->lock); } + +void +qt_window_stop(QtGLWindow* qt_window) +{ + g_mutex_lock(&qt_window->priv->lock); + + GST_DEBUG("stop window"); + qt_window->priv->updated = TRUE; + g_cond_signal(&qt_window->priv->update_cond); + + g_mutex_unlock(&qt_window->priv->lock); +} diff --git a/subprojects/gst-plugins-good/ext/qt/qtwindow.h b/subprojects/gst-plugins-good/ext/qt/qtwindow.h index b6b529ee2d..33f62d9159 100644 --- a/subprojects/gst-plugins-good/ext/qt/qtwindow.h +++ b/subprojects/gst-plugins-good/ext/qt/qtwindow.h @@ -64,6 +64,7 @@ gboolean qt_window_set_context (QtGLWindow * qt_window, GstGLContext * co GstGLDisplay * qt_window_get_display (QtGLWindow * qt_window); gboolean qt_window_is_scenegraph_initialized (QtGLWindow * qt_window); void qt_window_use_default_fbo (QtGLWindow * qt_window, gboolean useDefaultFbo); +void qt_window_stop(QtGLWindow* qt_window); } #endif /* __QT_WINDOW_H__ */