tests: mpeg2enc, mplex: port to the new GLib thread API

This commit is contained in:
Mark Nauwelaerts 2012-09-11 14:32:04 +02:00
parent 2816380e7c
commit 82f46a5efe
2 changed files with 24 additions and 24 deletions

View file

@ -53,8 +53,8 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
/* some global vars, makes it easy as for the ones above */ /* some global vars, makes it easy as for the ones above */
static GMutex *mpeg2enc_mutex; static GMutex mpeg2enc_mutex;
static GCond *mpeg2enc_cond; static GCond mpeg2enc_cond;
static gboolean arrived_eos; static gboolean arrived_eos;
static gboolean static gboolean
@ -63,10 +63,10 @@ test_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
g_mutex_lock (mpeg2enc_mutex); g_mutex_lock (&mpeg2enc_mutex);
arrived_eos = TRUE; arrived_eos = TRUE;
g_cond_signal (mpeg2enc_cond); g_cond_signal (&mpeg2enc_cond);
g_mutex_unlock (mpeg2enc_mutex); g_mutex_unlock (&mpeg2enc_mutex);
break; break;
default: default:
break; break;
@ -91,8 +91,8 @@ setup_mpeg2enc (void)
gst_pad_set_event_function (mysinkpad, test_sink_event); gst_pad_set_event_function (mysinkpad, test_sink_event);
/* and notify the test run */ /* and notify the test run */
mpeg2enc_mutex = g_mutex_new (); g_mutex_init (&mpeg2enc_mutex);
mpeg2enc_cond = g_cond_new (); g_cond_init (&mpeg2enc_cond);
return mpeg2enc; return mpeg2enc;
} }
@ -109,8 +109,8 @@ cleanup_mpeg2enc (GstElement * mpeg2enc)
gst_check_teardown_sink_pad (mpeg2enc); gst_check_teardown_sink_pad (mpeg2enc);
gst_check_teardown_element (mpeg2enc); gst_check_teardown_element (mpeg2enc);
g_mutex_free (mpeg2enc_mutex); g_mutex_clear (&mpeg2enc_mutex);
g_cond_free (mpeg2enc_cond); g_cond_clear (&mpeg2enc_cond);
} }
GST_START_TEST (test_video_pad) GST_START_TEST (test_video_pad)
@ -141,10 +141,10 @@ GST_START_TEST (test_video_pad)
/* need to force eos and state change to make sure the encoding task ends */ /* need to force eos and state change to make sure the encoding task ends */
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()) == TRUE); fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()) == TRUE);
/* need to wait a bit to make sure mpeg2enc task digested all this */ /* need to wait a bit to make sure mpeg2enc task digested all this */
g_mutex_lock (mpeg2enc_mutex); g_mutex_lock (&mpeg2enc_mutex);
while (!arrived_eos) while (!arrived_eos)
g_cond_wait (mpeg2enc_cond, mpeg2enc_mutex); g_cond_wait (&mpeg2enc_cond, &mpeg2enc_mutex);
g_mutex_unlock (mpeg2enc_mutex); g_mutex_unlock (&mpeg2enc_mutex);
num_buffers = g_list_length (buffers); num_buffers = g_list_length (buffers);
/* well, we do not really know much with mpeg, but at least something ... */ /* well, we do not really know much with mpeg, but at least something ... */

View file

@ -51,8 +51,8 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
/* some global vars, makes it easy as for the ones above */ /* some global vars, makes it easy as for the ones above */
static GMutex *mplex_mutex; static GMutex mplex_mutex;
static GCond *mplex_cond; static GCond mplex_cond;
static gboolean arrived_eos; static gboolean arrived_eos;
/* another easy hack, some mp2 audio data that should please mplex /* another easy hack, some mp2 audio data that should please mplex
@ -103,10 +103,10 @@ test_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
g_mutex_lock (mplex_mutex); g_mutex_lock (&mplex_mutex);
arrived_eos = TRUE; arrived_eos = TRUE;
g_cond_signal (mplex_cond); g_cond_signal (&mplex_cond);
g_mutex_unlock (mplex_mutex); g_mutex_unlock (&mplex_mutex);
break; break;
default: default:
break; break;
@ -191,8 +191,8 @@ setup_mplex (void)
gst_pad_set_event_function (mysinkpad, test_sink_event); gst_pad_set_event_function (mysinkpad, test_sink_event);
/* and notify the test run */ /* and notify the test run */
mplex_mutex = g_mutex_new (); g_mutex_init (&mplex_mutex);
mplex_cond = g_cond_new (); g_cond_init (&mplex_cond);
return mplex; return mplex;
} }
@ -209,8 +209,8 @@ cleanup_mplex (GstElement * mplex)
gst_check_teardown_sink_pad (mplex); gst_check_teardown_sink_pad (mplex);
gst_check_teardown_element (mplex); gst_check_teardown_element (mplex);
g_mutex_free (mplex_mutex); g_mutex_clear (&mplex_mutex);
g_cond_free (mplex_cond); g_cond_clear (&mplex_cond);
gst_deinit (); gst_deinit ();
} }
@ -245,10 +245,10 @@ GST_START_TEST (test_audio_pad)
/* need to force eos and state change to make sure the encoding task ends */ /* need to force eos and state change to make sure the encoding task ends */
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()) == TRUE); fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()) == TRUE);
/* need to wait a bit to make sure mplex task digested all this */ /* need to wait a bit to make sure mplex task digested all this */
g_mutex_lock (mplex_mutex); g_mutex_lock (&mplex_mutex);
while (!arrived_eos) while (!arrived_eos)
g_cond_wait (mplex_cond, mplex_mutex); g_cond_wait (&mplex_cond, &mplex_mutex);
g_mutex_unlock (mplex_mutex); g_mutex_unlock (&mplex_mutex);
num_buffers = g_list_length (buffers); num_buffers = g_list_length (buffers);
/* well, we do not really know much with mplex, but at least something ... */ /* well, we do not really know much with mplex, but at least something ... */