From 1d57e46dbd967e3e509e7d190a52c1fcfe0afd8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 20 May 2011 13:03:51 +0200 Subject: [PATCH] basesink: Only reinit the cached GstClockID if it is for the same clock The clock might have changed since the clock ID was created and in that case we have to request a new one. --- libs/gst/base/gstbasesink.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 7740a77..c342d3c 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -2186,14 +2186,21 @@ gst_base_sink_wait_clock (GstBaseSink * sink, GstClockTime time, time += base_time; /* Re-use existing clockid if available */ - if (G_LIKELY (sink->priv->cached_clock_id != NULL)) { + /* FIXME: Casting to GstClockEntry only works because the types + * are the same */ + if (G_LIKELY (sink->priv->cached_clock_id != NULL + && GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink-> + priv->cached_clock_id) == clock)) { if (!gst_clock_single_shot_id_reinit (clock, sink->priv->cached_clock_id, time)) { gst_clock_id_unref (sink->priv->cached_clock_id); sink->priv->cached_clock_id = gst_clock_new_single_shot_id (clock, time); } - } else + } else { + if (sink->priv->cached_clock_id != NULL) + gst_clock_id_unref (sink->priv->cached_clock_id); sink->priv->cached_clock_id = gst_clock_new_single_shot_id (clock, time); + } GST_OBJECT_UNLOCK (sink); /* A blocking wait is performed on the clock. We save the ClockID -- 2.7.4