From 35387bca479d6b1e8253b83cfbe75bb7a8e3f994 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 29 Nov 2002 13:59:30 +0000 Subject: [PATCH] random cleanups and paranoia checks Original commit message from CVS: random cleanups and paranoia checks --- examples/manual/Makefile.am | 4 ++-- gst/cothreads.c | 5 ++++- tests/old/examples/manual/Makefile.am | 4 ++-- tests/old/testsuite/cleanup/cleanup4.c | 6 +++--- tests/old/testsuite/threads/threadc.c | 11 ++++++----- tests/old/testsuite/threads/threadf.c | 2 +- testsuite/cleanup/cleanup4.c | 6 +++--- testsuite/threads/threadc.c | 11 ++++++----- testsuite/threads/threadf.c | 2 +- 9 files changed, 28 insertions(+), 23 deletions(-) diff --git a/examples/manual/Makefile.am b/examples/manual/Makefile.am index 00eb365..370d6a6 100644 --- a/examples/manual/Makefile.am +++ b/examples/manual/Makefile.am @@ -4,7 +4,7 @@ else GNOME= endif -EXAMPLES = dynamic $(GNOME) helloworld helloworld2 queue xml-mp3 +EXAMPLES = dynamic $(GNOME) helloworld helloworld2 queue threads xml-mp3 noinst_PROGRAMS = $(EXAMPLES) LDADD = $(GST_LIBS) @@ -23,5 +23,5 @@ EXTRA_DIST = extract.pl # also, it's a bit irritating that right now a change in any xml file # triggers a rebuild of all examples #%.c: -dynamic.c gnome.c helloworld.c helloworld2.c queue.c xml-mp3.c: $(top_srcdir)/docs/manual/*.xml +dynamic.c gnome.c helloworld.c helloworld2.c queue.c threads.c xml-mp3.c: $(top_srcdir)/docs/manual/*.xml $(srcdir)/extract.pl $@ $(top_srcdir)/docs/manual/*.xml diff --git a/gst/cothreads.c b/gst/cothreads.c index f4386f7..a66e956 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -296,7 +296,10 @@ cothread_free (cothread_state *cothread) cothread->cothreadnum); /* we simply flag the cothread for destruction here */ - cothread->flags |= COTHREAD_DESTROYED; + if (cothread) + cothread->flags |= COTHREAD_DESTROYED; + else + g_warning ("somebody set up us the bomb"); } static void diff --git a/tests/old/examples/manual/Makefile.am b/tests/old/examples/manual/Makefile.am index 00eb365..370d6a6 100644 --- a/tests/old/examples/manual/Makefile.am +++ b/tests/old/examples/manual/Makefile.am @@ -4,7 +4,7 @@ else GNOME= endif -EXAMPLES = dynamic $(GNOME) helloworld helloworld2 queue xml-mp3 +EXAMPLES = dynamic $(GNOME) helloworld helloworld2 queue threads xml-mp3 noinst_PROGRAMS = $(EXAMPLES) LDADD = $(GST_LIBS) @@ -23,5 +23,5 @@ EXTRA_DIST = extract.pl # also, it's a bit irritating that right now a change in any xml file # triggers a rebuild of all examples #%.c: -dynamic.c gnome.c helloworld.c helloworld2.c queue.c xml-mp3.c: $(top_srcdir)/docs/manual/*.xml +dynamic.c gnome.c helloworld.c helloworld2.c queue.c threads.c xml-mp3.c: $(top_srcdir)/docs/manual/*.xml $(srcdir)/extract.pl $@ $(top_srcdir)/docs/manual/*.xml diff --git a/tests/old/testsuite/cleanup/cleanup4.c b/tests/old/testsuite/cleanup/cleanup4.c index 91b92f7..4d0eb35 100644 --- a/tests/old/testsuite/cleanup/cleanup4.c +++ b/tests/old/testsuite/cleanup/cleanup4.c @@ -24,7 +24,7 @@ main (gint argc, gchar *argv[]) GstElement *bin; GstElement *fakesink; - fprintf (stderr, "+"); + g_print ("+"); bin = gst_bin_new ("bin"); @@ -41,11 +41,11 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_NULL); - fprintf (stderr, "-"); + g_print ("-"); gst_bin_remove (GST_BIN (pipeline), GST_ELEMENT (bin)); } - fprintf (stderr, "\n"); + g_print ("\n"); g_mem_chunk_info (); return 0; diff --git a/tests/old/testsuite/threads/threadc.c b/tests/old/testsuite/threads/threadc.c index 6f34794..d357138 100644 --- a/tests/old/testsuite/threads/threadc.c +++ b/tests/old/testsuite/threads/threadc.c @@ -8,7 +8,7 @@ gboolean running = FALSE; gboolean can_quit = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement *pipeline, gint identities) { GstElement *src, *sink, *identity; GstElement *from; @@ -31,7 +31,7 @@ construct_pipeline (GstElement *pipeline, gint identities) } gst_element_connect (identity, sink); - g_object_set (G_OBJECT (src), "num_buffers", 10, "sizetype", 3, NULL); + g_object_set (G_OBJECT (src), "num_buffers", 2, "sizetype", 3, NULL); } void @@ -56,7 +56,7 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) int main (gint argc, gchar *argv[]) { - int runs = 130; + int runs = 290; int i; gulong id; GstElement *thread; @@ -69,12 +69,13 @@ main (gint argc, gchar *argv[]) g_assert (thread); /* connect state change signal */ - id = g_signal_connect (G_OBJECT (thread), "state_change", + id = g_signal_connect (G_OBJECT (thread), "state_change", G_CALLBACK (state_changed), NULL); construct_pipeline (thread, i / 10 + 1); g_print ("Setting thread to play with %d identities\n", i / 10 + 1); - gst_element_set_state (thread, GST_STATE_PLAYING); + if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) + g_error ("Failed setting thread to play\n"); g_print ("Going into the main GStreamer loop\n"); can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */ diff --git a/tests/old/testsuite/threads/threadf.c b/tests/old/testsuite/threads/threadf.c index e219971..7db234f 100644 --- a/tests/old/testsuite/threads/threadf.c +++ b/tests/old/testsuite/threads/threadf.c @@ -48,7 +48,7 @@ thread (void) int i; GstElement *pipeline; - for (i = 0; i < runs; ++i) + for (i = 50; i < runs; ++i) { pipeline = gst_pipeline_new ("main_pipeline"); g_assert (pipeline); diff --git a/testsuite/cleanup/cleanup4.c b/testsuite/cleanup/cleanup4.c index 91b92f7..4d0eb35 100644 --- a/testsuite/cleanup/cleanup4.c +++ b/testsuite/cleanup/cleanup4.c @@ -24,7 +24,7 @@ main (gint argc, gchar *argv[]) GstElement *bin; GstElement *fakesink; - fprintf (stderr, "+"); + g_print ("+"); bin = gst_bin_new ("bin"); @@ -41,11 +41,11 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_NULL); - fprintf (stderr, "-"); + g_print ("-"); gst_bin_remove (GST_BIN (pipeline), GST_ELEMENT (bin)); } - fprintf (stderr, "\n"); + g_print ("\n"); g_mem_chunk_info (); return 0; diff --git a/testsuite/threads/threadc.c b/testsuite/threads/threadc.c index 6f34794..d357138 100644 --- a/testsuite/threads/threadc.c +++ b/testsuite/threads/threadc.c @@ -8,7 +8,7 @@ gboolean running = FALSE; gboolean can_quit = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement *pipeline, gint identities) { GstElement *src, *sink, *identity; GstElement *from; @@ -31,7 +31,7 @@ construct_pipeline (GstElement *pipeline, gint identities) } gst_element_connect (identity, sink); - g_object_set (G_OBJECT (src), "num_buffers", 10, "sizetype", 3, NULL); + g_object_set (G_OBJECT (src), "num_buffers", 2, "sizetype", 3, NULL); } void @@ -56,7 +56,7 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) int main (gint argc, gchar *argv[]) { - int runs = 130; + int runs = 290; int i; gulong id; GstElement *thread; @@ -69,12 +69,13 @@ main (gint argc, gchar *argv[]) g_assert (thread); /* connect state change signal */ - id = g_signal_connect (G_OBJECT (thread), "state_change", + id = g_signal_connect (G_OBJECT (thread), "state_change", G_CALLBACK (state_changed), NULL); construct_pipeline (thread, i / 10 + 1); g_print ("Setting thread to play with %d identities\n", i / 10 + 1); - gst_element_set_state (thread, GST_STATE_PLAYING); + if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) + g_error ("Failed setting thread to play\n"); g_print ("Going into the main GStreamer loop\n"); can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */ diff --git a/testsuite/threads/threadf.c b/testsuite/threads/threadf.c index e219971..7db234f 100644 --- a/testsuite/threads/threadf.c +++ b/testsuite/threads/threadf.c @@ -48,7 +48,7 @@ thread (void) int i; GstElement *pipeline; - for (i = 0; i < runs; ++i) + for (i = 50; i < runs; ++i) { pipeline = gst_pipeline_new ("main_pipeline"); g_assert (pipeline); -- 2.7.4