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);
#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;
{
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);
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 *
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;
}
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)
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");
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);
}
/* 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++) {
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)
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);
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);
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++) {
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;
#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;
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;
overrun_count = 0;
- underrun_mutex = g_mutex_new ();
- underrun_cond = g_cond_new ();
underrun_count = 0;
events = NULL;
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);
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,
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(). */
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;
}
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);
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 */
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");
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);
}
/* 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 */
/* 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");
* 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 */
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
{
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");
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");
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;
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]);
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 ();
typedef struct
{
- GMutex *lock;
- GCond *cond;
+ GMutex lock;
+ GCond cond;
gboolean signaled;
} SignalData;
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;
}
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
typedef struct
{
- GMutex *mutex;
- GCond *cond;
+ GMutex mutex;
+ GCond cond;
} BlockData;
static GstPadProbeReturn
{
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;
}
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);
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);
{
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);
/* clean up */
g_value_unset (&item);
gst_iterator_free (iter);
- g_mutex_free (m);
+ g_mutex_clear (&m);
g_list_free (l);
}
{
GList *l;
guint32 cookie = 0;
- GMutex *m;
+ GMutex m;
GstIterator *iter;
GstIteratorResult res;
GValue item = { 0, };
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);
/* clean up */
g_value_unset (&item);
gst_iterator_free (iter);
- g_mutex_free (m);
+ g_mutex_clear (&m);
g_list_free (l);
}
{
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;
/* clean up */
gst_iterator_free (iter);
- g_mutex_free (m);
+ g_mutex_clear (&m);
g_list_free (l);
}
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)) {
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)
*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;
}
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 */
{
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
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
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.
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])
#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)
return FALSE;
}
-GMutex *store_lock;
+GMutex store_lock;
static gboolean
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;
}
GstClockTime base;
GstClockReturn result;
- store_lock = g_mutex_new ();
-
clock = gst_system_clock_obtain ();
fail_unless (clock != NULL, "Could not create instance of GstSystemClock");
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;
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;
gst_clock_id_unschedule (td->async_id2);
}
out:
- g_mutex_unlock (td->lock);
+ g_mutex_unlock (&td->lock);
return FALSE;
}
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);
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);
"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);
}
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");
/* 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;
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);
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,
/* 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
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;
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);
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);
#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
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;
}
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;
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)
/* 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);
/* 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);
/* 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);
/* 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);