tests: port to new GLib thread API

This commit is contained in:
Mark Nauwelaerts 2012-09-12 11:52:25 +02:00
parent ec4ff874fc
commit 47e7c91ab5
17 changed files with 199 additions and 231 deletions

View file

@ -57,7 +57,8 @@ chain_async (GstPad * pad, GstBuffer * buffer)
chain_data->buffer = buffer;
chain_data->ret = GST_FLOW_ERROR;
thread = g_thread_create (chain_async_buffer, chain_data, TRUE, &error);
thread =
g_thread_try_new ("gst-check", chain_async_buffer, chain_data, &error);
if (error != NULL) {
g_warning ("could not create thread reason: %s", error->message);
g_free (chain_data);

View file

@ -26,8 +26,8 @@
#include <gst/check/gstcheck.h>
static gboolean have_eos = FALSE;
static GCond *eos_cond;
static GMutex *event_mutex;
static GCond eos_cond;
static GMutex event_mutex;
static GstPad *mysinkpad;
@ -41,13 +41,13 @@ event_func (GstPad * pad, GstObject * parent, GstEvent * event)
{
gboolean res = TRUE;
g_mutex_lock (event_mutex);
g_mutex_lock (&event_mutex);
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
have_eos = TRUE;
GST_DEBUG ("signal EOS");
g_cond_broadcast (eos_cond);
g_cond_broadcast (&eos_cond);
}
g_mutex_unlock (event_mutex);
g_mutex_unlock (&event_mutex);
gst_event_unref (event);
@ -57,13 +57,13 @@ event_func (GstPad * pad, GstObject * parent, GstEvent * event)
static void
wait_eos (void)
{
g_mutex_lock (event_mutex);
g_mutex_lock (&event_mutex);
GST_DEBUG ("waiting for EOS");
while (!have_eos) {
g_cond_wait (eos_cond, event_mutex);
g_cond_wait (&eos_cond, &event_mutex);
}
GST_DEBUG ("received EOS");
g_mutex_unlock (event_mutex);
g_mutex_unlock (&event_mutex);
}
static GstElement *
@ -77,9 +77,6 @@ setup_filesrc (void)
gst_pad_set_event_function (mysinkpad, event_func);
gst_pad_set_active (mysinkpad, TRUE);
eos_cond = g_cond_new ();
event_mutex = g_mutex_new ();
return filesrc;
}
@ -89,9 +86,6 @@ cleanup_filesrc (GstElement * filesrc)
gst_pad_set_active (mysinkpad, FALSE);
gst_check_teardown_sink_pad (filesrc);
gst_check_teardown_element (filesrc);
g_cond_free (eos_cond);
g_mutex_free (event_mutex);
}
GST_START_TEST (test_seeking)

View file

@ -415,14 +415,14 @@ run_output_order_test (gint n_linked)
struct PadData pad_data[5];
guint32 max_linked_id;
guint32 eos_seen;
GMutex *mutex;
GCond *cond;
GMutex mutex;
GCond cond;
gint i;
const gint NPADS = 5;
const gint NBUFFERS = 1000;
mutex = g_mutex_new ();
cond = g_cond_new ();
g_mutex_init (&mutex);
g_cond_init (&cond);
pipe = gst_bin_new ("testbin");
@ -470,8 +470,8 @@ run_output_order_test (gint n_linked)
pad_data[i].eos_count_ptr = &eos_seen;
pad_data[i].is_linked = (i < n_linked ? TRUE : FALSE);
pad_data[i].n_linked = n_linked;
pad_data[i].cond = cond;
pad_data[i].mutex = mutex;
pad_data[i].cond = &cond;
pad_data[i].mutex = &mutex;
pad_data[i].first_buf = TRUE;
gst_pad_set_element_private (sinkpads[i], pad_data + i);
@ -527,12 +527,12 @@ run_output_order_test (gint n_linked)
}
/* Wait while the buffers are processed */
g_mutex_lock (mutex);
g_mutex_lock (&mutex);
/* We wait until EOS has been pushed on all linked pads */
while (eos_seen < n_linked) {
g_cond_wait (cond, mutex);
g_cond_wait (&cond, &mutex);
}
g_mutex_unlock (mutex);
g_mutex_unlock (&mutex);
/* Clean up */
for (i = 0; i < NPADS; i++) {
@ -549,8 +549,8 @@ run_output_order_test (gint n_linked)
gst_element_set_state (pipe, GST_STATE_NULL);
gst_object_unref (pipe);
g_cond_free (cond);
g_mutex_free (mutex);
g_cond_clear (&cond);
g_mutex_clear (&mutex);
}
GST_START_TEST (test_output_order)
@ -574,14 +574,14 @@ GST_START_TEST (test_sparse_stream)
GstEvent *event;
struct PadData pad_data[2];
guint32 eos_seen, max_linked_id;
GMutex *mutex;
GCond *cond;
GMutex mutex;
GCond cond;
gint i;
const gint NBUFFERS = 100;
GstSegment segment;
mutex = g_mutex_new ();
cond = g_cond_new ();
g_mutex_init (&mutex);
g_cond_init (&cond);
pipe = gst_pipeline_new ("testbin");
mq = gst_element_factory_make ("multiqueue", NULL);
@ -626,8 +626,8 @@ GST_START_TEST (test_sparse_stream)
pad_data[i].eos_count_ptr = &eos_seen;
pad_data[i].is_linked = (i == 0) ? TRUE : FALSE;
pad_data[i].n_linked = 1;
pad_data[i].cond = cond;
pad_data[i].mutex = mutex;
pad_data[i].cond = &cond;
pad_data[i].mutex = &mutex;
pad_data[i].first_buf = TRUE;
gst_pad_set_element_private (sinkpads[i], pad_data + i);
@ -692,12 +692,12 @@ GST_START_TEST (test_sparse_stream)
gst_pad_push_event (inputpads[1], event);
/* Wait while the buffers are processed */
g_mutex_lock (mutex);
g_mutex_lock (&mutex);
/* We wait until EOS has been pushed on all pads */
while (eos_seen < 2) {
g_cond_wait (cond, mutex);
g_cond_wait (&cond, &mutex);
}
g_mutex_unlock (mutex);
g_mutex_unlock (&mutex);
/* Clean up */
for (i = 0; i < 2; i++) {
@ -714,8 +714,8 @@ GST_START_TEST (test_sparse_stream)
gst_element_set_state (pipe, GST_STATE_NULL);
gst_object_unref (pipe);
g_cond_free (cond);
g_mutex_free (mutex);
g_cond_clear (&cond);
g_mutex_clear (&mutex);
}
GST_END_TEST;

