From: Tim-Philipp Müller Date: Fri, 16 Jun 2006 09:39:54 +0000 (+0000) Subject: docs/manual/: Don't leak bus reference in sample code. X-Git-Tag: RELEASE-0_10_9~79 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49c923d8f6abb2f7386d388c1c0dbb9fc82a6995;p=platform%2Fupstream%2Fgstreamer.git docs/manual/: Don't leak bus reference in sample code. Original commit message from CVS: * docs/manual/advanced-autoplugging.xml: * docs/manual/basics-helloworld.xml: * docs/manual/highlevel-components.xml: Don't leak bus reference in sample code. --- diff --git a/ChangeLog b/ChangeLog index 2f1f07b..c1223a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-06-16 Tim-Philipp Müller + + * docs/manual/advanced-autoplugging.xml: + * docs/manual/basics-helloworld.xml: + * docs/manual/highlevel-components.xml: + Don't leak bus reference in sample code. + 2006-06-15 Tim-Philipp Müller * autogen.sh: diff --git a/docs/manual/advanced-autoplugging.xml b/docs/manual/advanced-autoplugging.xml index 36383f1..8abf238 100644 --- a/docs/manual/advanced-autoplugging.xml +++ b/docs/manual/advanced-autoplugging.xml @@ -185,6 +185,7 @@ main (gint argc, { GMainLoop *loop; GstElement *pipeline, *filesrc, *typefind; + GstBus *bus; /* init GStreamer */ gst_init (&argc, &argv); @@ -198,8 +199,10 @@ main (gint argc, /* create a new pipeline to hold the elements */ pipeline = gst_pipeline_new ("pipe"); - gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)), - my_bus_callback, NULL); + + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_watch (bus, my_bus_callback, NULL); + gst_object_unref (bus); /* create file source and typefind element */ filesrc = gst_element_factory_make ("filesrc", "source"); @@ -544,6 +547,7 @@ main (gint argc, { GMainLoop *loop; GstElement *typefind, *realsink; + GError *err = NULL; gchar *p; /* init GStreamer and ourselves */ @@ -559,10 +563,19 @@ main (gint argc, /* pipeline */ p = g_strdup_printf ("filesrc location=\"%s\" ! typefind name=tf", argv[1]); - pipeline = gst_parse_launch (p, NULL); - gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)), - my_bus_callback, NULL); + pipeline = gst_parse_launch (p, &err); g_free (p); + + if (err) { + g_error ("Could not construct pipeline: %s", err->message); + g_error_free (err); + return -1; + } + + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_watch (bus, my_bus_callback, NULL); + gst_object_unref (bus); + typefind = gst_bin_get_by_name (GST_BIN (pipeline), "tf"); g_signal_connect (typefind, "have-type", G_CALLBACK (cb_typefound), NULL); gst_object_unref (GST_OBJECT (typefind)); diff --git a/docs/manual/basics-helloworld.xml b/docs/manual/basics-helloworld.xml index 21bb62c..b671cce 100644 --- a/docs/manual/basics-helloworld.xml +++ b/docs/manual/basics-helloworld.xml @@ -119,6 +119,7 @@ main (int argc, char *argv[]) { GMainLoop *loop; + GstBus *bus; /* initialize GStreamer */ gst_init (&argc, &argv); @@ -145,8 +146,10 @@ main (int argc, /* set filename property on the file source. Also add a message * handler. */ g_object_set (G_OBJECT (source), "location", argv[1], NULL); - gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)), - bus_call, loop); + + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_watch (bus, bus_call, loop); + gst_object_unref (bus); /* put all elements in a bin */ gst_bin_add_many (GST_BIN (pipeline), diff --git a/docs/manual/highlevel-components.xml b/docs/manual/highlevel-components.xml index b7e4a5a..a56e19c 100644 --- a/docs/manual/highlevel-components.xml +++ b/docs/manual/highlevel-components.xml @@ -89,6 +89,7 @@ main (gint argc, { GMainLoop *loop; GstElement *play; + GstBus *bus; /* init GStreamer */ gst_init (&argc, &argv); @@ -103,8 +104,11 @@ main (gint argc, /* set up */ play = gst_element_factory_make ("playbin", "play"); g_object_set (G_OBJECT (play), "uri", argv[1], NULL); - gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (play)), - my_bus_callback, loop); + + bus = gst_pipeline_get_bus (GST_PIPELINE (play)); + gst_bus_add_watch (bus, my_bus_callback, loop); + gst_object_unref (bus); + gst_element_set_state (play, GST_STATE_PLAYING); /* now run */ @@ -266,6 +270,7 @@ main (gint argc, GMainLoop *loop; GstElement *src, *dec, *conv, *sink; GstPad *audiopad; + GstBus *bus; /* init GStreamer */ gst_init (&argc, &argv); @@ -279,8 +284,11 @@ main (gint argc, /* setup */ pipeline = gst_pipeline_new ("pipeline"); - gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)), - my_bus_callback, loop); + + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_watch (bus, my_bus_callback, loop); + gst_object_unref (bus); + src = gst_element_factory_make ("filesrc", "source"); g_object_set (G_OBJECT (src), "location", argv[1], NULL); dec = gst_element_factory_make ("decodebin", "decoder");