consistencychecker: Check for STREAM_START event
authorEdward Hervey <edward.hervey@collabora.co.uk>
Fri, 6 Jul 2012 09:38:58 +0000 (11:38 +0200)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Fri, 6 Jul 2012 10:48:43 +0000 (12:48 +0200)
Check that it is always before any serialized event.

libs/gst/check/gstconsistencychecker.c

index 576b575..76c10d7 100644 (file)
@@ -40,6 +40,8 @@ struct _GstStreamConsistency
   volatile gboolean segment;
   volatile gboolean eos;
   volatile gboolean expect_flush;
+  volatile gboolean saw_serialized_event;
+  volatile gboolean saw_stream_start;
   GstObject *parent;
   GList *pads;
 };
@@ -71,7 +73,7 @@ source_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
   } else if (GST_IS_EVENT (data)) {
     GstEvent *event = (GstEvent *) data;
 
-    GST_DEBUG_OBJECT (pad, "%s", GST_EVENT_TYPE_NAME (event));
+    GST_DEBUG_OBJECT (pad, "Event : %s", GST_EVENT_TYPE_NAME (event));
     switch (GST_EVENT_TYPE (event)) {
       case GST_EVENT_FLUSH_START:
         /* getting two flush_start in a row seems to be okay
@@ -87,6 +89,10 @@ source_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
         consist->flushing = consist->expect_flush = FALSE;
         break;
       case GST_EVENT_STREAM_START:
+        fail_if (consist->saw_serialized_event && !consist->saw_stream_start,
+            "Got a STREAM_START event after a serialized event");
+        consist->saw_stream_start = TRUE;
+        break;
       case GST_EVENT_STREAM_CONFIG:
       case GST_EVENT_CAPS:
         /* ok to have these before segment event */
@@ -116,6 +122,12 @@ source_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
         /* FIXME : Figure out what to do for other events */
         break;
     }
+    if (GST_EVENT_IS_SERIALIZED (event)) {
+      fail_if (!consist->saw_stream_start
+          && GST_EVENT_TYPE (event) != GST_EVENT_STREAM_START,
+          "Got a serialized event before a STREAM_START");
+      consist->saw_serialized_event = TRUE;
+    }
   }
 
   return TRUE;
@@ -252,9 +264,12 @@ gst_consistency_checker_add_pad (GstStreamConsistency * consist, GstPad * pad)
 void
 gst_consistency_checker_reset (GstStreamConsistency * consist)
 {
-  consist->eos = FALSE;
   consist->flushing = FALSE;
   consist->segment = FALSE;
+  consist->eos = FALSE;
+  consist->expect_flush = FALSE;
+  consist->saw_serialized_event = FALSE;
+  consist->saw_stream_start = FALSE;
 }
 
 /**