netclientclock: Don't ever store failed internal clocks in the cache
If starting the internal clock fails we would still store a broken clock in the cache despite it being unusable and never recovering. Not storing it allows the application to simply create a new one at a later time and have starting it retried. Also signal to the application that such a clock is not synced. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8334>
This commit is contained in:
parent
154ea45111
commit
dd58ae8cc8
@ -331,6 +331,7 @@ gst_net_client_internal_clock_constructed (GObject * object)
|
||||
|
||||
if (!gst_net_client_internal_clock_start (self)) {
|
||||
g_warning ("failed to start clock '%s'", GST_OBJECT_NAME (self));
|
||||
self->marked_corrupted = TRUE;
|
||||
}
|
||||
|
||||
/* all systems go, cap'n */
|
||||
@ -1181,6 +1182,8 @@ static void
|
||||
gst_net_client_clock_finalize (GObject * object)
|
||||
{
|
||||
GstNetClientClock *self = GST_NET_CLIENT_CLOCK (object);
|
||||
|
||||
if (self->priv->internal_clock) {
|
||||
GList *l;
|
||||
|
||||
if (self->priv->synced_id)
|
||||
@ -1216,6 +1219,7 @@ gst_net_client_clock_finalize (GObject * object)
|
||||
}
|
||||
}
|
||||
G_UNLOCK (clocks_lock);
|
||||
}
|
||||
|
||||
g_free (self->priv->address);
|
||||
self->priv->address = NULL;
|
||||
@ -1362,7 +1366,6 @@ static void
|
||||
gst_net_client_clock_constructed (GObject * object)
|
||||
{
|
||||
GstNetClientClock *self = GST_NET_CLIENT_CLOCK (object);
|
||||
GstClock *internal_clock;
|
||||
GList *l;
|
||||
ClockCache *cache = NULL;
|
||||
|
||||
@ -1390,13 +1393,21 @@ gst_net_client_clock_constructed (GObject * object)
|
||||
}
|
||||
|
||||
if (!cache) {
|
||||
cache = g_new0 (ClockCache, 1);
|
||||
GstNetClientInternalClock *internal_clock;
|
||||
|
||||
cache->clock =
|
||||
internal_clock =
|
||||
g_object_new (GST_TYPE_NET_CLIENT_INTERNAL_CLOCK, "address",
|
||||
self->priv->address, "port", self->priv->port, "is-ntp",
|
||||
self->priv->is_ntp, NULL);
|
||||
gst_object_ref_sink (cache->clock);
|
||||
gst_object_ref_sink (internal_clock);
|
||||
|
||||
if (internal_clock->marked_corrupted) {
|
||||
GST_WARNING_OBJECT (self, "Internal clock couldn't start");
|
||||
gst_object_unref (internal_clock);
|
||||
} else {
|
||||
cache = g_new0 (ClockCache, 1);
|
||||
|
||||
cache->clock = GST_CLOCK (internal_clock);
|
||||
clocks = g_list_prepend (clocks, cache);
|
||||
|
||||
/* Not actually leaked but is cached for a while before being disposed,
|
||||
@ -1404,7 +1415,9 @@ gst_net_client_clock_constructed (GObject * object)
|
||||
* tests. */
|
||||
GST_OBJECT_FLAG_SET (cache->clock, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
||||
}
|
||||
}
|
||||
|
||||
if (cache) {
|
||||
cache->clocks = g_list_prepend (cache->clocks, self);
|
||||
|
||||
GST_OBJECT_LOCK (cache->clock);
|
||||
@ -1415,9 +1428,14 @@ gst_net_client_clock_constructed (GObject * object)
|
||||
G_CALLBACK (gst_net_client_clock_synced_cb), self);
|
||||
GST_OBJECT_UNLOCK (cache->clock);
|
||||
|
||||
self->priv->internal_clock = cache->clock;
|
||||
}
|
||||
|
||||
G_UNLOCK (clocks_lock);
|
||||
|
||||
self->priv->internal_clock = internal_clock = cache->clock;
|
||||
/* Mark clock as unsynced if creation of the internal clock failed */
|
||||
if (!cache)
|
||||
gst_clock_set_synced (GST_CLOCK (self), FALSE);
|
||||
|
||||
/* all systems go, cap'n */
|
||||
}
|
||||
@ -1427,6 +1445,9 @@ gst_net_client_clock_get_internal_time (GstClock * clock)
|
||||
{
|
||||
GstNetClientClock *self = GST_NET_CLIENT_CLOCK (clock);
|
||||
|
||||
if (!self->priv->internal_clock)
|
||||
return self->priv->base_time;
|
||||
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user