From 2dfb0d2772eec352eac20656b7e12f626eb50c76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 26 Aug 2010 23:37:07 +0200 Subject: [PATCH] base: Stop using GST_FLOW_IS_FATAL() And document the special handling of WRONG_STATE. --- libs/gst/base/gstbasesink.c | 33 +++++++++++++------------ libs/gst/base/gstbasesrc.c | 60 +++++++++++++++++++++++---------------------- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 97ce7f3..1e0c3cd 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -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; } diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index bb511d3..6510b24 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -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; } -- 2.7.4