basesrc: handle flush better

Unlock the streaming thread when flushing so that we can
insert the flush-stop correctly.
This commit is contained in:
Wim Taymans 2013-08-14 16:58:41 +02:00
parent 516261b0b9
commit d95c227641

View file

@ -1698,8 +1698,10 @@ gst_base_src_send_event (GstElement * element, GstEvent * event)
{ {
GstBaseSrc *src; GstBaseSrc *src;
gboolean result = FALSE; gboolean result = FALSE;
GstBaseSrcClass *bclass;
src = GST_BASE_SRC (element); src = GST_BASE_SRC (element);
bclass = GST_BASE_SRC_GET_CLASS (src);
GST_DEBUG_OBJECT (src, "handling event %p %" GST_PTR_FORMAT, event, event); GST_DEBUG_OBJECT (src, "handling event %p %" GST_PTR_FORMAT, event, event);
@ -1708,26 +1710,37 @@ gst_base_src_send_event (GstElement * element, GstEvent * event)
case GST_EVENT_FLUSH_START: case GST_EVENT_FLUSH_START:
GST_DEBUG_OBJECT (src, "pushing flush-start event downstream"); GST_DEBUG_OBJECT (src, "pushing flush-start event downstream");
result = gst_pad_push_event (src->srcpad, event); result = gst_pad_push_event (src->srcpad, event);
/* also unblock the create function */
gst_base_src_set_flushing (src, TRUE, FALSE, NULL);
event = NULL; event = NULL;
break; break;
case GST_EVENT_FLUSH_STOP: case GST_EVENT_FLUSH_STOP:
{
gboolean start;
GST_LIVE_LOCK (src); GST_LIVE_LOCK (src);
src->priv->segment_pending = TRUE; src->priv->segment_pending = TRUE;
/* sending random flushes downstream can break stuff,
* especially sync since all segment info will get flushed */
GST_DEBUG_OBJECT (src, "pushing flush-stop event downstream"); GST_DEBUG_OBJECT (src, "pushing flush-stop event downstream");
result = gst_pad_push_event (src->srcpad, event); result = gst_pad_push_event (src->srcpad, event);
gst_base_src_activate_pool (src, TRUE);
GST_OBJECT_LOCK (src->srcpad);
start = (GST_PAD_MODE (src->srcpad) == GST_PAD_MODE_PUSH);
GST_OBJECT_UNLOCK (src->srcpad);
if (start)
gst_pad_start_task (src->srcpad, (GstTaskFunction) gst_base_src_loop,
src->srcpad, NULL);
GST_DEBUG_OBJECT (src, "signal");
GST_LIVE_SIGNAL (src);
GST_LIVE_UNLOCK (src); GST_LIVE_UNLOCK (src);
event = NULL; event = NULL;
break; break;
}
/* downstream serialized events */ /* downstream serialized events */
case GST_EVENT_EOS: case GST_EVENT_EOS:
{ {
GstBaseSrcClass *bclass;
bclass = GST_BASE_SRC_GET_CLASS (src);
/* queue EOS and make sure the task or pull function performs the EOS /* queue EOS and make sure the task or pull function performs the EOS
* actions. * actions.
* *