summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/gst/check/gstbufferstraw.c39
-rw-r--r--libs/gst/check/gstcheck.c19
-rw-r--r--libs/gst/check/gstcheck.h36
-rw-r--r--tests/check/elements/queue.c6
-rw-r--r--tests/check/elements/tee.c24
5 files changed, 53 insertions, 71 deletions
diff --git a/libs/gst/check/gstbufferstraw.c b/libs/gst/check/gstbufferstraw.c
index 68405df91..8e55940c1 100644
--- a/libs/gst/check/gstbufferstraw.c
+++ b/libs/gst/check/gstbufferstraw.c
@@ -30,8 +30,8 @@
#include "gstbufferstraw.h"
-static GCond *cond = NULL;
-static GMutex *lock = NULL;
+static GCond cond;
+static GMutex lock;
static GstBuffer *buf = NULL;
static gulong id;
@@ -42,17 +42,17 @@ buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer unused)
{
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
- g_mutex_lock (lock);
+ g_mutex_lock (&lock);
while (buf != NULL)
- g_cond_wait (cond, lock);
+ g_cond_wait (&cond, &lock);
/* increase the refcount because we store it globally for others to use */
buf = gst_buffer_ref (buffer);
- g_cond_signal (cond);
+ g_cond_signal (&cond);
- g_mutex_unlock (lock);
+ g_mutex_unlock (&lock);
return GST_PAD_PROBE_OK;
}
@@ -86,9 +86,6 @@ gst_buffer_straw_start_pipeline (GstElement * bin, GstPad * pad)
id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER,
buffer_probe, NULL, NULL);
- cond = g_cond_new ();
- lock = g_mutex_new ();
-
ret = gst_element_set_state (bin, GST_STATE_PLAYING);
fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not start test pipeline");
if (ret == GST_STATE_CHANGE_ASYNC) {
@@ -117,17 +114,17 @@ gst_buffer_straw_get_buffer (GstElement * bin, GstPad * pad)
{
GstBuffer *ret;
- g_mutex_lock (lock);
+ g_mutex_lock (&lock);
while (buf == NULL)
- g_cond_wait (cond, lock);
+ g_cond_wait (&cond, &lock);
ret = buf;
buf = NULL;
- g_cond_signal (cond);
+ g_cond_signal (&cond);
- g_mutex_unlock (lock);
+ g_mutex_unlock (&lock);
return ret;
}
@@ -148,14 +145,14 @@ gst_buffer_straw_stop_pipeline (GstElement * bin, GstPad * pad)
{
GstStateChangeReturn ret;
- g_mutex_lock (lock);
+ g_mutex_lock (&lock);
if (buf)
gst_buffer_unref (buf);
buf = NULL;
gst_pad_remove_probe (pad, (guint) id);
id = 0;
- g_cond_signal (cond);
- g_mutex_unlock (lock);
+ g_cond_signal (&cond);
+ g_mutex_unlock (&lock);
ret = gst_element_set_state (bin, GST_STATE_NULL);
fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not stop test pipeline");
@@ -164,15 +161,9 @@ gst_buffer_straw_stop_pipeline (GstElement * bin, GstPad * pad)
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not stop test pipeline");
}
- g_mutex_lock (lock);
+ g_mutex_lock (&lock);
if (buf)
gst_buffer_unref (buf);
buf = NULL;
- g_mutex_unlock (lock);
-
- g_mutex_free (lock);
- g_cond_free (cond);
-
- lock = NULL;
- cond = NULL;
+ g_mutex_unlock (&lock);
}
diff --git a/libs/gst/check/gstcheck.c b/libs/gst/check/gstcheck.c
index 4f967935f..bb923088a 100644
--- a/libs/gst/check/gstcheck.c
+++ b/libs/gst/check/gstcheck.c
@@ -40,13 +40,13 @@ GST_DEBUG_CATEGORY (check_debug);
gboolean _gst_check_threads_running = FALSE;
GList *thread_list = NULL;
-GMutex *mutex;
-GCond *start_cond; /* used to notify main thread of thread startups */
-GCond *sync_cond; /* used to synchronize all threads and main thread */
+GMutex mutex;
+GCond start_cond; /* used to notify main thread of thread startups */
+GCond sync_cond; /* used to synchronize all threads and main thread */
GList *buffers = NULL;
-GMutex *check_mutex = NULL;
-GCond *check_cond = NULL;
+GMutex check_mutex;
+GCond check_cond;
/* FIXME 0.11: shouldn't _gst_check_debug be static? Not used anywhere */
gboolean _gst_check_debug = FALSE;
@@ -136,9 +136,6 @@ gst_check_init (int *argc, char **argv[])
gst_check_log_critical_func, NULL);
print_plugins ();
-
- check_cond = g_cond_new ();
- check_mutex = g_mutex_new ();
}
/* message checking */
@@ -167,9 +164,9 @@ gst_check_chain_func (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GST_DEBUG_OBJECT (pad, "chain_func: received buffer %p", buffer);
buffers = g_list_append (buffers, buffer);
- g_mutex_lock (check_mutex);
- g_cond_signal (check_cond);
- g_mutex_unlock (check_mutex);
+ g_mutex_lock (&check_mutex);
+ g_cond_signal (&check_cond);
+ g_mutex_unlock (&check_mutex);
return GST_FLOW_OK;
}
diff --git a/libs/gst/check/gstcheck.h b/libs/gst/check/gstcheck.h
index a527c1b5c..d2d8367db 100644
--- a/libs/gst/check/gstcheck.h
+++ b/libs/gst/check/gstcheck.h
@@ -51,8 +51,8 @@ extern gboolean _gst_check_expecting_log;
/* global variables used in test methods */
extern GList * buffers;
-extern GMutex *check_mutex;
-extern GCond *check_cond;
+extern GMutex check_mutex;
+extern GCond check_cond;
typedef struct
{
@@ -267,9 +267,9 @@ G_STMT_START { \
* thread test macros and variables
*/
extern GList *thread_list;
-extern GMutex *mutex;
-extern GCond *start_cond; /* used to notify main thread of thread startups */
-extern GCond *sync_cond; /* used to synchronize all threads and main thread */
+extern GMutex mutex;
+extern GCond start_cond; /* used to notify main thread of thread startups */
+extern GCond sync_cond; /* used to synchronize all threads and main thread */
#define MAIN_START_THREADS(count, function, data) \
MAIN_INIT(); \
@@ -354,12 +354,6 @@ gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time)
#define MAIN_INIT() \
G_STMT_START { \
_gst_check_threads_running = TRUE; \
- \
- if (mutex == NULL) { \
- mutex = g_mutex_new (); \
- start_cond = g_cond_new (); \
- sync_cond = g_cond_new (); \
- } \
} G_STMT_END;
#define MAIN_START_THREAD_FUNCTIONS(count, function, data) \
@@ -374,13 +368,13 @@ G_STMT_START { \
G_STMT_START { \
GThread *thread = NULL; \
GST_DEBUG ("MAIN: creating thread %d", i); \
- g_mutex_lock (mutex); \
- thread = g_thread_create ((GThreadFunc) function, data, \
- TRUE, NULL); \
+ g_mutex_lock (&mutex); \
+ thread = g_thread_try_new ("gst-check", \
+ (GThreadFunc) function, data, NULL); \
/* wait for thread to signal us that it's ready */ \
GST_DEBUG ("MAIN: waiting for thread %d", i); \
- g_cond_wait (start_cond, mutex); \
- g_mutex_unlock (mutex); \
+ g_cond_wait (&start_cond, &mutex); \
+ g_mutex_unlock (&mutex); \
\
thread_list = g_list_append (thread_list, thread); \
} G_STMT_END;
@@ -389,7 +383,7 @@ G_STMT_START { \
#define MAIN_SYNCHRONIZE() \
G_STMT_START { \
GST_DEBUG ("MAIN: synchronizing"); \
- g_cond_broadcast (sync_cond); \
+ g_cond_broadcast (&sync_cond); \
GST_DEBUG ("MAIN: synchronized"); \
} G_STMT_END;
@@ -413,17 +407,17 @@ THREAD_SYNCHRONIZE();
G_STMT_START { \
/* signal main thread that we started */ \
GST_DEBUG ("THREAD %p: started", g_thread_self ()); \
- g_mutex_lock (mutex); \
- g_cond_signal (start_cond); \
+ g_mutex_lock (&mutex); \
+ g_cond_signal (&start_cond); \
} G_STMT_END;
#define THREAD_SYNCHRONIZE() \
G_STMT_START { \
/* synchronize everyone */ \
GST_DEBUG ("THREAD %p: syncing", g_thread_self ()); \
- g_cond_wait (sync_cond, mutex); \
+ g_cond_wait (&sync_cond, &mutex); \
GST_DEBUG ("THREAD %p: synced", g_thread_self ()); \
- g_mutex_unlock (mutex); \
+ g_mutex_unlock (&mutex); \
} G_STMT_END;
#define THREAD_SWITCH() \
diff --git a/tests/check/elements/queue.c b/tests/check/elements/queue.c
index 441017702..6682d186d 100644
--- a/tests/check/elements/queue.c
+++ b/tests/check/elements/queue.c
@@ -270,12 +270,12 @@ GST_START_TEST (test_non_leaky_overrun)
fail_unless (overrun_count == 1);
/* lock the check_mutex to block the first buffer pushed to mysinkpad */
- g_mutex_lock (check_mutex);
+ g_mutex_lock (&check_mutex);
/* now let the queue push all buffers */
while (g_list_length (buffers) < 3) {
- g_cond_wait (check_cond, check_mutex);
+ g_cond_wait (&check_cond, &check_mutex);
}
- g_mutex_unlock (check_mutex);
+ g_mutex_unlock (&check_mutex);
fail_unless (overrun_count == 1);
/* make sure we get the underrun signal before we check underrun_count */
diff --git a/tests/check/elements/tee.c b/tests/check/elements/tee.c
index 777d3e134..46ff4d962 100644
--- a/tests/check/elements/tee.c
+++ b/tests/check/elements/tee.c
@@ -242,20 +242,20 @@ app_thread_func (gpointer data)
BufferAllocHarness *h = data;
/* Signal that we are about to call release_request_pad(). */
- g_mutex_lock (check_mutex);
+ g_mutex_lock (&check_mutex);
h->app_thread_prepped = TRUE;
- g_cond_signal (check_cond);
- g_mutex_unlock (check_mutex);
+ g_cond_signal (&check_cond);
+ g_mutex_unlock (&check_mutex);
/* Simulate that the app releases the pad while the streaming thread is in
* buffer_alloc below. */
gst_element_release_request_pad (h->tee, h->tee_srcpad);
/* Signal the bufferalloc function below if it's still waiting. */
- g_mutex_lock (check_mutex);
+ g_mutex_lock (&check_mutex);
h->bufferalloc_blocked = FALSE;
- g_cond_signal (check_cond);
- g_mutex_unlock (check_mutex);
+ g_cond_signal (&check_cond);
+ g_mutex_unlock (&check_mutex);
return NULL;
}
@@ -282,21 +282,21 @@ final_sinkpad_bufferalloc (GstPad * pad, guint64 offset, guint size,
fail_if (h->app_thread == NULL);
/* Wait for the app thread to get ready to call release_request_pad(). */
- g_mutex_lock (check_mutex);
+ g_mutex_lock (&check_mutex);
while (!h->app_thread_prepped)
- g_cond_wait (check_cond, check_mutex);
- g_mutex_unlock (check_mutex);
+ g_cond_wait (&check_cond, &check_mutex);
+ g_mutex_unlock (&check_mutex);
/* Now wait for it to do that within a second, to avoid deadlocking
* in the event of future changes to the locking semantics. */
- g_mutex_lock (check_mutex);
+ g_mutex_lock (&check_mutex);
g_get_current_time (&deadline);
deadline.tv_sec += 1;
while (h->bufferalloc_blocked) {
- if (!g_cond_timed_wait (check_cond, check_mutex, &deadline))
+ if (!g_cond_timed_wait (&check_cond, &check_mutex, &deadline))
break;
}
- g_mutex_unlock (check_mutex);
+ g_mutex_unlock (&check_mutex);
}
*buf = gst_buffer_new_and_alloc (size);