basesink: try harder to arrange increasing position reporting

... rather than having a momentary decreasing one while transitioning
to PLAYING.

Fixes #628021.
This commit is contained in:
Mark Nauwelaerts 2011-07-04 12:58:54 +02:00
parent f47c3472df
commit c8b9275578

View file

@ -231,6 +231,8 @@ struct _GstBaseSinkPrivate
/* if we already commited the state */ /* if we already commited the state */
gboolean commited; gboolean commited;
/* state change to playing ongoing */
gboolean to_playing;
/* when we received EOS */ /* when we received EOS */
gboolean received_eos; gboolean received_eos;
@ -4584,6 +4586,14 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
else else
gst_object_ref (clock); gst_object_ref (clock);
/* mainloop might be querying position when going to playing async,
* while (audio) rendering might be quickly advancing stream position,
* so use clock asap rather than last reported position */
if (in_paused && with_clock && g_atomic_int_get (&basesink->priv->to_playing)) {
GST_DEBUG_OBJECT (basesink, "going to PLAYING, so not PAUSED");
in_paused = FALSE;
}
/* collect all data we need holding the lock */ /* collect all data we need holding the lock */
if (GST_CLOCK_TIME_IS_VALID (segment->time)) if (GST_CLOCK_TIME_IS_VALID (segment->time))
time = segment->time; time = segment->time;
@ -4988,6 +4998,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
break; break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING: case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
GST_PAD_PREROLL_LOCK (basesink->sinkpad); GST_PAD_PREROLL_LOCK (basesink->sinkpad);
g_atomic_int_set (&basesink->priv->to_playing, TRUE);
if (!gst_base_sink_needs_preroll (basesink)) { if (!gst_base_sink_needs_preroll (basesink)) {
GST_DEBUG_OBJECT (basesink, "PAUSED to PLAYING, don't need preroll"); GST_DEBUG_OBJECT (basesink, "PAUSED to PLAYING, don't need preroll");
/* no preroll needed anymore now. */ /* no preroll needed anymore now. */
@ -5034,6 +5045,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_PLAYING_TO_PAUSED: case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
g_atomic_int_set (&basesink->priv->to_playing, FALSE);
GST_DEBUG_OBJECT (basesink, "PLAYING to PAUSED"); GST_DEBUG_OBJECT (basesink, "PLAYING to PAUSED");
/* FIXME, make sure we cannot enter _render first */ /* FIXME, make sure we cannot enter _render first */