tests: camerabin: Some leak fixes

Leak fixes related to removing the source returned from
gst_bus_add_watch
This commit is contained in:
Thiago Santos 2011-04-14 13:27:20 -03:00
parent 290d598748
commit 8a9a0cd37e

View file

@ -47,6 +47,7 @@
#define PHOTO_SETTING_DELAY_US 0
static GstElement *camera;
static guint bus_source;
static GMainLoop *main_loop;
static guint cycle_count = 0;
static gboolean received_preview_msg = FALSE;
@ -290,7 +291,7 @@ setup (void)
g_signal_connect (camera, "image-done", G_CALLBACK (capture_done), main_loop);
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_bus_set_sync_handler (bus, bus_sync_callback, main_loop);
gst_object_unref (bus);
@ -335,6 +336,8 @@ teardown (void)
{
gint i;
g_source_remove (bus_source);
if (camera)
gst_check_teardown_element (camera);
@ -444,6 +447,7 @@ extract_jpeg_tags (const gchar * filename, gint num)
static gboolean
check_file_validity (const gchar * filename, gint num, GstTagList * taglist)
{
guint source;
GstBus *bus;
GMainLoop *loop = g_main_loop_new (NULL, FALSE);
GstElement *playbin = gst_element_factory_make ("playbin2", NULL);
@ -458,7 +462,7 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist)
validation_taglist = 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_PLAYING);
g_main_loop_run (loop);
@ -484,8 +488,10 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist)
gst_tag_list_free (validation_taglist);
g_free (uri);
g_source_remove (source);
gst_object_unref (bus);
gst_object_unref (playbin);
g_main_loop_unref (loop);
return TRUE;
}