Commit 754f9030 authored by Aaron Boxer's avatar Aaron Boxer

gst: enforce gst_deinit one call per process

unit tests do not need to call deinit as it is already called in exit handler
parent 35d62660
Pipeline #55649 passed with stages
in 62 minutes and 17 seconds
......@@ -125,6 +125,7 @@
static gboolean gst_initialized = FALSE;
static gboolean gst_deinitialized = FALSE;
static GMutex init_lock;
GstClockTime _priv_gst_start_time;
......@@ -404,7 +405,6 @@ gst_get_main_executable_path (void)
gboolean
gst_init_check (int *argc, char **argv[], GError ** err)
{
static GMutex init_lock;
#ifndef GST_DISABLE_OPTION_PARSING
GOptionGroup *group;
GOptionContext *ctx;
......@@ -1079,15 +1079,18 @@ gst_deinit (void)
GstBinClass *bin_class;
GstClock *clock;
if (!gst_initialized)
return;
GST_INFO ("deinitializing GStreamer");
g_mutex_lock (&init_lock);
if (gst_deinitialized) {
GST_DEBUG ("already deinitialized");
if (!gst_initialized) {
g_mutex_unlock (&init_lock);
return;
}
if (gst_deinitialized) {
/* tell the user how naughty they've been */
g_error ("GStreamer should not be deinitialized a second time.");
}
GST_INFO ("deinitializing GStreamer");
g_thread_pool_set_max_unused_threads (0);
bin_class = (GstBinClass *) g_type_class_peek (gst_bin_get_type ());
if (bin_class && bin_class->pool != NULL) {
......@@ -1231,6 +1234,7 @@ gst_deinit (void)
gst_deinitialized = TRUE;
GST_INFO ("deinitialized GStreamer");
g_mutex_unlock (&init_lock);
/* Doing this as the very last step to allow the above GST_INFO() to work
* correctly. It's of course making the above statement a lie: for a short
......
......@@ -39,7 +39,7 @@ GST_START_TEST (test_deinit)
{
gst_init (NULL, NULL);
gst_deinit ();
/* gst_deinit will be called by test exit handler */
}
GST_END_TEST;
......@@ -53,7 +53,7 @@ GST_START_TEST (test_deinit_sysclock)
clock = gst_system_clock_obtain ();
gst_object_unref (clock);
gst_deinit ();
/* gst_deinit will be called by test exit handler */
}
GST_END_TEST;
......@@ -100,15 +100,19 @@ gst_suite (void)
{
Suite *s = suite_create ("Gst");
TCase *tc_chain = tcase_create ("gst tests");
const char *ck_fork = g_getenv ("CK_FORK");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_init);
tcase_add_test (tc_chain, test_new_pipeline);
tcase_add_test (tc_chain, test_new_fakesrc);
tcase_add_test (tc_chain, test_version);
/* run these last so the others don't fail if CK_FORK=no is being used */
/* run these last so the others don't fail if CK_FORK=no is being used.
* only run single test for deinitialization if CK_FORK=no, so system exit
* will make the single deinit call */
tcase_add_test (tc_chain, test_deinit_sysclock);
tcase_add_test (tc_chain, test_deinit);
if (!ck_fork || (strcmp (ck_fork, "no") != 0))
tcase_add_test (tc_chain, test_deinit);
return s;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment