qmlglsrc: Stop when basesrc calls unlock()
authorJan Schmidt <jan@centricular.com>
Tue, 20 Dec 2022 15:31:05 +0000 (02:31 +1100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 21 Dec 2022 12:21:32 +0000 (12:21 +0000)
Instead of stopping capture when the state changes,
handle other cases of basesrc stopping capture by - such
as handling an EOS event - by implementing an unlock()
method

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3612>

subprojects/gst-plugins-good/ext/qt/gstqtsrc.cc

index 615a42b..a405172 100644 (file)
@@ -54,6 +54,7 @@ static GstStateChangeReturn gst_qt_src_change_state (GstElement * element,
     GstStateChange transition);
 static gboolean gst_qt_src_start (GstBaseSrc * basesrc);
 static gboolean gst_qt_src_stop (GstBaseSrc * basesrc);
+static gboolean gst_qt_src_unlock(GstBaseSrc *basesrc);
 
 static GstStaticPadTemplate gst_qt_src_template =
 GST_STATIC_PAD_TEMPLATE ("src",
@@ -123,6 +124,7 @@ gst_qt_src_class_init (GstQtSrcClass * klass)
   gstbasesrc_class->query = gst_qt_src_query;
   gstbasesrc_class->start = gst_qt_src_start;
   gstbasesrc_class->stop = gst_qt_src_stop;
+  gstbasesrc_class->unlock = gst_qt_src_unlock;
   gstbasesrc_class->decide_allocation = gst_qt_src_decide_allocation;
 
   gstpushsrc_class->fill = gst_qt_src_fill;
@@ -513,8 +515,6 @@ 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;
@@ -555,6 +555,15 @@ gst_qt_src_start (GstBaseSrc * basesrc)
 }
 
 static gboolean
+gst_qt_src_unlock(GstBaseSrc *basesrc)
+{
+  GstQtSrc *qt_src = GST_QT_SRC (basesrc);
+  if (qt_src->window)
+    qt_window_stop (qt_src->window);
+  return TRUE;
+}
+
+static gboolean
 gst_qt_src_stop (GstBaseSrc * basesrc)
 {
   return TRUE;