View file

@ -24,10 +24,10 @@
#include <gst/check/gstcheck.h>
#define UNDERRUN_LOCK() (g_mutex_lock (underrun_mutex))
#define UNDERRUN_UNLOCK() (g_mutex_unlock (underrun_mutex))
#define UNDERRUN_SIGNAL() (g_cond_signal (underrun_cond))
#define UNDERRUN_WAIT() (g_cond_wait (underrun_cond, underrun_mutex))
#define UNDERRUN_LOCK() (g_mutex_lock (&underrun_mutex))
#define UNDERRUN_UNLOCK() (g_mutex_unlock (&underrun_mutex))
#define UNDERRUN_SIGNAL() (g_cond_signal (&underrun_cond))
#define UNDERRUN_WAIT() (g_cond_wait (&underrun_cond, &underrun_mutex))
static GstElement *queue;
@ -41,8 +41,8 @@ static gulong probe_id;
static gint overrun_count;
static GMutex *underrun_mutex;
static GCond *underrun_cond;
static GMutex underrun_mutex;
static GCond underrun_cond;
static gint underrun_count;
static GList *events;
@ -121,8 +121,6 @@ setup (void)
overrun_count = 0;
underrun_mutex = g_mutex_new ();
underrun_cond = g_cond_new ();
underrun_count = 0;
events = NULL;
@ -137,11 +135,6 @@ cleanup (void)
drop_events ();
g_cond_free (underrun_cond);
underrun_cond = NULL;
g_mutex_free (underrun_mutex);
underrun_mutex = NULL;
if (mysinkpad != NULL) {
gst_pad_set_active (mysinkpad, FALSE);
gst_check_teardown_sink_pad (queue);

View file

@ -242,7 +242,9 @@ GST_START_TEST (test_filled_read)
buffer = gst_buffer_new_and_alloc (4 * 1024);
fail_unless (gst_pad_chain (sinkpad, buffer) == GST_FLOW_OK);
thread = g_thread_create ((GThreadFunc) push_buffer, sinkpad, TRUE, NULL);
thread =
g_thread_try_new ("gst-check", (GThreadFunc) push_buffer, sinkpad, NULL);
fail_unless (thread != NULL);
buffer = NULL;
fail_unless (gst_pad_get_range (srcpad, 1024, 4 * 1024,

View file

@ -278,7 +278,7 @@ final_sinkpad_bufferalloc (GstPad * pad, guint64 offset, guint size,
h->app_thread_prepped = FALSE;
h->bufferalloc_blocked = TRUE;
h->app_thread = g_thread_create (app_thread_func, h, TRUE, NULL);
h->app_thread = g_thread_try_new ("gst-check", app_thread_func, h, NULL);
fail_if (h->app_thread == NULL);
/* Wait for the app thread to get ready to call release_request_pad(). */

View file

@ -760,16 +760,16 @@ GST_START_TEST (test_add_live)
GST_END_TEST;
static GMutex *blocked_lock;
static GCond *blocked_cond;
static GMutex blocked_lock;
static GCond blocked_cond;
static GstPadProbeReturn
pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
g_mutex_lock (blocked_lock);
g_mutex_lock (&blocked_lock);
GST_DEBUG ("srcpad blocked: %d, sending signal", info->type);
g_cond_signal (blocked_cond);
g_mutex_unlock (blocked_lock);
g_cond_signal (&blocked_cond);
g_mutex_unlock (&blocked_lock);
return GST_PAD_PROBE_OK;
}
@ -782,9 +782,6 @@ GST_START_TEST (test_add_live2)
GstPad *srcpad, *sinkpad;
gulong id;
blocked_lock = g_mutex_new ();
blocked_cond = g_cond_new ();
pipeline = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "src");
g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);
@ -797,7 +794,7 @@ GST_START_TEST (test_add_live2)
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");
g_mutex_lock (blocked_lock);
g_mutex_lock (&blocked_lock);
GST_DEBUG ("blocking srcpad");
/* block source pad */
@ -817,8 +814,8 @@ GST_START_TEST (test_add_live2)
gst_bin_add (GST_BIN (pipeline), src);
/* wait for pad blocked, this means the source is now PLAYING. */
g_cond_wait (blocked_cond, blocked_lock);
g_mutex_unlock (blocked_lock);
g_cond_wait (&blocked_cond, &blocked_lock);
g_mutex_unlock (&blocked_lock);
GST_DEBUG ("linking pads");
@ -845,8 +842,6 @@ GST_START_TEST (test_add_live2)
ret = gst_element_set_state (pipeline, GST_STATE_NULL);
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");
g_cond_free (blocked_cond);
g_mutex_free (blocked_lock);
gst_object_unref (pipeline);
}
@ -952,7 +947,8 @@ GST_START_TEST (test_fake_eos)
/* push EOS, this will block for up to 100 seconds, until the previous
* buffer has finished. We therefore push it in another thread so we can do
* something else while it blocks. */
thread = g_thread_create ((GThreadFunc) send_eos, sinkpad, TRUE, NULL);
thread =
g_thread_try_new ("gst-check", (GThreadFunc) send_eos, sinkpad, NULL);
fail_if (thread == NULL, "no thread");
/* wait a while so that the thread manages to start and push the EOS */
@ -1096,7 +1092,8 @@ GST_START_TEST (test_async_done)
/* last buffer, blocks because preroll queue is filled. Start the push in a
* new thread so that we can check the position */
GST_DEBUG ("starting thread");
thread = g_thread_create ((GThreadFunc) send_buffer, sinkpad, TRUE, NULL);
thread =
g_thread_try_new ("gst-check", (GThreadFunc) send_buffer, sinkpad, NULL);
fail_if (thread == NULL, "no thread");
GST_DEBUG ("waiting 1 second");
@ -1207,7 +1204,8 @@ GST_START_TEST (test_async_done_eos)
* position should now be 10 seconds. */
GST_DEBUG ("pushing EOS");
GST_DEBUG ("starting thread");
thread = g_thread_create ((GThreadFunc) send_eos, sinkpad, TRUE, NULL);
thread =
g_thread_try_new ("gst-check", (GThreadFunc) send_eos, sinkpad, NULL);
fail_if (thread == NULL, "no thread");
/* wait for preroll */
@ -1228,17 +1226,17 @@ GST_START_TEST (test_async_done_eos)
GST_END_TEST;
static GMutex *preroll_lock;
static GCond *preroll_cond;
static GMutex preroll_lock;
static GCond preroll_cond;
static void
test_async_false_seek_preroll (GstElement * elem, GstBuffer * buf,
GstPad * pad, gpointer data)
{
g_mutex_lock (preroll_lock);
g_mutex_lock (&preroll_lock);
GST_DEBUG ("Got preroll buffer %p", buf);
g_cond_signal (preroll_cond);
g_mutex_unlock (preroll_lock);
g_cond_signal (&preroll_cond);
g_mutex_unlock (&preroll_lock);
}
static void
@ -1254,9 +1252,6 @@ GST_START_TEST (test_async_false_seek)
{
GstElement *pipeline, *source, *sink;
preroll_lock = g_mutex_new ();
preroll_cond = g_cond_new ();
/* Create gstreamer elements */
pipeline = gst_pipeline_new ("test-pipeline");
source = gst_element_factory_make ("fakesrc", "file-source");
@ -1278,56 +1273,50 @@ GST_START_TEST (test_async_false_seek)
gst_element_link (source, sink);
GST_DEBUG ("Now pausing");
g_mutex_lock (preroll_lock);
g_mutex_lock (&preroll_lock);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
/* wait for preroll */
GST_DEBUG ("wait for preroll");
g_cond_wait (preroll_cond, preroll_lock);
g_mutex_unlock (preroll_lock);
g_cond_wait (&preroll_cond, &preroll_lock);
g_mutex_unlock (&preroll_lock);
g_mutex_lock (preroll_lock);
g_mutex_lock (&preroll_lock);
GST_DEBUG ("Seeking");
fail_unless (gst_element_seek (pipeline, 1.0, GST_FORMAT_BYTES,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, -1));
GST_DEBUG ("wait for new preroll");
/* this either prerolls or fails */
g_cond_wait (preroll_cond, preroll_lock);
g_mutex_unlock (preroll_lock);
g_cond_wait (&preroll_cond, &preroll_lock);
g_mutex_unlock (&preroll_lock);
GST_DEBUG ("bring pipe to state NULL");
gst_element_set_state (pipeline, GST_STATE_NULL);
GST_DEBUG ("Deleting pipeline");
gst_object_unref (GST_OBJECT (pipeline));
g_mutex_free (preroll_lock);
g_cond_free (preroll_cond);
}
GST_END_TEST;
static GMutex *handoff_lock;
static GCond *handoff_cond;
static GMutex handoff_lock;
static GCond handoff_cond;
static void
test_async_false_seek_in_playing_handoff (GstElement * elem, GstBuffer * buf,
GstPad * pad, gpointer data)
{
g_mutex_lock (handoff_lock);
g_mutex_lock (&handoff_lock);
GST_DEBUG ("Got handoff buffer %p", buf);
g_cond_signal (handoff_cond);
g_mutex_unlock (handoff_lock);
g_cond_signal (&handoff_cond);
g_mutex_unlock (&handoff_lock);
}
GST_START_TEST (test_async_false_seek_in_playing)
{
GstElement *pipeline, *source, *sink;
handoff_lock = g_mutex_new ();
handoff_cond = g_cond_new ();
/* Create gstreamer elements */
pipeline = gst_pipeline_new ("test-pipeline");
source = gst_element_factory_make ("fakesrc", "fake-source");
@ -1348,28 +1337,25 @@ GST_START_TEST (test_async_false_seek_in_playing)
GST_DEBUG ("Now playing");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_mutex_lock (handoff_lock);
g_mutex_lock (&handoff_lock);
GST_DEBUG ("wait for handoff buffer");
g_cond_wait (handoff_cond, handoff_lock);
g_mutex_unlock (handoff_lock);
g_cond_wait (&handoff_cond, &handoff_lock);
g_mutex_unlock (&handoff_lock);
GST_DEBUG ("Seeking");
fail_unless (gst_element_seek (source, 1.0, GST_FORMAT_BYTES,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, -1));
g_mutex_lock (handoff_lock);
g_mutex_lock (&handoff_lock);
GST_DEBUG ("wait for handoff buffer");
g_cond_wait (handoff_cond, handoff_lock);
g_mutex_unlock (handoff_lock);
g_cond_wait (&handoff_cond, &handoff_lock);
g_mutex_unlock (&handoff_lock);
GST_DEBUG ("bring pipe to state NULL");
gst_element_set_state (pipeline, GST_STATE_NULL);
GST_DEBUG ("Deleting pipeline");
gst_object_unref (GST_OBJECT (pipeline));
g_mutex_free (handoff_lock);
g_cond_free (handoff_cond);
}
GST_END_TEST;

