static gboolean gst_initialized = FALSE;
static gboolean gst_deinitialized = FALSE;
+static GMutex init_lock;
GstClockTime _priv_gst_start_time;
gboolean
gst_init_check (int *argc, char **argv[], GError ** error)
{
- static GMutex init_lock;
#ifndef GST_DISABLE_OPTION_PARSING
GOptionGroup *group;
GOptionContext *ctx;
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) {
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
{
gst_init (NULL, NULL);
- gst_deinit ();
+ /* gst_deinit will be called by test exit handler */
}
GST_END_TEST;
clock = gst_system_clock_obtain ();
gst_object_unref (clock);
- gst_deinit ();
+ /* gst_deinit will be called by test exit handler */
}
GST_END_TEST;
{
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;
}