examples: webrtc: Remove the bus watch at the end
authorSebastian Dröge <sebastian@centricular.com>
Tue, 20 Dec 2022 11:03:44 +0000 (13:03 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 20 Dec 2022 11:03:44 +0000 (13:03 +0200)
Otherwise a file descriptor will be leaked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3609>

subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c
subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c
subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c

index a184e19..30f4962 100644 (file)
@@ -973,6 +973,7 @@ int
 main (int argc, char *argv[])
 {
   GOptionContext *context;
+  GstBus *bus;
   GError *error = NULL;
 
   context = g_option_context_new ("- gstreamer webrtc sendrecv demo");
@@ -1021,6 +1022,10 @@ main (int argc, char *argv[])
   gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
   gst_print ("Pipeline stopped\n");
 
+  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+  gst_bus_remove_watch (bus);
+  gst_object_unref (bus);
+
   gst_object_unref (pipeline);
   g_free (server_url);
   g_free (local_id);
index 0533f08..58dbf02 100644 (file)
@@ -392,9 +392,15 @@ destroy_receiver_entry (gpointer receiver_entry_ptr)
   g_assert (receiver_entry != NULL);
 
   if (receiver_entry->pipeline != NULL) {
+    GstBus *bus;
+
     gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline),
         GST_STATE_NULL);
 
+    bus = gst_pipeline_get_bus (GST_PIPELINE (receiver_entry->pipeline));
+    gst_bus_remove_watch (bus);
+    gst_object_unref (bus);
+
     gst_object_unref (GST_OBJECT (receiver_entry->webrtcbin));
     gst_object_unref (GST_OBJECT (receiver_entry->pipeline));
   }
index 4717b6a..5d6ed25 100644 (file)
@@ -324,9 +324,15 @@ destroy_receiver_entry (gpointer receiver_entry_ptr)
   g_assert (receiver_entry != NULL);
 
   if (receiver_entry->pipeline != NULL) {
+    GstBus *bus;
+
     gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline),
         GST_STATE_NULL);
 
+    bus = gst_pipeline_get_bus (GST_PIPELINE (receiver_entry->pipeline));
+    gst_bus_remove_watch (bus);
+    gst_object_unref (bus);
+
     gst_object_unref (GST_OBJECT (receiver_entry->webrtcbin));
     gst_object_unref (GST_OBJECT (receiver_entry->pipeline));
   }