+ GST_QUEUE_MUTEX_LOCK (queue);
+
+ /* STREAM_START and SEGMENT reset the EOS status of a
+ * pad. Change the cached sinkpad flow result accordingly */
+ if (queue->srcresult == GST_FLOW_EOS
+ && (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START
+ || GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT))
+ queue->srcresult = GST_FLOW_OK;
+
+ if (queue->srcresult != GST_FLOW_OK) {
+ /* Errors in sticky event pushing are no problem and ignored here
+ * as they will cause more meaningful errors during data flow.
+ * For EOS events, that are not followed by data flow, we still
+ * return FALSE here though and report an error.
+ */
+ if (!GST_EVENT_IS_STICKY (event)) {
+ GST_QUEUE_MUTEX_UNLOCK (queue);
+ goto out_flow_error;
+ } else if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
+ if (queue->srcresult == GST_FLOW_NOT_LINKED
+ || queue->srcresult < GST_FLOW_EOS) {
+ GST_QUEUE_MUTEX_UNLOCK (queue);
+ GST_ELEMENT_FLOW_ERROR (queue, queue->srcresult);
+ } else {
+ GST_QUEUE_MUTEX_UNLOCK (queue);
+ }
+ goto out_flow_error;
+ }
+ }
+
+ /* refuse more events on EOS unless they unset the EOS status */
+ if (queue->eos) {
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_STREAM_START:
+ case GST_EVENT_SEGMENT:
+ /* Restart the loop */
+ if (GST_PAD_MODE (queue->srcpad) == GST_PAD_MODE_PUSH) {
+ queue->srcresult = GST_FLOW_OK;
+ queue->eos = FALSE;
+ queue->unexpected = FALSE;
+ gst_pad_start_task (queue->srcpad,
+ (GstTaskFunction) gst_queue_loop, queue->srcpad, NULL);
+ } else {
+ queue->eos = FALSE;
+ queue->unexpected = FALSE;
+ }
+
+ break;
+ default:
+ goto out_eos;
+ }
+ }
+