From e4ba5018559d09e153aafca1d1d52d9e1cced648 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 22 Sep 2006 12:12:10 +0000 Subject: [PATCH] gst/autodetect/: Make static pad templates static to appease valgrind's leak detector. Original commit message from CVS: * gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_base_init): * gst/autodetect/gstautovideosink.c: (gst_auto_video_sink_base_init): Make static pad templates static to appease valgrind's leak detector. * tests/check/Makefile.am: * tests/check/elements/.cvsignore: * tests/check/elements/autodetect.c: (GST_START_TEST), (autodetect_suite): Add simple test for the ghostpad lockup on shutdown fixed in core CVS (audio bit disabled because it would need dozens of alsa suppressions and I'm too lazy to add those now). --- ChangeLog | 17 +++++ gst/autodetect/gstautoaudiosink.c | 19 +++--- gst/autodetect/gstautovideosink.c | 20 +++--- tests/check/Makefile.am | 1 + tests/check/elements/.gitignore | 1 + tests/check/elements/autodetect.c | 129 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 169 insertions(+), 18 deletions(-) create mode 100644 tests/check/elements/autodetect.c diff --git a/ChangeLog b/ChangeLog index 569e21e..439c82a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2006-09-22 Tim-Philipp Müller + + * gst/autodetect/gstautoaudiosink.c: + (gst_auto_audio_sink_base_init): + * gst/autodetect/gstautovideosink.c: + (gst_auto_video_sink_base_init): + Make static pad templates static to appease valgrind's leak + detector. + + * tests/check/Makefile.am: + * tests/check/elements/.cvsignore: + * tests/check/elements/autodetect.c: (GST_START_TEST), + (autodetect_suite): + Add simple test for the ghostpad lockup on shutdown fixed in core + CVS (audio bit disabled because it would need dozens of alsa + suppressions and I'm too lazy to add those now). + 2006-09-22 Wim Taymans * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16depay_change_state): diff --git a/gst/autodetect/gstautoaudiosink.c b/gst/autodetect/gstautoaudiosink.c index 13b0e65..8e8f14f 100644 --- a/gst/autodetect/gstautoaudiosink.c +++ b/gst/autodetect/gstautoaudiosink.c @@ -52,19 +52,20 @@ gst_auto_audio_sink_change_state (GstElement * element, GST_BOILERPLATE (GstAutoAudioSink, gst_auto_audio_sink, GstBin, GST_TYPE_BIN); +static const GstElementDetails gst_auto_audio_sink_details = +GST_ELEMENT_DETAILS ("Auto audio sink", + "Sink/Audio", + "Wrapper audio sink for automatically detected audio sink", + "Ronald Bultje "); +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static void gst_auto_audio_sink_base_init (gpointer klass) { GstElementClass *eklass = GST_ELEMENT_CLASS (klass); - const GstElementDetails gst_auto_audio_sink_details = - GST_ELEMENT_DETAILS ("Auto audio sink", - "Sink/Audio", - "Wrapper audio sink for automatically detected audio sink", - "Ronald Bultje "); - GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY); gst_element_class_add_pad_template (eklass, gst_static_pad_template_get (&sink_template)); diff --git a/gst/autodetect/gstautovideosink.c b/gst/autodetect/gstautovideosink.c index 779acf1..6d5a931 100644 --- a/gst/autodetect/gstautovideosink.c +++ b/gst/autodetect/gstautovideosink.c @@ -52,19 +52,21 @@ gst_auto_video_sink_change_state (GstElement * element, GST_BOILERPLATE (GstAutoVideoSink, gst_auto_video_sink, GstBin, GST_TYPE_BIN); +static const GstElementDetails gst_auto_video_sink_details = +GST_ELEMENT_DETAILS ("Auto video sink", + "Sink/Video", + "Wrapper video sink for automatically detected video sink", + "Ronald Bultje "); + +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static void gst_auto_video_sink_base_init (gpointer klass) { GstElementClass *eklass = GST_ELEMENT_CLASS (klass); - const GstElementDetails gst_auto_video_sink_details = - GST_ELEMENT_DETAILS ("Auto video sink", - "Sink/Video", - "Wrapper video sink for automatically detected video sink", - "Ronald Bultje "); - GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY); gst_element_class_add_pad_template (eklass, gst_static_pad_template_get (&sink_template)); diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index d0c8ca5..c649b8e 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -34,6 +34,7 @@ endif check_PROGRAMS = \ $(check_annodex) \ elements/audiopanorama \ + elements/autodetect \ elements/avimux \ elements/level \ elements/matroskamux \ diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index 5a585af..b10b2d1 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -9,3 +9,4 @@ id3v2mux apev2mux audiopanorama +autodetect diff --git a/tests/check/elements/autodetect.c b/tests/check/elements/autodetect.c new file mode 100644 index 0000000..6556243 --- /dev/null +++ b/tests/check/elements/autodetect.c @@ -0,0 +1,129 @@ +/* GStreamer unit test for the autodetect elements + * + * Copyright (C) <2006> Tim-Philipp Müller + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +GST_START_TEST (test_autovideosink_ghostpad_error_case) +{ + GstStateChangeReturn state_ret; + GstElement *pipeline, *src, *filter, *sink; + GstCaps *caps; + + pipeline = gst_pipeline_new ("pipeline"); + src = gst_element_factory_make ("fakesrc", NULL); + filter = gst_element_factory_make ("capsfilter", NULL); + sink = gst_element_factory_make ("autovideosink", NULL); + + caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC, + GST_MAKE_FOURCC ('A', 'C', 'D', 'C'), NULL); + + g_object_set (filter, "caps", caps, NULL); + gst_caps_unref (caps); + + gst_bin_add_many (GST_BIN (pipeline), src, filter, sink, NULL); + + fail_unless (gst_element_link (src, filter)); + fail_unless (gst_element_link (filter, sink)); + + /* this should fail, there's no such format */ + state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); + fail_unless (state_ret == GST_STATE_CHANGE_FAILURE, + "pipeline _set_state() to PAUSED succeeded but should have failed"); + + /* so, we hit an error and try to shut down the pipeline; this shouldn't + * deadlock or block anywhere when autovideosink resets the ghostpad + * targets etc. */ + state_ret = gst_element_set_state (pipeline, GST_STATE_NULL); + fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS); + + /* clean up */ + gst_object_unref (pipeline); +} + +GST_END_TEST; + +/* disable this for now, too many valgrind suppressions needed for libasound */ +#if 0 +GST_START_TEST (test_autoaudiosink_ghostpad_error_case) +{ + GstStateChangeReturn state_ret; + GstElement *pipeline, *src, *filter, *sink; + GstCaps *caps; + + pipeline = gst_pipeline_new ("pipeline"); + src = gst_element_factory_make ("fakesrc", NULL); + filter = gst_element_factory_make ("capsfilter", NULL); + sink = gst_element_factory_make ("autoaudiosink", NULL); + + caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 42, NULL); + + g_object_set (filter, "caps", caps, NULL); + gst_caps_unref (caps); + + gst_bin_add_many (GST_BIN (pipeline), src, filter, sink, NULL); + + fail_unless (gst_element_link (src, filter)); + fail_unless (gst_element_link (filter, sink)); + + /* this should fail, there's no such width (hopefully) */ + state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); + fail_unless (state_ret == GST_STATE_CHANGE_FAILURE, + "pipeline _set_state() to PAUSED succeeded but should have failed"); + + /* so, we hit an error and try to shut down the pipeline; this shouldn't + * deadlock or block anywhere when autoaudiosink resets the ghostpad + * targets etc. */ + state_ret = gst_element_set_state (pipeline, GST_STATE_NULL); + fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS); + + /* clean up */ + gst_object_unref (pipeline); +} + +GST_END_TEST; +#endif + +static Suite * +autodetect_suite (void) +{ + guint maj, min, mic, nano; + + Suite *s = suite_create ("autodetect"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + + gst_version (&maj, &min, &mic, &nano); + + /* requires fixes from 0.10.10.1, but don't want to add a hard dependency + * in configure.ac just for this yet */ + if (maj > 0 || min > 10 || mic > 10 || (mic == 10 && nano > 0)) { + tcase_add_test (tc_chain, test_autovideosink_ghostpad_error_case); + /* tcase_add_test (tc_chain, test_autoaudiosink_ghostpad_error_case); */ + } + + return s; +} + +GST_CHECK_MAIN (autodetect); -- 2.7.4