threadc still fails

Original commit message from CVS:
threadc still fails
This commit is contained in:
Thomas Vander Stichele 2002-11-14 21:20:47 +00:00
parent 88f3b9131c
commit 852761c9dc
4 changed files with 54 additions and 28 deletions

View file

@ -1,5 +1,5 @@
testprogs = thread1 thread2 thread3 thread4 thread5 testprogs = thread1 thread2 thread3 thread4 thread5 threadb
testsfailing = threadb testsfailing = threadc
TESTS = $(testprogs) TESTS = $(testprogs)

View file

@ -3,8 +3,11 @@
/* threadb.c /* threadb.c
* this tests if we can make a GstThread, put some stuff in it, * this tests if we can make a GstThread, put some stuff in it,
* dispatch it, and let it run from a main gst loop * dispatch it, and let it run from a main gst loop
* we repeat the main loop a hundred times to test thread reuse
* underneath GstThread
*/ */
gboolean running = FALSE;
static void static void
construct_pipeline (GstElement *pipeline) construct_pipeline (GstElement *pipeline)
@ -28,7 +31,6 @@ construct_pipeline (GstElement *pipeline)
void void
state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
{ {
static gboolean running = FALSE;
GstElementState state = gst_element_get_state (el); GstElementState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n", g_print ("element %s has changed state to %s\n",
@ -42,15 +44,20 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
int int
main (gint argc, gchar *argv[]) main (gint argc, gchar *argv[])
{ {
int runs = 100;
int i;
gulong id;
GstElement *thread; GstElement *thread;
gst_init (&argc, &argv); gst_init (&argc, &argv);
for (i = 0; i < runs; ++i)
{
thread = gst_thread_new ("main_thread"); thread = gst_thread_new ("main_thread");
g_assert (thread); g_assert (thread);
/* connect state change signal */ /* connect state change signal */
g_signal_connect (G_OBJECT (thread), "state_change", id = g_signal_connect (G_OBJECT (thread), "state_change",
G_CALLBACK (state_changed), NULL); G_CALLBACK (state_changed), NULL);
construct_pipeline (thread); construct_pipeline (thread);
@ -60,6 +67,12 @@ main (gint argc, gchar *argv[])
g_print ("Going into the main GStreamer loop\n"); g_print ("Going into the main GStreamer loop\n");
gst_main (); gst_main ();
g_print ("Coming out of the main GStreamer loop\n"); g_print ("Coming out of the main GStreamer loop\n");
g_signal_handler_disconnect (G_OBJECT (thread), id);
gst_element_set_state (thread, GST_STATE_NULL);
g_print ("Unreffing thread\n");
g_object_unref (G_OBJECT (thread));
running = FALSE;
}
return 0; return 0;
} }

View file

@ -1,5 +1,5 @@
testprogs = thread1 thread2 thread3 thread4 thread5 testprogs = thread1 thread2 thread3 thread4 thread5 threadb
testsfailing = threadb testsfailing = threadc
TESTS = $(testprogs) TESTS = $(testprogs)

View file

@ -3,8 +3,11 @@
/* threadb.c /* threadb.c
* this tests if we can make a GstThread, put some stuff in it, * this tests if we can make a GstThread, put some stuff in it,
* dispatch it, and let it run from a main gst loop * dispatch it, and let it run from a main gst loop
* we repeat the main loop a hundred times to test thread reuse
* underneath GstThread
*/ */
gboolean running = FALSE;
static void static void
construct_pipeline (GstElement *pipeline) construct_pipeline (GstElement *pipeline)
@ -28,7 +31,6 @@ construct_pipeline (GstElement *pipeline)
void void
state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
{ {
static gboolean running = FALSE;
GstElementState state = gst_element_get_state (el); GstElementState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n", g_print ("element %s has changed state to %s\n",
@ -42,15 +44,20 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
int int
main (gint argc, gchar *argv[]) main (gint argc, gchar *argv[])
{ {
int runs = 100;
int i;
gulong id;
GstElement *thread; GstElement *thread;
gst_init (&argc, &argv); gst_init (&argc, &argv);
for (i = 0; i < runs; ++i)
{
thread = gst_thread_new ("main_thread"); thread = gst_thread_new ("main_thread");
g_assert (thread); g_assert (thread);
/* connect state change signal */ /* connect state change signal */
g_signal_connect (G_OBJECT (thread), "state_change", id = g_signal_connect (G_OBJECT (thread), "state_change",
G_CALLBACK (state_changed), NULL); G_CALLBACK (state_changed), NULL);
construct_pipeline (thread); construct_pipeline (thread);
@ -60,6 +67,12 @@ main (gint argc, gchar *argv[])
g_print ("Going into the main GStreamer loop\n"); g_print ("Going into the main GStreamer loop\n");
gst_main (); gst_main ();
g_print ("Coming out of the main GStreamer loop\n"); g_print ("Coming out of the main GStreamer loop\n");
g_signal_handler_disconnect (G_OBJECT (thread), id);
gst_element_set_state (thread, GST_STATE_NULL);
g_print ("Unreffing thread\n");
g_object_unref (G_OBJECT (thread));
running = FALSE;
}
return 0; return 0;
} }