docs/manual/: Don't leak bus reference in sample code.
authorTim-Philipp Müller <tim@centricular.net>
Fri, 16 Jun 2006 09:39:54 +0000 (09:39 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 16 Jun 2006 09:39:54 +0000 (09:39 +0000)
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.

ChangeLog
docs/manual/advanced-autoplugging.xml
docs/manual/basics-helloworld.xml
docs/manual/highlevel-components.xml

index 2f1f07b..c1223a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-06-16  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * 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  <tim at centricular dot net>
 
        * autogen.sh:
index 36383f1..8abf238 100644 (file)
@@ -185,6 +185,7 @@ main (gint   argc,
 {
   GMainLoop *loop;
   GstElement *pipeline, *filesrc, *typefind;
+  GstBus *bus;
 
   /* init GStreamer */
   gst_init (&amp;argc, &amp;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, &amp;err);
   g_free (p);
+
+  if (err) {
+    g_error ("Could not construct pipeline: %s", err-&gt;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));
index 21bb62c..b671cce 100644 (file)
@@ -119,6 +119,7 @@ main (int   argc,
       char *argv[])
 {
   GMainLoop *loop;
+  GstBus *bus;
 
   /* initialize GStreamer */
   gst_init (&amp;argc, &amp;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),
index b7e4a5a..a56e19c 100644 (file)
@@ -89,6 +89,7 @@ main (gint   argc,
 {
   GMainLoop *loop;
   GstElement *play;
+  GstBus *bus;
 
   /* init GStreamer */
   gst_init (&amp;argc, &amp;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 (&amp;argc, &amp;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");