[clutter-gst] auto-sink: Ensure the IS_SINK flag



commit 6f77059040a7da535a2e59288ea284de12b6f28a
Author: Hans-Christian Ebke <christian ebke rwth-aachen de>
Date:   Thu Jan 3 18:04:19 2013 +0000

    auto-sink: Ensure the IS_SINK flag
    
    The ClutterGstAutoVideoSink sets its GST_ELEMENT_IS_SINK flag in its
    init method. However, in contrast to the ClutterGstVideoSink, this class
    is not based on GstBaseSink but on GstBin instead.
    
    The problem is that GstBin automatically sets its GST_ELEMENT_IS_SINK
    flag whenever a sink is added. It also automatically unsets it whenever
    the last sink is removed from the bin.
    
    Now, after the first video clip is finished and the pipeline leaves the
    PLAYING state, the encapsulated ClutterGstVideoSink is removed from the
    ClutterGstAutoVideoSink leaving it without any sinks and thus making it
    lose its GST_ELEMENT_IS_SINK flag. Apparently this happens even before
    the EOS signal is broadcast in the pipeline.
    
    Interestingly, the ClutterGstAutoVideoSink does receive the EOS signal
    and forwards it to its parent, the vbin of the playsink. But the vbin
    ignores the signal because in bin_do_eos (gstbin.c) the is_eos check
    fails. This check, in turn, fails because the bin_element_is_sink check
    fails on its child, the ClutterGstAutoVideoSink (because its
    GST_ELEMENT_IS_SINK flag isn't set anymore).
    
    Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=679611

 clutter-gst/clutter-gst-auto-video-sink.c |   39 +++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/clutter-gst/clutter-gst-auto-video-sink.c b/clutter-gst/clutter-gst-auto-video-sink.c
index 6276e55..4977d5b 100644
--- a/clutter-gst/clutter-gst-auto-video-sink.c
+++ b/clutter-gst/clutter-gst-auto-video-sink.c
@@ -53,6 +53,10 @@ enum
 
 #define DEFAULT_TS_OFFSET           0
 
+static gboolean clutter_gst_auto_video_sink_add (GstBin *    bin,
+                                                 GstElement *element);
+static gboolean clutter_gst_auto_video_sink_remove (GstBin *    bin,
+                                                    GstElement *element);
 G_DEFINE_TYPE (ClutterGstAutoVideoSink,
     clutter_gst_auto_video_sink, GST_TYPE_BIN);
 
@@ -597,6 +601,35 @@ activate_failed:
   }
 }
 
+/*
+ * Call the base class implementation and make
+ * sure that the GST_ELEMENT_FLAG_SINK flag is still
+ * set afterwards.
+ */
+static gboolean
+clutter_gst_auto_video_sink_add (GstBin * bin, GstElement * element)
+{
+  gboolean result;
+
+  result = GST_BIN_CLASS (parent_class)->add_element (bin, element);
+  GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_SINK);
+  return result;
+}
+
+/*
+ * Call the base class implementation and make
+ * sure that the GST_ELEMENT_FLAG_SINK flag is still
+ * set afterwards.
+ */
+static gboolean
+clutter_gst_auto_video_sink_remove (GstBin * bin, GstElement * element) {
+  gboolean result;
+
+  result = GST_BIN_CLASS (parent_class)->remove_element (bin, element);
+  GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_SINK);
+  return result;
+}
+
 static void
 clutter_gst_auto_video_sink_dispose (GObject * object)
 {
@@ -691,6 +724,7 @@ clutter_gst_auto_video_sink_class_init (ClutterGstAutoVideoSinkClass * klass)
 {
   GObjectClass *oclass = G_OBJECT_CLASS (klass);
   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+  GstBinClass *gstbin_class = GST_BIN_CLASS (klass);
   GParamSpec *pspec;
 
   oclass->dispose = clutter_gst_auto_video_sink_dispose;
@@ -729,6 +763,11 @@ clutter_gst_auto_video_sink_class_init (ClutterGstAutoVideoSinkClass * klass)
 
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (clutter_gst_auto_video_sink_change_state);
+
+  gstbin_class->add_element =
+      GST_DEBUG_FUNCPTR (clutter_gst_auto_video_sink_add);
+  gstbin_class->remove_element =
+      GST_DEBUG_FUNCPTR (clutter_gst_auto_video_sink_remove);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]