base: Stop using GST_FLOW_IS_FATAL()
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 26 Aug 2010 21:37:07 +0000 (23:37 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 27 Aug 2010 14:59:09 +0000 (16:59 +0200)
And document the special handling of WRONG_STATE.

libs/gst/base/gstbasesink.c
libs/gst/base/gstbasesrc.c

index 97ce7f3..1e0c3cd 100644 (file)
@@ -3933,25 +3933,26 @@ paused:
     GST_LOG_OBJECT (basesink, "pausing task, reason %s",
         gst_flow_get_name (result));
     gst_pad_pause_task (pad);
-    /* fatal errors and NOT_LINKED cause EOS */
-    if (GST_FLOW_IS_FATAL (result) || result == GST_FLOW_NOT_LINKED) {
-      if (result == GST_FLOW_UNEXPECTED) {
-        /* perform EOS logic */
-        if (basesink->segment.flags & GST_SEEK_FLAG_SEGMENT) {
-          gst_element_post_message (GST_ELEMENT_CAST (basesink),
-              gst_message_new_segment_done (GST_OBJECT_CAST (basesink),
-                  basesink->segment.format, basesink->segment.last_stop));
-        } else {
-          gst_base_sink_event (pad, gst_event_new_eos ());
-        }
+    if (result == GST_FLOW_UNEXPECTED) {
+      /* perform EOS logic */
+      if (basesink->segment.flags & GST_SEEK_FLAG_SEGMENT) {
+        gst_element_post_message (GST_ELEMENT_CAST (basesink),
+            gst_message_new_segment_done (GST_OBJECT_CAST (basesink),
+                basesink->segment.format, basesink->segment.last_stop));
       } else {
-        /* for fatal errors we post an error message, post the error
-         * first so the app knows about the error first. */
-        GST_ELEMENT_ERROR (basesink, STREAM, FAILED,
-            (_("Internal data stream error.")),
-            ("stream stopped, reason %s", gst_flow_get_name (result)));
         gst_base_sink_event (pad, gst_event_new_eos ());
       }
+    } else if (result == GST_FLOW_NOT_LINKED || result <= GST_FLOW_UNEXPECTED) {
+      /* for fatal errors we post an error message, post the error
+       * first so the app knows about the error first. 
+       * wrong-state is not a fatal error because it happens due to
+       * flushing and posting an error message in that case is the
+       * wrong thing to do, e.g. when basesrc is doing a flushing
+       * seek. */
+      GST_ELEMENT_ERROR (basesink, STREAM, FAILED,
+          (_("Internal data stream error.")),
+          ("stream stopped, reason %s", gst_flow_get_name (result)));
+      gst_base_sink_event (pad, gst_event_new_eos ());
     }
     return;
   }
index bb511d3..6510b24 100644 (file)
@@ -2525,41 +2525,43 @@ pause:
     GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason);
     src->data.ABI.running = FALSE;
     gst_pad_pause_task (pad);
-    if (GST_FLOW_IS_FATAL (ret) || ret == GST_FLOW_NOT_LINKED) {
-      if (ret == GST_FLOW_UNEXPECTED) {
-        gboolean flag_segment;
-        GstFormat format;
-        gint64 last_stop;
-
-        /* perform EOS logic */
-        flag_segment = (src->segment.flags & GST_SEEK_FLAG_SEGMENT) != 0;
-        format = src->segment.format;
-        last_stop = src->segment.last_stop;
-
-        if (flag_segment) {
-          GstMessage *message;
-
-          message = gst_message_new_segment_done (GST_OBJECT_CAST (src),
-              format, last_stop);
-          gst_message_set_seqnum (message, src->priv->seqnum);
-          gst_element_post_message (GST_ELEMENT_CAST (src), message);
-        } else {
-          event = gst_event_new_eos ();
-          gst_event_set_seqnum (event, src->priv->seqnum);
-          gst_pad_push_event (pad, event);
-          src->priv->last_sent_eos = TRUE;
-        }
+    if (ret == GST_FLOW_UNEXPECTED) {
+      gboolean flag_segment;
+      GstFormat format;
+      gint64 last_stop;
+
+      /* perform EOS logic */
+      flag_segment = (src->segment.flags & GST_SEEK_FLAG_SEGMENT) != 0;
+      format = src->segment.format;
+      last_stop = src->segment.last_stop;
+
+      if (flag_segment) {
+        GstMessage *message;
+
+        message = gst_message_new_segment_done (GST_OBJECT_CAST (src),
+            format, last_stop);
+        gst_message_set_seqnum (message, src->priv->seqnum);
+        gst_element_post_message (GST_ELEMENT_CAST (src), message);
       } else {
         event = gst_event_new_eos ();
         gst_event_set_seqnum (event, src->priv->seqnum);
-        /* for fatal errors we post an error message, post the error
-         * first so the app knows about the error first. */
-        GST_ELEMENT_ERROR (src, STREAM, FAILED,
-            (_("Internal data flow error.")),
-            ("streaming task paused, reason %s (%d)", reason, ret));
         gst_pad_push_event (pad, event);
         src->priv->last_sent_eos = TRUE;
       }
+    } else if (ret == GST_FLOW_NOT_LINKED || ret <= GST_FLOW_UNEXPECTED) {
+      event = gst_event_new_eos ();
+      gst_event_set_seqnum (event, src->priv->seqnum);
+      /* for fatal errors we post an error message, post the error
+       * first so the app knows about the error first.
+       * Also don't do this for WRONG_STATE because it happens
+       * due to flushing and posting an error message because of
+       * that is the wrong thing to do, e.g. when we're doing
+       * a flushing seek. */
+      GST_ELEMENT_ERROR (src, STREAM, FAILED,
+          (_("Internal data flow error.")),
+          ("streaming task paused, reason %s (%d)", reason, ret));
+      gst_pad_push_event (pad, event);
+      src->priv->last_sent_eos = TRUE;
     }
     goto done;
   }