View file

@ -87,8 +87,8 @@ GST_START_TEST (test_hammer_bus)
test_bus = gst_bus_new ();
for (i = 0; i < NUM_THREADS; i++)
threads[i] = g_thread_create (pound_bus_with_messages, GINT_TO_POINTER (i),
TRUE, NULL);
threads[i] = g_thread_try_new ("gst-check", pound_bus_with_messages,
GINT_TO_POINTER (i), NULL);
for (i = 0; i < NUM_THREADS; i++)
g_thread_join (threads[i]);
@ -509,7 +509,7 @@ GST_START_TEST (test_timed_pop_thread)
test_bus = gst_bus_new ();
thread = g_thread_create (pop_thread, test_bus, TRUE, &error);
thread = g_thread_try_new ("gst-chek", pop_thread, test_bus, &error);
fail_if (error != NULL);
send_10_app_messages ();

View file

@ -334,8 +334,8 @@ event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
typedef struct
{
GMutex *lock;
GCond *cond;
GMutex lock;
GCond cond;
gboolean signaled;
} SignalData;
@ -343,8 +343,8 @@ static void
signal_data_init (SignalData * data)
{
GST_DEBUG ("init %p", data);
data->lock = g_mutex_new ();
data->cond = g_cond_new ();
g_mutex_init (&data->lock);
g_cond_init (&data->cond);
data->signaled = FALSE;
}
@ -352,29 +352,29 @@ static void
signal_data_cleanup (SignalData * data)
{
GST_DEBUG ("free %p", data);
g_mutex_free (data->lock);
g_cond_free (data->cond);
g_mutex_clear (&data->lock);
g_cond_clear (&data->cond);
}
static void
signal_data_signal (SignalData * data)
{
g_mutex_lock (data->lock);
g_mutex_lock (&data->lock);
data->signaled = TRUE;
g_cond_broadcast (data->cond);
g_cond_broadcast (&data->cond);
GST_DEBUG ("signaling %p", data);
g_mutex_unlock (data->lock);
g_mutex_unlock (&data->lock);
}
static void
signal_data_wait (SignalData * data)
{
g_mutex_lock (data->lock);
g_mutex_lock (&data->lock);
GST_DEBUG ("signal wait %p", data);
while (!data->signaled)
g_cond_wait (data->cond, data->lock);
g_cond_wait (&data->cond, &data->lock);
GST_DEBUG ("signal wait done %p", data);
g_mutex_unlock (data->lock);
g_mutex_unlock (&data->lock);
}
static GstPadProbeReturn

