examples: webrtc: Remove the bus watch at the end

Otherwise a file descriptor will be leaked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3609>
This commit is contained in:
Sebastian Dröge 2022-12-20 13:03:44 +02:00
parent 1f4f338d85
commit ec6290d63f
3 changed files with 17 additions and 0 deletions

View file

@ -973,6 +973,7 @@ int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
GOptionContext *context; GOptionContext *context;
GstBus *bus;
GError *error = NULL; GError *error = NULL;
context = g_option_context_new ("- gstreamer webrtc sendrecv demo"); 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_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
gst_print ("Pipeline stopped\n"); 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); gst_object_unref (pipeline);
g_free (server_url); g_free (server_url);
g_free (local_id); g_free (local_id);

View file

@ -392,9 +392,15 @@ destroy_receiver_entry (gpointer receiver_entry_ptr)
g_assert (receiver_entry != NULL); g_assert (receiver_entry != NULL);
if (receiver_entry->pipeline != NULL) { if (receiver_entry->pipeline != NULL) {
GstBus *bus;
gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline), gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline),
GST_STATE_NULL); 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->webrtcbin));
gst_object_unref (GST_OBJECT (receiver_entry->pipeline)); gst_object_unref (GST_OBJECT (receiver_entry->pipeline));
} }

View file

@ -324,9 +324,15 @@ destroy_receiver_entry (gpointer receiver_entry_ptr)
g_assert (receiver_entry != NULL); g_assert (receiver_entry != NULL);
if (receiver_entry->pipeline != NULL) { if (receiver_entry->pipeline != NULL) {
GstBus *bus;
gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline), gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline),
GST_STATE_NULL); 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->webrtcbin));
gst_object_unref (GST_OBJECT (receiver_entry->pipeline)); gst_object_unref (GST_OBJECT (receiver_entry->pipeline));
} }