netclientclock: Add deinitialize function for testing
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9115>
This commit is contained in:
parent
15ae6d13f8
commit
88314f7706
@ -1539,3 +1539,36 @@ gst_ntp_clock_new (const gchar * name, const gchar * remote_address,
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_clock_cache (gpointer data)
|
||||
{
|
||||
ClockCache *cache = data;
|
||||
|
||||
g_assert (cache->clocks == NULL);
|
||||
|
||||
if (cache->remove_id) {
|
||||
gst_clock_id_unschedule (cache->remove_id);
|
||||
gst_clock_id_unref (cache->remove_id);
|
||||
}
|
||||
|
||||
gst_object_unref (cache->clock);
|
||||
g_free (cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_net_client_clock_deinit:
|
||||
*
|
||||
* Clears any cached #GstNetClientClock clocks.
|
||||
* All references should be released beforehand.
|
||||
* Mainly used for testing.
|
||||
*
|
||||
* Since: 1.28
|
||||
*/
|
||||
void
|
||||
gst_net_client_clock_deinit (void)
|
||||
{
|
||||
G_LOCK (clocks_lock);
|
||||
g_list_free_full (g_steal_pointer (&clocks), _free_clock_cache);
|
||||
G_UNLOCK (clocks_lock);
|
||||
}
|
||||
|
@ -72,6 +72,9 @@ struct _GstNetClientClockClass {
|
||||
GST_NET_API
|
||||
GType gst_net_client_clock_get_type (void);
|
||||
|
||||
GST_NET_API
|
||||
void gst_net_client_clock_deinit (void);
|
||||
|
||||
GST_NET_API
|
||||
GstClock* gst_net_client_clock_new (const gchar *name, const gchar *remote_address,
|
||||
gint remote_port, GstClockTime base_time);
|
||||
|
@ -48,12 +48,7 @@ GST_START_TEST (test_instantiation)
|
||||
|
||||
gst_object_unref (local);
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
if (RUNNING_ON_VALGRIND) {
|
||||
// Delay 60+ to allow cache to free clocks
|
||||
g_usleep (65 * G_USEC_PER_SEC);
|
||||
}
|
||||
#endif
|
||||
gst_net_client_clock_deinit ();
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
@ -126,12 +121,7 @@ GST_START_TEST (test_functioning)
|
||||
gst_object_unref (client);
|
||||
gst_object_unref (server);
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
if (RUNNING_ON_VALGRIND) {
|
||||
// Delay 60+ to allow cache to free clocks
|
||||
g_usleep (65 * G_USEC_PER_SEC);
|
||||
}
|
||||
#endif
|
||||
gst_net_client_clock_deinit ();
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
Loading…
x
Reference in New Issue
Block a user