summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2011-04-14 14:32:02 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2011-04-14 14:33:00 -0300
commit3f7ab0b31983daca1747cf9ae1696b491db2f7ae (patch)
treea16582a256ac307fd575ba795b5643213aaf7568
parent8a9a0cd37e5572dba0681e84eef16341746348f3 (diff)
downloadgstreamer-plugins-bad-3f7ab0b31983daca1747cf9ae1696b491db2f7ae.tar.gz
tests: camerabin2: Leak fixes for the unit tests
Leak fixes related to not removing the source returned from gst_bus_add_watch
-rw-r--r--tests/check/elements/camerabin2.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/check/elements/camerabin2.c b/tests/check/elements/camerabin2.c
index 55c3cc0db..f44998543 100644
--- a/tests/check/elements/camerabin2.c
+++ b/tests/check/elements/camerabin2.c
@@ -167,6 +167,7 @@ gst_test_camera_src_init (GstTestCameraSrc * self,
static GstElement *camera;
+static guint bus_source;
static GMainLoop *main_loop;
guint32 test_id = 0;
@@ -304,19 +305,21 @@ extract_jpeg_tags (const gchar * filename, gint num)
gchar *pipeline_str = g_strdup_printf ("filesrc location=%s ! "
"jpegparse ! fakesink", filepath);
GstElement *pipeline;
+ guint source;
pipeline = gst_parse_launch (pipeline_str, NULL);
fail_unless (pipeline != NULL);
g_free (pipeline_str);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- gst_bus_add_watch (bus, (GstBusFunc) validity_bus_cb, loop);
+ source = gst_bus_add_watch (bus, (GstBusFunc) validity_bus_cb, loop);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_main_loop_run (loop);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (bus);
+ g_source_remove (source);
gst_object_unref (pipeline);
}
@@ -332,6 +335,7 @@ setup_wrappercamerabinsrc_videotestsrc (void)
GST_INFO ("init");
test_id = g_random_int ();
+ bus_source = 0;
main_loop = g_main_loop_new (NULL, TRUE);
@@ -356,7 +360,7 @@ setup_wrappercamerabinsrc_videotestsrc (void)
gst_object_unref (fakevideosink);
bus = gst_pipeline_get_bus (GST_PIPELINE (camera));
- gst_bus_add_watch (bus, (GstBusFunc) capture_bus_cb, main_loop);
+ bus_source = gst_bus_add_watch (bus, (GstBusFunc) capture_bus_cb, main_loop);
gst_object_unref (bus);
tags_found = NULL;
@@ -373,6 +377,9 @@ teardown (void)
gst_check_teardown_element (camera);
camera = NULL;
+ if (bus_source)
+ g_source_remove (bus_source);
+
if (main_loop)
g_main_loop_unref (main_loop);
main_loop = NULL;
@@ -455,6 +462,7 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist,
GstCaps *caps;
gint caps_width, caps_height;
GstState state;
+ guint source;
GMainLoop *loop = g_main_loop_new (NULL, FALSE);
GstElement *playbin = gst_element_factory_make ("playbin2", NULL);
@@ -468,7 +476,7 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist,
"audio-sink", fakeaudio, NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (playbin));
- gst_bus_add_watch (bus, (GstBusFunc) validity_bus_cb, loop);
+ source = gst_bus_add_watch (bus, (GstBusFunc) validity_bus_cb, loop);
gst_element_set_state (playbin, GST_STATE_PAUSED);
gst_element_get_state (playbin, &state, NULL, GST_SECOND * 3);
@@ -511,6 +519,7 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist,
}
g_free (uri);
+ g_source_remove (source);
gst_object_unref (bus);
gst_object_unref (playbin);