gst/audioresample/gstaudioresample.c: Don't leak references to the incoming caps. Clean them up when stopping.

Original commit message from CVS:
* gst/audioresample/gstaudioresample.c: (audioresample_stop),
(audioresample_set_caps):
Don't leak references to the incoming caps. Clean them up when
stopping.
* gst/videoscale/gstvideoscale.c: (gst_video_scale_class_init),
(gst_video_scale_finalize):
Don't leak our temporary pixel buffer.
* tests/check/Makefile.am:
* tests/check/pipelines/simple-launch-lines.c: (run_pipeline),
(GST_START_TEST), (simple_launch_lines_suite):
Fix leaks and re-enable the test for valgrind checking.
This commit is contained in:
Jan Schmidt 2006-07-28 17:17:24 +00:00
parent 11503c773e
commit e828178eca
6 changed files with 65 additions and 23 deletions

View file

@ -1,3 +1,20 @@
2006-07-28 Jan Schmidt <thaytan@mad.scientist.com>
* gst/audioresample/gstaudioresample.c: (audioresample_stop),
(audioresample_set_caps):
Don't leak references to the incoming caps. Clean them up when
stopping.
* gst/videoscale/gstvideoscale.c: (gst_video_scale_class_init),
(gst_video_scale_finalize):
Don't leak our temporary pixel buffer.
* tests/check/Makefile.am:
* tests/check/pipelines/simple-launch-lines.c: (run_pipeline),
(GST_START_TEST), (simple_launch_lines_suite):
Fix leaks and re-enable the test for valgrind checking.
2006-07-28 Tim-Philipp Müller <tim at centricular dot net> 2006-07-28 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Sjoerd Simons <sjoerd at luon net> Patch by: Sjoerd Simons <sjoerd at luon net>

2
common

@ -1 +1 @@
Subproject commit ef97fb3278d98a1fdb32e5c6b2a7467116ffc160 Subproject commit e9ea99f6e89d7e1af3a0a859bfeb0ed6ecf2e3a9

View file

