dv1394src: Post clock-provide and clock-lost messages when going from/to PLAYING
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 9 Jul 2010 15:33:55 +0000 (17:33 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 16 Jul 2010 15:45:39 +0000 (17:45 +0200)
In PAUSED and below the clock is not working.

ext/raw1394/gstdv1394src.c

index 9a05798b363433a26fad745942f44bfa25ad3a94..17708a71988782a0afdc1cc1cfb917277ebc9fce 100644 (file)
@@ -130,6 +130,8 @@ static void gst_dv1394src_get_property (GObject * object, guint prop_id,
 static void gst_dv1394src_dispose (GObject * object);
 
 static GstClock *gst_dv1394src_provide_clock (GstElement * element);
+static GstStateChangeReturn gst_dv1394_src_change_state (GstElement * element,
+    GstStateChange transition);
 
 static gboolean gst_dv1394src_start (GstBaseSrc * bsrc);
 static gboolean gst_dv1394src_stop (GstBaseSrc * bsrc);
@@ -197,6 +199,7 @@ gst_dv1394src_class_init (GstDV1394SrcClass * klass)
   gobject_class->dispose = gst_dv1394src_dispose;
 
   gstelement_class->provide_clock = gst_dv1394src_provide_clock;
+  gstelement_class->change_state = gst_dv1394_src_change_state;
 
   gst_dv1394src_signals[SIGNAL_FRAME_DROPPED] =
       g_signal_new ("frame-dropped", G_TYPE_FROM_CLASS (klass),
@@ -381,6 +384,39 @@ gst_dv1394src_provide_clock (GstElement * element)
   return GST_CLOCK_CAST (gst_object_ref (dv1394src->provided_clock));
 }
 
+static GstStateChangeReturn
+gst_dv1394_src_change_state (GstElement * element, GstStateChange transition)
+{
+  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+  GstDV1394Src *src = GST_DV1394SRC (element);
+
+  switch (transition) {
+    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+      gst_element_post_message (element,
+          gst_message_new_clock_lost (GST_OBJECT_CAST (element),
+              GST_CLOCK_CAST (src->provided_clock)));
+      break;
+    default:
+      break;
+  }
+
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+  if (ret == GST_STATE_CHANGE_FAILURE)
+    return ret;
+
+  switch (transition) {
+    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
+      gst_element_post_message (element,
+          gst_message_new_clock_provide (GST_OBJECT_CAST (element),
+              GST_CLOCK_CAST (src->provided_clock), TRUE));
+      break;
+    default:
+      break;
+  }
+
+  return ret;
+}
+
 #ifdef HAVE_LIBIEC61883
 static GstDV1394Src *
 gst_dv1394src_from_raw1394handle (raw1394handle_t handle)