task: add GDestroyNotify to _new
[platform/upstream/gstreamer.git] / tests / check / gst / gsttask.c
index 12791d2..699219f 100644 (file)
 
 #include <gst/check/gstcheck.h>
 
-static GMutex *task_lock;
-static GCond *task_cond;
+static GMutex task_lock;
+static GCond task_cond;
 
-static GStaticRecMutex task_mutex = G_STATIC_REC_MUTEX_INIT;
+static GRecMutex task_mutex;
 
 static void
 task_func2 (void *data)
@@ -32,10 +32,10 @@ task_func2 (void *data)
   gboolean ret;
   GstTask *t = *((GstTask **) data);
 
-  g_mutex_lock (task_lock);
+  g_mutex_lock (&task_lock);
   GST_DEBUG ("signal");
-  g_cond_signal (task_cond);
-  g_mutex_unlock (task_lock);
+  g_cond_signal (&task_cond);
+  g_mutex_unlock (&task_lock);
 
   ASSERT_WARNING (ret = gst_task_join (t));
   fail_unless (ret == FALSE);
@@ -46,23 +46,24 @@ GST_START_TEST (test_join)
   GstTask *t;
   gboolean ret;
 
-  t = gst_task_new (task_func2, &t);
+  t = gst_task_new (task_func2, &t, NULL);
   fail_if (t == NULL);
 
+  g_rec_mutex_init (&task_mutex);
   gst_task_set_lock (t, &task_mutex);
 
-  task_cond = g_cond_new ();
-  task_lock = g_mutex_new ();
+  g_cond_init (&task_cond);
+  g_mutex_init (&task_lock);
 
-  g_mutex_lock (task_lock);
+  g_mutex_lock (&task_lock);
   GST_DEBUG ("starting");
   ret = gst_task_start (t);
   fail_unless (ret == TRUE);
   /* wait for it to spin up */
   GST_DEBUG ("waiting");
-  g_cond_wait (task_cond, task_lock);
+  g_cond_wait (&task_cond, &task_lock);
   GST_DEBUG ("done waiting");
-  g_mutex_unlock (task_lock);
+  g_mutex_unlock (&task_lock);
 
   GST_DEBUG ("joining");
   ret = gst_task_join (t);
@@ -78,10 +79,10 @@ GST_END_TEST;
 static void
 task_func (void *data)
 {
-  g_mutex_lock (task_lock);
+  g_mutex_lock (&task_lock);
   GST_DEBUG ("signal");
-  g_cond_signal (task_cond);
-  g_mutex_unlock (task_lock);
+  g_cond_signal (&task_cond);
+  g_mutex_unlock (&task_lock);
 }
 
 GST_START_TEST (test_lock_start)
@@ -89,23 +90,24 @@ GST_START_TEST (test_lock_start)
   GstTask *t;
   gboolean ret;
 
-  t = gst_task_new (task_func, NULL);
+  t = gst_task_new (task_func, NULL, NULL);
   fail_if (t == NULL);
 
+  g_rec_mutex_init (&task_mutex);
   gst_task_set_lock (t, &task_mutex);
 
-  task_cond = g_cond_new ();
-  task_lock = g_mutex_new ();
+  g_cond_init (&task_cond);
+  g_mutex_init (&task_lock);
 
-  g_mutex_lock (task_lock);
+  g_mutex_lock (&task_lock);
   GST_DEBUG ("starting");
   ret = gst_task_start (t);
   fail_unless (ret == TRUE);
   /* wait for it to spin up */
   GST_DEBUG ("waiting");
-  g_cond_wait (task_cond, task_lock);
+  g_cond_wait (&task_cond, &task_lock);
   GST_DEBUG ("done waiting");
-  g_mutex_unlock (task_lock);
+  g_mutex_unlock (&task_lock);
 
   /* cannot set mutex now */
   ASSERT_WARNING (gst_task_set_lock (t, &task_mutex));
@@ -126,9 +128,10 @@ GST_START_TEST (test_lock)
   GstTask *t;
   gboolean ret;
 
-  t = gst_task_new (task_func, NULL);
+  t = gst_task_new (task_func, NULL, NULL);
   fail_if (t == NULL);
 
+  g_rec_mutex_init (&task_mutex);
   gst_task_set_lock (t, &task_mutex);
 
   GST_DEBUG ("pause");
@@ -153,7 +156,7 @@ GST_START_TEST (test_no_lock)
   GstTask *t;
   gboolean ret;
 
-  t = gst_task_new (task_func, NULL);
+  t = gst_task_new (task_func, NULL, NULL);
   fail_if (t == NULL);
 
   /* stop should be possible without lock */
@@ -179,7 +182,7 @@ GST_START_TEST (test_create)
 {
   GstTask *t;
 
-  t = gst_task_new (task_func, NULL);
+  t = gst_task_new (task_func, NULL, NULL);
   fail_if (t == NULL);
 
   gst_object_unref (t);