@ -223,6 +223,9 @@ audioresample_stop (GstBaseTransform * base)
audioresample->resample = NULL; audioresample->resample = NULL;
} }
gst_caps_replace (&audioresample->sinkcaps, NULL);
gst_caps_replace (&audioresample->srccaps, NULL);
return TRUE; return TRUE;
} }
@ -438,10 +441,7 @@ audioresample_set_caps (GstBaseTransform * base, GstCaps * incaps,
/* save caps so we can short-circuit in the size_transform if the caps /* save caps so we can short-circuit in the size_transform if the caps
* are the same */ * are the same */
/* FIXME: clean them up in state change ? */
gst_caps_ref (incaps);
gst_caps_replace (&audioresample->sinkcaps, incaps); gst_caps_replace (&audioresample->sinkcaps, incaps);
gst_caps_ref (outcaps);
gst_caps_replace (&audioresample->srccaps, outcaps); gst_caps_replace (&audioresample->srccaps, outcaps);
return TRUE; return TRUE;

View file

@ -187,6 +187,7 @@ gst_video_scale_sink_template_factory (void)
static void gst_video_scale_base_init (gpointer g_class); static void gst_video_scale_base_init (gpointer g_class);
static void gst_video_scale_class_init (GstVideoScaleClass * klass); static void gst_video_scale_class_init (GstVideoScaleClass * klass);
static void gst_video_scale_init (GstVideoScale * videoscale); static void gst_video_scale_init (GstVideoScale * videoscale);
static void gst_video_scale_finalize (GstVideoScale * videoscale);
static gboolean gst_video_scale_src_event (GstBaseTransform * trans, static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
GstEvent * event); GstEvent * event);
@ -257,6 +258,7 @@ gst_video_scale_class_init (GstVideoScaleClass * klass)
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
trans_class = (GstBaseTransformClass *) klass; trans_class = (GstBaseTransformClass *) klass;
gobject_class->finalize = (GObjectFinalizeFunc) gst_video_scale_finalize;
gobject_class->set_property = gst_video_scale_set_property; gobject_class->set_property = gst_video_scale_set_property;
gobject_class->get_property = gst_video_scale_get_property; gobject_class->get_property = gst_video_scale_get_property;
@ -286,6 +288,14 @@ gst_video_scale_init (GstVideoScale * videoscale)
videoscale->method = DEFAULT_PROP_METHOD; videoscale->method = DEFAULT_PROP_METHOD;
} }
static void
gst_video_scale_finalize (GstVideoScale * videoscale)
{
if (videoscale->tmp_buf)
g_free (videoscale->tmp_buf);
G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT (videoscale));
}
static void static void
gst_video_scale_set_property (GObject * object, guint prop_id, gst_video_scale_set_property (GObject * object, guint prop_id,

View file

@ -6,7 +6,7 @@ REGISTRY_ENVIRONMENT = \
GST_REGISTRY=$(CHECK_REGISTRY) GST_REGISTRY=$(CHECK_REGISTRY)
TESTS_ENVIRONMENT = \ TESTS_ENVIRONMENT = \
CK_DEFAULT_TIMEOUT=20 \ CK_DEFAULT_TIMEOUT=120 \
$(REGISTRY_ENVIRONMENT) \ $(REGISTRY_ENVIRONMENT) \
GST_PLUGIN_SYSTEM_PATH= \ GST_PLUGIN_SYSTEM_PATH= \
GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(GST_PLUGINS_DIR) GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(GST_PLUGINS_DIR)
@ -65,8 +65,7 @@ VALGRIND_TO_FIX = \
elements/audioresample \ elements/audioresample \
generic/states \ generic/states \
libs/cddabasesrc \ libs/cddabasesrc \
libs/video \ libs/video
pipelines/simple-launch-lines
# these tests don't even pass # these tests don't even pass
noinst_PROGRAMS = noinst_PROGRAMS =

View file

@ -56,7 +56,8 @@ run_pipeline (GstElement * pipe, const gchar * descr,
bus = gst_element_get_bus (pipe); bus = gst_element_get_bus (pipe);
g_assert (bus); g_assert (bus);
ret = gst_element_set_state (pipe, GST_STATE_PLAYING); fail_if (gst_element_set_state (pipe, GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to playing", descr);
ret = gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE); ret = gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE);
if (ret != GST_STATE_CHANGE_SUCCESS) { if (ret != GST_STATE_CHANGE_SUCCESS) {
g_critical ("Couldn't set pipeline to PLAYING"); g_critical ("Couldn't set pipeline to PLAYING");
@ -89,22 +90,34 @@ run_pipeline (GstElement * pipe, const gchar * descr,
} }
done: done:
gst_element_set_state (pipe, GST_STATE_NULL); fail_if (gst_element_set_state (pipe, GST_STATE_NULL) ==
GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to NULL", descr);
gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE);
gst_object_unref (pipe); gst_object_unref (pipe);
gst_bus_set_flushing (bus, TRUE);
gst_object_unref (bus);
} }
GST_START_TEST (test_element_negotiation) GST_START_TEST (test_element_negotiation)
{ {
gchar *s; gchar *s;
/* see http://bugzilla.gnome.org/show_bug.cgi?id=315126 */ /* Ensures that filtering buffers with unknown caps down to fixed-caps
s = "fakesrc ! audio/x-raw-int,width=16,depth=16,rate=22050,channels=1 ! audioconvert ! audio/x-raw-int,width=16,depth=16,rate=22050,channels=1 ! fakesink"; * will apply those caps to the buffers.
* see http://bugzilla.gnome.org/show_bug.cgi?id=315126 */
s = "fakesrc num-buffers=2 ! "
"audio/x-raw-int,width=16,depth=16,rate=22050,channels=1,"
"signed=(boolean)true,endianness=1234 ! "
"audioconvert ! audio/x-raw-int,width=16,depth=16,rate=22050,channels=1 "
"! fakesink";
run_pipeline (setup_pipeline (s), s, run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN); GST_MESSAGE_UNKNOWN);
#ifdef HAVE_LIBVISUAL #ifdef HAVE_LIBVISUAL
s = "audiotestsrc ! tee name=t ! alsasink t. ! audioconvert ! libvisual_lv_scope ! ffmpegcolorspace ! xvimagesink"; s = "audiotestsrc num-buffers=30 ! tee name=t ! alsasink t. ! audioconvert ! "
"libvisual_lv_scope ! ffmpegcolorspace ! xvimagesink";
run_pipeline (setup_pipeline (s), s, run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN); GST_MESSAGE_UNKNOWN);
@ -114,20 +127,22 @@ GST_START_TEST (test_element_negotiation)
GST_END_TEST GST_END_TEST
GST_START_TEST (test_basetransform_based) GST_START_TEST (test_basetransform_based)
{ {
/* Each of these tests is to check whether various basetransform based elements can /* Each of these tests is to check whether various basetransform based
* select output caps when not allowed to do passthrough and going to a generic sink * elements can select output caps when not allowed to do passthrough
* such as fakesink or filesink */ * and going to a generic sink such as fakesink or filesink */
const gchar *s; const gchar *s;
/* Check that videoscale can pick a height given only a width */ /* Check that videoscale can pick a height given only a width */
s = "videotestsrc ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! " "videoscale ! video/x-raw-yuv,width=640 ! fakesink"; s = "videotestsrc num-buffers=2 ! "
"video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! "
"videoscale ! video/x-raw-yuv,width=640 ! fakesink";
run_pipeline (setup_pipeline (s), s, run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN); GST_MESSAGE_UNKNOWN);
/* Test that ffmpegcolorspace can pick an output format that isn't /* Test that ffmpegcolorspace can pick an output format that isn't
* passthrough without completely specified output caps */ * passthrough without completely specified output caps */
s = "videotestsrc ! " s = "videotestsrc num-buffers=2 ! "
"video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! " "video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! "
"ffmpegcolorspace ! video/x-raw-rgb ! fakesink"; "ffmpegcolorspace ! video/x-raw-rgb ! fakesink";
run_pipeline (setup_pipeline (s), s, run_pipeline (setup_pipeline (s), s,
@ -136,15 +151,16 @@ GST_START_TEST (test_basetransform_based)
/* Check that audioresample can pick a samplerate to use from a /* Check that audioresample can pick a samplerate to use from a
* range that doesn't include the input */ * range that doesn't include the input */
s = "audiotestsrc ! audio/x-raw-int,width=16,depth=16,rate=8000 ! " s = "audiotestsrc num-buffers=2 ! "
"audio/x-raw-int,width=16,depth=16,rate=8000 ! "
"audioresample ! audio/x-raw-int,rate=[16000,48000] ! fakesink"; "audioresample ! audio/x-raw-int,rate=[16000,48000] ! fakesink";
run_pipeline (setup_pipeline (s), s, run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN); GST_MESSAGE_UNKNOWN);
/* Check that audioconvert can pick a depth to use, given a width */ /* Check that audioconvert can pick a depth to use, given a width */
s = "audiotestsrc ! audio/x-raw-int,width=16,depth=16 ! audioconvert ! " s = "audiotestsrc num-buffers=30 ! audio/x-raw-int,width=16,depth=16 ! "
"audio/x-raw-int,width=32 ! fakesink"; "audioconvert ! " "audio/x-raw-int,width=32 ! fakesink";
run_pipeline (setup_pipeline (s), s, run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN); GST_MESSAGE_UNKNOWN);
@ -157,12 +173,12 @@ GST_END_TEST
Suite *s = suite_create ("Pipelines"); Suite *s = suite_create ("Pipelines");
TCase *tc_chain = tcase_create ("linear"); TCase *tc_chain = tcase_create ("linear");
/* time out after 20s, not the default 3 */ /* time out after 60s, not the default 3 */
tcase_set_timeout (tc_chain, 20); tcase_set_timeout (tc_chain, 60);
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
#ifndef GST_DISABLE_PARSE #ifndef GST_DISABLE_PARSE
// tcase_add_test (tc_chain, test_element_negotiation); tcase_add_test (tc_chain, test_element_negotiation);
tcase_add_test (tc_chain, test_basetransform_based); tcase_add_test (tc_chain, test_basetransform_based);
#endif #endif
return s; return s;