gst/gstpipeline.c: Modify the clock distribution path in PAUSED->PLAYING so that we never attempt to choose a new clo...

Original commit message from CVS:
* gst/gstpipeline.c: (gst_pipeline_change_state):
Modify the clock distribution path in PAUSED->PLAYING so that we
never attempt to choose a new clock unless we're actually leaving
the PAUSED state for the first time. This prevents choosing a
different clock when the state_change gets called for a 2nd time due
to some element doing an async state change.
This commit is contained in:
Jan Schmidt 2007-03-23 17:52:19 +00:00
parent 12111f3107
commit cf4a1965da
2 changed files with 48 additions and 31 deletions

View file

@ -1,3 +1,12 @@
2007-03-23 Jan Schmidt <thaytan@mad.scientist.com>
* gst/gstpipeline.c: (gst_pipeline_change_state):
Modify the clock distribution path in PAUSED->PLAYING so that we
never attempt to choose a new clock unless we're actually leaving
the PAUSED state for the first time. This prevents choosing a
different clock when the state_change gets called for a 2nd time due
to some element doing an async state change.
2007-03-22 Sebastian Dröge <slomo@circular-chaos.org>
* gst/gstpad.c: (gst_pad_set_caps), (gst_pad_configure_sink),

View file

@ -371,48 +371,53 @@ gst_pipeline_change_state (GstElement * element, GstStateChange transition)
GstClockTime start_time, stream_time, delay;
gboolean new_clock, update;
gboolean res;
GstClock *cur_clock;
GST_DEBUG_OBJECT (element, "selecting clock and base_time");
/* when going to playing, select a clock */
clock = gst_element_provide_clock (element);
if (clock) {
start_time = gst_clock_get_time (clock);
} else {
GST_DEBUG ("no clock, using base time of NONE");
start_time = GST_CLOCK_TIME_NONE;
new_base_time = GST_CLOCK_TIME_NONE;
}
GST_OBJECT_LOCK (element);
new_clock = element->clock != clock;
cur_clock = element->clock;
if (cur_clock)
gst_object_ref (cur_clock);
stream_time = pipeline->stream_time;
update = pipeline->priv->new_stream_time;
pipeline->priv->new_stream_time = FALSE;
delay = pipeline->delay;
GST_OBJECT_UNLOCK (element);
if (new_clock) {
/* now distribute the clock (which could be NULL). If some
* element refuses the clock, this will return FALSE and
* we effectively fail the state change. */
if (!gst_element_set_clock (element, clock))
goto invalid_clock;
/* if we selected and distributed a new clock, let the app
* know about it */
gst_element_post_message (element,
gst_message_new_new_clock (GST_OBJECT_CAST (element), clock));
}
if (clock)
gst_object_unref (clock);
/* stream time changed, either with a PAUSED or a flush, we need to update
* the base time */
/* stream time changed, either with a PAUSED or a flush, we need to check
* if there is a new clock & update the base time */
if (update) {
GST_DEBUG_OBJECT (pipeline, "stream_time changed, updating base time");
GST_DEBUG_OBJECT (pipeline, "stream_time changed. "
"Updating base time and checking for new clock.");
/* when going to playing, select a clock */
clock = gst_element_provide_clock (element);
new_clock = (clock != cur_clock);
if (clock) {
start_time = gst_clock_get_time (clock);
} else {
GST_DEBUG ("no clock, using base time of NONE");
start_time = GST_CLOCK_TIME_NONE;
new_base_time = GST_CLOCK_TIME_NONE;
}
if (new_clock) {
/* now distribute the clock (which could be NULL). If some
* element refuses the clock, this will return FALSE and
* we effectively fail the state change. */
if (!gst_element_set_clock (element, clock))
goto invalid_clock;
/* if we selected and distributed a new clock, let the app
* know about it */
gst_element_post_message (element,
gst_message_new_new_clock (GST_OBJECT_CAST (element), clock));
}
if (clock)
gst_object_unref (clock);
if (stream_time != GST_CLOCK_TIME_NONE
&& start_time != GST_CLOCK_TIME_NONE) {
@ -435,6 +440,9 @@ gst_pipeline_change_state (GstElement * element, GstStateChange transition)
"NOT adjusting base_time because we selected one before");
}
if (cur_clock)
gst_object_unref (cur_clock);
/* determine latency in this pipeline */
GST_DEBUG_OBJECT (element, "querying pipeline latency");
query = gst_query_new_latency ();