bin: Switch `g_warning()`s to `GST_WARNING_OBJECT()`s when adding/removing an element...
authorSebastian Dröge <sebastian@centricular.com>
Mon, 8 Nov 2021 13:30:18 +0000 (15:30 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 8 Nov 2021 20:31:44 +0000 (20:31 +0000)
The failure conditions can be overidden by subclasses, and a boolean
return value is provided to the caller whether adding/removing the child
element has actually worked. The caller can then handle this
accordingly but flooding stderr with this is not very useful.

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

subprojects/gstreamer/gst/gstbin.c

index 571d7cd..298a8c2 100644 (file)
@@ -1390,9 +1390,9 @@ adding_itself:
   }
 duplicate_name:
   {
-    g_warning ("Name '%s' is not unique in bin '%s', not adding",
-        elem_name, GST_ELEMENT_NAME (bin));
     GST_OBJECT_UNLOCK (bin);
+    GST_WARNING_OBJECT (bin, "Name '%s' is not unique in bin, not adding",
+        elem_name);
     g_free (elem_name);
     gst_object_ref_sink (element);
     gst_object_unref (element);
@@ -1400,8 +1400,8 @@ duplicate_name:
   }
 had_parent:
   {
-    g_warning ("Element '%s' already has parent", elem_name);
     GST_OBJECT_UNLOCK (bin);
+    GST_WARNING_OBJECT (bin, "Element '%s' already has parent", elem_name);
     g_free (elem_name);
     return FALSE;
   }
@@ -1548,8 +1548,7 @@ gst_bin_add (GstBin * bin, GstElement * element)
   /* ERROR handling */
 no_function:
   {
-    g_warning ("adding elements to bin '%s' is not supported",
-        GST_ELEMENT_NAME (bin));
+    GST_WARNING_OBJECT (bin, "adding elements to bin is not supported");
     gst_object_ref_sink (element);
     gst_object_unref (element);
     return FALSE;
@@ -1844,10 +1843,9 @@ removing_itself:
   }
 not_in_bin:
   {
-    g_warning ("Element '%s' is not in bin '%s'", elem_name,
-        GST_ELEMENT_NAME (bin));
     GST_OBJECT_UNLOCK (element);
     GST_OBJECT_UNLOCK (bin);
+    GST_WARNING_OBJECT (bin, "Element '%s' is not in bin", elem_name);
     g_free (elem_name);
     return FALSE;
   }
@@ -1898,8 +1896,7 @@ gst_bin_remove (GstBin * bin, GstElement * element)
   /* ERROR handling */
 no_function:
   {
-    g_warning ("removing elements from bin '%s' is not supported",
-        GST_ELEMENT_NAME (bin));
+    GST_WARNING_OBJECT (bin, "Removing elements from bin is not supported");
     return FALSE;
   }
 }