From 1c60558d8c0d9890e89fea0519aa321a94e4252f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 15 Jun 2012 14:54:48 +0200 Subject: [PATCH] basesrc: avoid flush when starting When we are doing the initial seek in startup, avoid doing a flush (and unlock) because we know that the task is not started yet. --- libs/gst/base/gstbasesrc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index e034580..a832802 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -1483,7 +1483,7 @@ not_ok: * instead of EOS when doing a segment seek. */ static gboolean -gst_base_src_perform_seek (GstBaseSrc * src, GstEvent * event) +gst_base_src_perform_seek (GstBaseSrc * src, GstEvent * event, gboolean unlock) { gboolean res = TRUE, tres; gdouble rate; @@ -1542,7 +1542,8 @@ gst_base_src_perform_seek (GstBaseSrc * src, GstEvent * event) gst_pad_pause_task (src->srcpad); /* unblock streaming thread. */ - gst_base_src_set_flushing (src, TRUE, FALSE, &playing); + if (unlock) + gst_base_src_set_flushing (src, TRUE, FALSE, &playing); /* grab streaming lock, this should eventually be possible, either * because the task is paused, our streaming thread stopped @@ -1557,7 +1558,8 @@ gst_base_src_perform_seek (GstBaseSrc * src, GstEvent * event) GST_DEBUG_OBJECT (src, "seek with seqnum %" G_GUINT32_FORMAT, seqnum); } - gst_base_src_set_flushing (src, FALSE, playing, NULL); + if (unlock) + gst_base_src_set_flushing (src, FALSE, playing, NULL); /* If we configured the seeksegment above, don't overwrite it now. Otherwise * copy the current segment info into the temp segment that we can actually @@ -1772,7 +1774,7 @@ gst_base_src_send_event (GstElement * element, GstEvent * event) GST_DEBUG_OBJECT (src, "performing seek"); /* when we are running in push mode, we can execute the * seek right now. */ - result = gst_base_src_perform_seek (src, event); + result = gst_base_src_perform_seek (src, event, TRUE); } else { GstEvent **event_p; @@ -1867,7 +1869,7 @@ gst_base_src_default_event (GstBaseSrc * src, GstEvent * event) if (!gst_base_src_seekable (src)) goto not_seekable; - result = gst_base_src_perform_seek (src, event); + result = gst_base_src_perform_seek (src, event, TRUE); break; case GST_EVENT_FLUSH_START: /* cancel any blocking getrange, is normally called @@ -3157,8 +3159,9 @@ gst_base_src_start_complete (GstBaseSrc * basesrc, GstFlowReturn ret) basesrc->pending_seek = NULL; GST_OBJECT_UNLOCK (basesrc); - /* The perform seek code will start the task when finished. */ - if (G_UNLIKELY (!gst_base_src_perform_seek (basesrc, event))) + /* The perform seek code will start the task when finished. We don't have to + * unlock the streaming thread because it is not running yet */ + if (G_UNLIKELY (!gst_base_src_perform_seek (basesrc, event, FALSE))) goto seek_failed; if (event) @@ -3295,6 +3298,8 @@ gst_base_src_set_flushing (GstBaseSrc * basesrc, bclass = GST_BASE_SRC_GET_CLASS (basesrc); + GST_DEBUG_OBJECT (basesrc, "flushing %d, live_play %d", flushing, live_play); + if (flushing) { gst_base_src_activate_pool (basesrc, FALSE); /* unlock any subclasses, we need to do this before grabbing the -- 2.7.4