From 7124e56bb58e574876ae57e445081756dd6e82e8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 9 Mar 2016 13:44:24 +0200 Subject: [PATCH] netclientclock: Don't reset calibration of internal clock whenever a new netclient clock is created https://bugzilla.gnome.org/show_bug.cgi?id=763325 --- libs/gst/net/gstnetclientclock.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/libs/gst/net/gstnetclientclock.c b/libs/gst/net/gstnetclientclock.c index eaae6e4..716bc09 100644 --- a/libs/gst/net/gstnetclientclock.c +++ b/libs/gst/net/gstnetclientclock.c @@ -957,7 +957,7 @@ struct _GstNetClientClockPrivate GstClockTime roundtrip_limit; GstClockTime minimum_update_interval; - GstClockTime base_time; + GstClockTime base_time, internal_base_time; gchar *address; gint port; @@ -1055,6 +1055,7 @@ static void gst_net_client_clock_init (GstNetClientClock * self) { GstNetClientClockPrivate *priv; + GstClock *clock; self->priv = priv = GST_NET_CLIENT_CLOCK_GET_PRIVATE (self); @@ -1066,7 +1067,11 @@ gst_net_client_clock_init (GstNetClientClock * self) priv->roundtrip_limit = DEFAULT_ROUNDTRIP_LIMIT; priv->minimum_update_interval = DEFAULT_MINIMUM_UPDATE_INTERVAL; + + clock = gst_system_clock_obtain (); priv->base_time = DEFAULT_BASE_TIME; + priv->internal_base_time = gst_clock_get_time (clock); + gst_object_unref (clock); } /* Must be called with clocks_lock */ @@ -1210,9 +1215,15 @@ gst_net_client_clock_set_property (GObject * object, guint prop_id, GST_OBJECT_UNLOCK (self); update = TRUE; break; - case PROP_BASE_TIME: + case PROP_BASE_TIME:{ + GstClock *clock; + self->priv->base_time = g_value_get_uint64 (value); + clock = gst_system_clock_obtain (); + self->priv->internal_base_time = gst_clock_get_time (clock); + gst_object_unref (clock); break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1335,18 +1346,6 @@ gst_net_client_clock_constructed (GObject * object) self->priv->internal_clock = internal_clock = cache->clock; - /* gst_clock_get_time() values are guaranteed to be increasing. because no one - * has called get_time on this clock yet we are free to adjust to any value - * without worrying about worrying about MAX() issues with the clock's - * internal time. - */ - - /* update our internal time so get_time() give something around base_time. - assume that the rate is 1 in the beginning. */ - internal = gst_clock_get_internal_time (internal_clock); - gst_clock_set_calibration (internal_clock, internal, - self->priv->base_time, 1, 1); - { GstClockTime now = gst_clock_get_time (internal_clock); @@ -1364,6 +1363,12 @@ gst_net_client_clock_get_internal_time (GstClock * clock) { GstNetClientClock *self = GST_NET_CLIENT_CLOCK (clock); + if (!gst_clock_is_synced (self->priv->internal_clock)) { + GstClockTime now = gst_clock_get_internal_time (self->priv->internal_clock); + return gst_clock_adjust_with_calibration (self->priv->internal_clock, now, + self->priv->internal_base_time, self->priv->base_time, 1, 1); + } + return gst_clock_get_time (self->priv->internal_clock); } -- 2.7.4