From c8b92755781b652862d7d2a15cfe5860ed8fe2a5 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Mon, 4 Jul 2011 12:58:54 +0200 Subject: [PATCH] basesink: try harder to arrange increasing position reporting ... rather than having a momentary decreasing one while transitioning to PLAYING. Fixes #628021. --- libs/gst/base/gstbasesink.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index d60ba6f..b9f2f7c 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -231,6 +231,8 @@ struct _GstBaseSinkPrivate /* if we already commited the state */ gboolean commited; + /* state change to playing ongoing */ + gboolean to_playing; /* when we received EOS */ gboolean received_eos; @@ -4584,6 +4586,14 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, else 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 */ if (GST_CLOCK_TIME_IS_VALID (segment->time)) time = segment->time; @@ -4988,6 +4998,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition) break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: GST_PAD_PREROLL_LOCK (basesink->sinkpad); + g_atomic_int_set (&basesink->priv->to_playing, TRUE); if (!gst_base_sink_needs_preroll (basesink)) { GST_DEBUG_OBJECT (basesink, "PAUSED to PLAYING, don't need preroll"); /* no preroll needed anymore now. */ @@ -5034,6 +5045,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: + g_atomic_int_set (&basesink->priv->to_playing, FALSE); GST_DEBUG_OBJECT (basesink, "PLAYING to PAUSED"); /* FIXME, make sure we cannot enter _render first */ -- 2.7.4