libs/gst/base/gstbasesrc.c: Call unlock for live sources so that they can't get stuck in _create and produce a buffer...

Original commit message from CVS:
* libs/gst/base/gstbasesrc.c: (gst_base_src_do_sync),
(gst_base_src_get_range), (gst_base_src_change_state):
Call unlock for live sources so that they can't get stuck in _create and
produce a buffer before they are set back to PLAYING.
This commit is contained in:
Wim Taymans 2007-10-02 15:20:58 +00:00
parent 3a63262829
commit d39d3debfc
2 changed files with 31 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2007-10-02 Wim Taymans <wim.taymans@gmail.com>
* libs/gst/base/gstbasesrc.c: (gst_base_src_do_sync),
(gst_base_src_get_range), (gst_base_src_change_state):
Call unlock for live sources so that they can't get stuck in _create and
produce a buffer before they are set back to PLAYING.
2007-10-02 Edward Hervey <bilboed@bilboed.com> 2007-10-02 Edward Hervey <bilboed@bilboed.com>
* plugins/elements/gstqueue.c: (gst_queue_locked_enqueue), * plugins/elements/gstqueue.c: (gst_queue_locked_enqueue),

View file

@ -1626,6 +1626,9 @@ gst_base_src_do_sync (GstBaseSrc * basesrc, GstBuffer * buffer)
now = gst_clock_get_time (clock); now = gst_clock_get_time (clock);
GST_BUFFER_TIMESTAMP (buffer) = now - base_time; GST_BUFFER_TIMESTAMP (buffer) = now - base_time;
GST_LOG_OBJECT (basesrc, "created timestamp: %" GST_TIME_FORMAT,
GST_TIME_ARGS (now - base_time));
} }
} }
@ -1773,7 +1776,7 @@ gst_base_src_get_range (GstBaseSrc * src, guint64 offset, guint length,
ret = bclass->create (src, offset, length, buf); ret = bclass->create (src, offset, length, buf);
if (G_UNLIKELY (ret != GST_FLOW_OK)) if (G_UNLIKELY (ret != GST_FLOW_OK))
goto done; goto not_ok;
/* no timestamp set and we are at offset 0, we can timestamp with 0 */ /* no timestamp set and we are at offset 0, we can timestamp with 0 */
if (offset == 0 && src->segment.time == 0 if (offset == 0 && src->segment.time == 0
@ -1812,13 +1815,19 @@ gst_base_src_get_range (GstBaseSrc * src, guint64 offset, guint length,
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
break; break;
} }
done:
return ret; return ret;
/* ERROR */ /* ERROR */
stopped: stopped:
{ {
GST_DEBUG_OBJECT (src, "wait_playing returned %d", ret); GST_DEBUG_OBJECT (src, "wait_playing returned %d (%s)", ret,
gst_flow_get_name (ret));
return ret;
}
not_ok:
{
GST_DEBUG_OBJECT (src, "create returned %d (%s)", ret,
gst_flow_get_name (ret));
return ret; return ret;
} }
not_started: not_started:
@ -2498,10 +2507,21 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PAUSED_TO_PLAYING: case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
GST_LIVE_LOCK (element); GST_LIVE_LOCK (element);
if (basesrc->is_live) { if (basesrc->is_live) {
gboolean start;
gst_base_src_unlock_stop (basesrc);
/* for live sources we restart the timestamp correction */ /* for live sources we restart the timestamp correction */
basesrc->priv->latency = -1; basesrc->priv->latency = -1;
basesrc->live_running = TRUE; basesrc->live_running = TRUE;
GST_LIVE_SIGNAL (element); GST_LIVE_SIGNAL (element);
/* have to restart the task in case it stopped because of the unlock when
* we went to PAUSED. Only do this if we operating in push mode. */
GST_OBJECT_LOCK (basesrc->srcpad);
start = (GST_PAD_ACTIVATE_MODE (basesrc->srcpad) == GST_ACTIVATE_PUSH);
GST_OBJECT_UNLOCK (basesrc->srcpad);
if (start)
gst_pad_start_task (basesrc->srcpad,
(GstTaskFunction) gst_base_src_loop, basesrc->srcpad);
} }
GST_LIVE_UNLOCK (element); GST_LIVE_UNLOCK (element);
break; break;
@ -2518,6 +2538,7 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED: case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
GST_LIVE_LOCK (element); GST_LIVE_LOCK (element);
if (basesrc->is_live) { if (basesrc->is_live) {
gst_base_src_unlock (basesrc);
no_preroll = TRUE; no_preroll = TRUE;
basesrc->live_running = FALSE; basesrc->live_running = FALSE;
} }