View file

@ -474,8 +474,8 @@ GST_END_TEST;
typedef struct
{
GMutex *mutex;
GCond *cond;
GMutex mutex;
GCond cond;
} BlockData;
static GstPadProbeReturn
@ -483,10 +483,10 @@ block_callback (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
BlockData *block_data = (BlockData *) user_data;
g_mutex_lock (block_data->mutex);
g_mutex_lock (&block_data->mutex);
GST_DEBUG ("blocked\n");
g_cond_signal (block_data->cond);
g_mutex_unlock (block_data->mutex);
g_cond_signal (&block_data->cond);
g_mutex_unlock (&block_data->mutex);
return GST_PAD_PROBE_OK;
}
@ -512,20 +512,20 @@ GST_START_TEST (test_ghost_pads_block)
gst_element_add_pad (GST_ELEMENT (srcbin), srcghost);
gst_object_unref (srcpad);
block_data.mutex = g_mutex_new ();
block_data.cond = g_cond_new ();
g_mutex_init (&block_data.mutex);
g_cond_init (&block_data.cond);
g_mutex_lock (block_data.mutex);
g_mutex_lock (&block_data.mutex);
gst_pad_add_probe (srcghost, GST_PAD_PROBE_TYPE_BLOCK, block_callback,
&block_data, NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
/* and wait now */
g_cond_wait (block_data.cond, block_data.mutex);
g_mutex_unlock (block_data.mutex);
g_cond_wait (&block_data.cond, &block_data.mutex);
g_mutex_unlock (&block_data.mutex);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
g_mutex_free (block_data.mutex);
g_cond_free (block_data.cond);
g_mutex_clear (&block_data.mutex);
g_cond_clear (&block_data.cond);
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
gst_object_unref (pipeline);
@ -554,20 +554,20 @@ GST_START_TEST (test_ghost_pads_probes)
gst_element_add_pad (GST_ELEMENT (srcbin), srcghost);
gst_object_unref (srcpad);
block_data.mutex = g_mutex_new ();
block_data.cond = g_cond_new ();
g_mutex_init (&block_data.mutex);
g_cond_init (&block_data.cond);
g_mutex_lock (block_data.mutex);
g_mutex_lock (&block_data.mutex);
gst_pad_add_probe (srcghost, GST_PAD_PROBE_TYPE_BLOCK, block_callback,
&block_data, NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
/* and wait now */
g_cond_wait (block_data.cond, block_data.mutex);
g_mutex_unlock (block_data.mutex);
g_cond_wait (&block_data.cond, &block_data.mutex);
g_mutex_unlock (&block_data.mutex);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
g_mutex_free (block_data.mutex);
g_cond_free (block_data.cond);
g_mutex_clear (&block_data.mutex);
g_cond_clear (&block_data.cond);
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
gst_object_unref (pipeline);

View file

@ -41,16 +41,16 @@ GST_START_TEST (test_manual_iteration)
{
GList *l;
guint32 cookie = 0;
GMutex *m;
GMutex m;
GstIterator *iter;
GstIteratorResult res;
GValue item = { 0, };
gint i = 0;
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
g_mutex_init (&m);
iter = gst_iterator_new_list (G_TYPE_POINTER, m, &cookie, &l, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_POINTER, &m, &cookie, &l, NULL, NULL);
fail_unless (iter != NULL);
@ -70,7 +70,7 @@ GST_START_TEST (test_manual_iteration)
/* clean up */
g_value_unset (&item);
gst_iterator_free (iter);
g_mutex_free (m);
g_mutex_clear (&m);
g_list_free (l);
}
@ -80,7 +80,7 @@ GST_START_TEST (test_resync)
{
GList *l;
guint32 cookie = 0;
GMutex *m;
GMutex m;
GstIterator *iter;
GstIteratorResult res;
GValue item = { 0, };
@ -88,9 +88,9 @@ GST_START_TEST (test_resync)
gboolean hacked_list = FALSE;
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
g_mutex_init (&m);
iter = gst_iterator_new_list (G_TYPE_POINTER, m, &cookie, &l, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_POINTER, &m, &cookie, &l, NULL, NULL);
fail_unless (iter != NULL);
@ -124,7 +124,7 @@ GST_START_TEST (test_resync)
/* clean up */
g_value_unset (&item);
gst_iterator_free (iter);
g_mutex_free (m);
g_mutex_clear (&m);
g_list_free (l);
}
@ -142,15 +142,15 @@ GST_START_TEST (test_fold)
{
GList *l;
guint32 cookie = 0;
GMutex *m;
GMutex m;
GstIterator *iter;
GstIteratorResult res;
gint i, expected;
GValue ret = { 0, };
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (G_TYPE_POINTER, m, &cookie, &l, NULL, NULL);
g_mutex_init (&m);
iter = gst_iterator_new_list (G_TYPE_POINTER, &m, &cookie, &l, NULL, NULL);
fail_unless (iter != NULL);
expected = 0;
@ -167,7 +167,7 @@ GST_START_TEST (test_fold)
/* clean up */
gst_iterator_free (iter);
g_mutex_free (m);
g_mutex_clear (&m);
g_list_free (l);
}

View file

@ -1038,7 +1038,8 @@ test_pad_blocking_with_type (GstPadProbeType type)
id = gst_pad_add_probe (pad, type, block_async_cb_return_ok, NULL, NULL);
thread = g_thread_create ((GThreadFunc) push_buffer_async, pad, TRUE, NULL);
thread = g_thread_try_new ("gst-check", (GThreadFunc) push_buffer_async,
pad, NULL);
/* wait for the block */
while (!gst_pad_is_blocking (pad)) {

View file

@ -239,8 +239,8 @@ GST_START_TEST (test_bus)
GST_END_TEST;
static GMutex *probe_lock;
static GCond *probe_cond;
static GMutex probe_lock;
static GCond probe_cond;
static GstPadProbeReturn
sink_pad_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
@ -262,9 +262,9 @@ sink_pad_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
*first_timestamp = GST_BUFFER_TIMESTAMP (buffer);
}
g_mutex_lock (probe_lock);
g_cond_signal (probe_cond);
g_mutex_unlock (probe_lock);
g_mutex_lock (&probe_lock);
g_cond_signal (&probe_cond);
g_mutex_unlock (&probe_lock);
return GST_PAD_PROBE_OK;
}
@ -301,9 +301,6 @@ GST_START_TEST (test_base_time)
fail_unless (gst_element_get_start_time (pipeline) == 0,
"stream time doesn't start off at 0");
probe_lock = g_mutex_new ();
probe_cond = g_cond_new ();
/* test the first: that base time is being distributed correctly, timestamps
are correct relative to the running clock and base time */
{
@ -316,10 +313,10 @@ GST_START_TEST (test_base_time)
GST_CLOCK_TIME_NONE)
== GST_STATE_CHANGE_SUCCESS, "failed state change");
g_mutex_lock (probe_lock);
g_mutex_lock (&probe_lock);
while (observed == GST_CLOCK_TIME_NONE)
g_cond_wait (probe_cond, probe_lock);
g_mutex_unlock (probe_lock);
g_cond_wait (&probe_cond, &probe_lock);
g_mutex_unlock (&probe_lock);
/* now something a little more than lower was distributed as the base time,
* and the buffer was timestamped between 0 and upper-base
@ -389,10 +386,10 @@ GST_START_TEST (test_base_time)
GST_CLOCK_TIME_NONE)
== GST_STATE_CHANGE_SUCCESS, "failed state change");
g_mutex_lock (probe_lock);
g_mutex_lock (&probe_lock);
while (observed == GST_CLOCK_TIME_NONE)
g_cond_wait (probe_cond, probe_lock);
g_mutex_unlock (probe_lock);
g_cond_wait (&probe_cond, &probe_lock);
g_mutex_unlock (&probe_lock);
/* now the base time should have advanced by more than WAIT_TIME compared
* to what it was. The buffer will be timestamped between the last stream
@ -461,10 +458,10 @@ GST_START_TEST (test_base_time)
GST_CLOCK_TIME_NONE)
== GST_STATE_CHANGE_SUCCESS, "failed state change");
g_mutex_lock (probe_lock);
g_mutex_lock (&probe_lock);
while (observed == GST_CLOCK_TIME_NONE)
g_cond_wait (probe_cond, probe_lock);
g_mutex_unlock (probe_lock);
g_cond_wait (&probe_cond, &probe_lock);
g_mutex_unlock (&probe_lock);
/* now the base time should be the same as it was, and the timestamp should
* be more than WAIT_TIME past what it was.
@ -535,7 +532,7 @@ GST_START_TEST (test_concurrent_create)
int i;
for (i = 0; i < G_N_ELEMENTS (threads); ++i) {
threads[i] = g_thread_create (pipeline_thread, NULL, TRUE, NULL);
threads[i] = g_thread_try_new ("gst-check", pipeline_thread, NULL, NULL);
}
for (i = 0; i < G_N_ELEMENTS (threads); ++i) {
if (threads[i])

View file

@ -21,8 +21,8 @@
#include <gst/check/gstcheck.h>
static GMutex *af_lock;
static GCond *af_cond;
static GMutex af_lock;
static GCond af_cond;
/* see if the defines make sense */
GST_START_TEST (test_range)
@ -90,7 +90,7 @@ error_callback (GstClock * clock, GstClockTime time,
return FALSE;
}
GMutex *store_lock;
GMutex store_lock;
static gboolean
store_callback (GstClock * clock, GstClockTime time,
@ -99,9 +99,9 @@ store_callback (GstClock * clock, GstClockTime time,
GList **list = user_data;
GST_DEBUG ("unlocked async id %p", id);
g_mutex_lock (store_lock);
g_mutex_lock (&store_lock);
*list = g_list_append (*list, id);
g_mutex_unlock (store_lock);
g_mutex_unlock (&store_lock);
return FALSE;
}
@ -268,8 +268,6 @@ GST_START_TEST (test_async_order)
GstClockTime base;
GstClockReturn result;
store_lock = g_mutex_new ();
clock = gst_system_clock_obtain ();
fail_unless (clock != NULL, "Could not create instance of GstSystemClock");
@ -285,32 +283,31 @@ GST_START_TEST (test_async_order)
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
g_usleep (TIME_UNIT / 1000);
/* at this point at least one of the timers should have timed out */
g_mutex_lock (store_lock);
g_mutex_lock (&store_lock);
fail_unless (cb_list != NULL, "expected notification");
fail_unless (cb_list->data == id2,
"Expected notification for id2 to come first");
g_mutex_unlock (store_lock);
g_mutex_unlock (&store_lock);
g_usleep (TIME_UNIT / 1000);
g_mutex_lock (store_lock);
g_mutex_lock (&store_lock);
/* now both should have timed out */
next = g_list_next (cb_list);
fail_unless (next != NULL, "expected second notification");
fail_unless (next->data == id1, "Missing notification for id1");
g_mutex_unlock (store_lock);
g_mutex_unlock (&store_lock);
gst_clock_id_unref (id1);
gst_clock_id_unref (id2);
g_list_free (cb_list);
gst_object_unref (clock);
g_mutex_free (store_lock);
}
GST_END_TEST;
struct test_async_sync_interaction_data
{
GMutex *lock;
GMutex lock;
GstClockID sync_id;
GstClockID sync_id2;
@ -327,7 +324,7 @@ test_async_sync_interaction_cb (GstClock * clock, GstClockTime time,
struct test_async_sync_interaction_data *td =
(struct test_async_sync_interaction_data *) (user_data);
g_mutex_lock (td->lock);
g_mutex_lock (&td->lock);
/* The first async callback is ignored */
if (id == td->async_id)
goto out;
@ -341,7 +338,7 @@ test_async_sync_interaction_cb (GstClock * clock, GstClockTime time,
gst_clock_id_unschedule (td->async_id2);
}
out:
g_mutex_unlock (td->lock);
g_mutex_unlock (&td->lock);
return FALSE;
}
@ -363,12 +360,12 @@ GST_START_TEST (test_async_sync_interaction)
clock = gst_system_clock_obtain ();
fail_unless (clock != NULL, "Could not create instance of GstSystemClock");
td.lock = g_mutex_new ();
g_mutex_init (&td.lock);
for (i = 0; i < 50; i++) {
gst_clock_debug (clock);
base = gst_clock_get_time (clock);
g_mutex_lock (td.lock);
g_mutex_lock (&td.lock);
td.async_id = gst_clock_new_single_shot_id (clock, base + 40 * GST_MSECOND);
td.async_id2 =
gst_clock_new_single_shot_id (clock, base + 30 * GST_MSECOND);
@ -376,7 +373,7 @@ GST_START_TEST (test_async_sync_interaction)
gst_clock_new_single_shot_id (clock, base + 20 * GST_MSECOND);
td.sync_id2 = gst_clock_new_single_shot_id (clock, base + 10 * GST_MSECOND);
td.sync_id = gst_clock_new_single_shot_id (clock, base + 50 * GST_MSECOND);
g_mutex_unlock (td.lock);
g_mutex_unlock (&td.lock);
result = gst_clock_id_wait_async (td.async_id,
test_async_sync_interaction_cb, &td, NULL);
@ -403,17 +400,17 @@ GST_START_TEST (test_async_sync_interaction)
"Waiting did not return UNSCHEDULED (was %d)", result);
gst_clock_id_unschedule (td.async_id3);
g_mutex_lock (td.lock);
g_mutex_lock (&td.lock);
gst_clock_id_unref (td.sync_id);
gst_clock_id_unref (td.sync_id2);
gst_clock_id_unref (td.async_id);
gst_clock_id_unref (td.async_id2);
gst_clock_id_unref (td.async_id3);
g_mutex_unlock (td.lock);
g_mutex_unlock (&td.lock);
}
g_mutex_free (td.lock);
g_mutex_clear (&td.lock);
gst_object_unref (clock);
}
@ -537,7 +534,8 @@ GST_START_TEST (test_mixed)
id = gst_clock_new_periodic_id (info.clock, base, 10 * GST_MSECOND);
/* start waiting for the entry */
thread = g_thread_create ((GThreadFunc) mixed_thread, &info, TRUE, &error);
thread =
g_thread_try_new ("gst-check", (GThreadFunc) mixed_thread, &info, &error);
fail_unless (error == NULL, "error creating thread");
fail_unless (thread != NULL, "Could not create thread");
@ -569,20 +567,20 @@ test_async_full_slave_callback (GstClock * master, GstClockTime time,
/* notify the test case that we started */
GST_INFO ("callback started");
g_mutex_lock (af_lock);
g_cond_signal (af_cond);
g_mutex_lock (&af_lock);
g_cond_signal (&af_cond);
/* wait for the test case to unref "clock" and signal */
GST_INFO ("waiting for test case to signal");
g_cond_wait (af_cond, af_lock);
g_cond_wait (&af_cond, &af_lock);
stime = gst_clock_get_internal_time (clock);
mtime = gst_clock_get_time (master);
gst_clock_add_observation (clock, stime, mtime, &r_squared);
g_cond_signal (af_cond);
g_mutex_unlock (af_lock);
g_cond_signal (&af_cond);
g_mutex_unlock (&af_lock);
GST_INFO ("callback finished");
return TRUE;
@ -593,9 +591,6 @@ GST_START_TEST (test_async_full)
GstClock *master, *slave;
GstClockID *clockid;
af_lock = g_mutex_new ();
af_cond = g_cond_new ();
/* create master and slave */
master =
g_object_new (GST_TYPE_SYSTEM_CLOCK, "name", "TestClockMaster", NULL);
@ -607,7 +602,7 @@ GST_START_TEST (test_async_full)
fail_unless (GST_OBJECT_REFCOUNT (slave) == 1);
/* register a periodic shot on the master to calibrate the slave */
g_mutex_lock (af_lock);
g_mutex_lock (&af_lock);
clockid = gst_clock_new_periodic_id (master,
gst_clock_get_time (master), gst_clock_get_timeout (slave));
gst_clock_id_wait_async (clockid,
@ -617,7 +612,7 @@ GST_START_TEST (test_async_full)
/* wait for the shot to be fired and test_async_full_slave_callback to be
* called */
GST_INFO ("waiting for the slave callback to start");
g_cond_wait (af_cond, af_lock);
g_cond_wait (&af_cond, &af_lock);
GST_INFO ("slave callback running, unreffing slave");
/* unref the slave clock while the slave_callback is running. This should be
@ -630,17 +625,14 @@ GST_START_TEST (test_async_full)
gst_clock_id_unref (clockid);
/* signal and wait for the callback to complete */
g_cond_signal (af_cond);
g_cond_signal (&af_cond);
GST_INFO ("waiting for callback to finish");
g_cond_wait (af_cond, af_lock);
g_cond_wait (&af_cond, &af_lock);
GST_INFO ("callback finished");
g_mutex_unlock (af_lock);
g_mutex_unlock (&af_lock);
gst_object_unref (master);
g_mutex_free (af_lock);
g_cond_free (af_cond);
}
GST_END_TEST;

View file

@ -300,9 +300,12 @@ GST_START_TEST (test_threads)
setter = GST_TAG_SETTER (g_object_new (GST_TYPE_DUMMY_ENC, NULL));
spin_and_wait = TRUE;
threads[0] = g_thread_create (test_threads_thread_func1, setter, TRUE, NULL);
threads[1] = g_thread_create (test_threads_thread_func2, setter, TRUE, NULL);
threads[2] = g_thread_create (test_threads_thread_func3, setter, TRUE, NULL);
threads[0] = g_thread_try_new ("gst-check", test_threads_thread_func1,
setter, NULL);
threads[1] = g_thread_try_new ("gst-check", test_threads_thread_func2,
setter, NULL);
threads[2] = g_thread_try_new ("gst-check", test_threads_thread_func3,
setter, NULL);
while (g_atomic_int_get (&threads_running) < 3)
g_usleep (10);

View file

@ -350,9 +350,12 @@ GST_START_TEST (test_threads)
setter = GST_TOC_SETTER (g_object_new (GST_TYPE_DUMMY_ENC, NULL));
spin_and_wait = TRUE;
threads[0] = g_thread_create (test_threads_thread_func1, setter, TRUE, NULL);
threads[1] = g_thread_create (test_threads_thread_func2, setter, TRUE, NULL);
threads[2] = g_thread_create (test_threads_thread_func3, setter, TRUE, NULL);
threads[0] = g_thread_try_new ("gst-check", test_threads_thread_func1,
setter, NULL);
threads[1] = g_thread_try_new ("gst-check", test_threads_thread_func2,
setter, NULL);
threads[2] = g_thread_try_new ("gst-check", test_threads_thread_func3,
setter, NULL);
while (g_atomic_int_get (&threads_running) < 3)
g_usleep (10);

View file

@ -26,11 +26,11 @@
#define fail_unless_collected(expected) \
G_STMT_START { \
g_mutex_lock (lock); \
g_mutex_lock (&lock); \
while (expected == TRUE && collected == FALSE) \
g_cond_wait (cond, lock); \
g_cond_wait (&cond,& lock); \
fail_unless_equals_int (collected, expected); \
g_mutex_unlock (lock); \
g_mutex_unlock (&lock); \
} G_STMT_END;
typedef struct
@ -62,16 +62,16 @@ static GstPad *srcpad1, *srcpad2;
static GstPad *sinkpad1, *sinkpad2;
static TestData *data1, *data2;
static GMutex *lock;
static GCond *cond;
static GMutex lock;
static GCond cond;
static GstFlowReturn
collected_cb (GstCollectPads * pads, gpointer user_data)
{
g_mutex_lock (lock);
g_mutex_lock (&lock);
collected = TRUE;
g_cond_signal (cond);
g_mutex_unlock (lock);
g_cond_signal (&cond);
g_mutex_unlock (&lock);
return GST_FLOW_OK;
}
@ -124,8 +124,6 @@ setup (void)
gst_pad_set_active (srcpad1, TRUE);
gst_pad_set_active (srcpad2, TRUE);
cond = g_cond_new ();
lock = g_mutex_new ();
data1 = NULL;
data2 = NULL;
collected = FALSE;
@ -137,8 +135,6 @@ teardown (void)
gst_object_unref (sinkpad1);
gst_object_unref (sinkpad2);
gst_object_unref (collect);
g_cond_free (cond);
g_mutex_free (lock);
}
GST_START_TEST (test_pad_add_remove)
@ -178,13 +174,13 @@ GST_START_TEST (test_collect)
/* push buffers on the pads */
data1->pad = srcpad1;
data1->buffer = buf1;
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
thread1 = g_thread_try_new ("gst-check", push_buffer, data1, NULL);
/* here thread1 is blocked and srcpad1 has a queued buffer */
fail_unless_collected (FALSE);
data2->pad = srcpad2;
data2->buffer = buf2;
thread2 = g_thread_create (push_buffer, data2, TRUE, NULL);
thread2 = g_thread_try_new ("gst-check", push_buffer, data2, NULL);
/* now both pads have a buffer */
fail_unless_collected (TRUE);
@ -228,13 +224,13 @@ GST_START_TEST (test_collect_eos)
/* push a buffer on srcpad1 and EOS on srcpad2 */
data1->pad = srcpad1;
data1->buffer = buf1;
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
thread1 = g_thread_try_new ("gst-check", push_buffer, data1, NULL);
/* here thread1 is blocked and srcpad1 has a queued buffer */
fail_unless_collected (FALSE);
data2->pad = srcpad2;
data2->event = gst_event_new_eos ();
thread2 = g_thread_create (push_event, data2, TRUE, NULL);
thread2 = g_thread_try_new ("gst-check", push_event, data2, NULL);
/* now sinkpad1 has a buffer and sinkpad2 has EOS */
fail_unless_collected (TRUE);
@ -279,14 +275,14 @@ GST_START_TEST (test_collect_twice)
/* queue a buffer */
data1->pad = srcpad1;
data1->buffer = buf1;
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
thread1 = g_thread_try_new ("gst-check", push_buffer, data1, NULL);
/* here thread1 is blocked and srcpad1 has a queued buffer */
fail_unless_collected (FALSE);
/* push EOS on the other pad */
data2->pad = srcpad2;
data2->event = gst_event_new_eos ();
thread2 = g_thread_create (push_event, data2, TRUE, NULL);
thread2 = g_thread_try_new ("gst-check", push_event, data2, NULL);
/* one of the pads has a buffer, the other has EOS */
fail_unless_collected (TRUE);
@ -319,13 +315,13 @@ GST_START_TEST (test_collect_twice)
/* push buffers on the pads */
data1->pad = srcpad1;
data1->buffer = buf1;
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
thread1 = g_thread_try_new ("gst-check", push_buffer, data1, NULL);
/* here thread1 is blocked and srcpad1 has a queued buffer */
fail_unless_collected (FALSE);
data2->pad = srcpad2;
data2->buffer = buf2;
thread2 = g_thread_create (push_buffer, data2, TRUE, NULL);
thread2 = g_thread_try_new ("gst-check", push_buffer, data2, NULL);
/* now both pads have a buffer */
fail_unless_collected (TRUE);