Merge branch 'upstream/1.16' into tizen_gst_1.16.2
[platform/upstream/gstreamer.git] / gst / gstobject.c
index 4bd431a..d0c52c8 100644 (file)
@@ -288,6 +288,9 @@ gst_object_unref (gpointer object)
  * the floating flag while leaving the reference count unchanged. If the object
  * is not floating, then this call adds a new normal reference increasing the
  * reference count by one.
+ *
+ * For more background on "floating references" please see the #GObject
+ * documentation.
  */
 gpointer
 gst_object_ref_sink (gpointer object)
@@ -303,6 +306,30 @@ gst_object_ref_sink (gpointer object)
 }
 
 /**
+ * gst_clear_object: (skip)
+ * @object_ptr: a pointer to a #GstObject reference
+ *
+ * Clears a reference to a #GstObject.
+ *
+ * @object_ptr must not be %NULL.
+ *
+ * If the reference is %NULL then this function does nothing.
+ * Otherwise, the reference count of the object is decreased using
+ * gst_object_unref() and the pointer is set to %NULL.
+ *
+ * A macro is also included that allows this function to be used without
+ * pointer casts.
+ *
+ * Since: 1.16
+ **/
+#undef gst_clear_object
+void
+gst_clear_object (GstObject ** object_ptr)
+{
+  g_clear_pointer (object_ptr, gst_object_unref);
+}
+
+/**
  * gst_object_replace:
  * @oldobj: (inout) (transfer full) (nullable): pointer to a place of
  *     a #GstObject to replace
@@ -660,7 +687,7 @@ gst_object_get_name (GstObject * object)
 
 /**
  * gst_object_set_parent:
- * @object: a #GstObject
+ * @object: (transfer floating): a #GstObject
  * @parent: new parent of object
  *
  * Sets the parent of @object to @parent. The object's reference count will
@@ -703,6 +730,8 @@ had_parent:
   {
     GST_CAT_DEBUG_OBJECT (GST_CAT_REFCOUNTING, object,
         "set parent failed, object already had a parent");
+    gst_object_ref_sink (object);
+    gst_object_unref (object);
     GST_OBJECT_UNLOCK (object);
     return FALSE;
   }
@@ -845,11 +874,7 @@ gst_object_has_as_ancestor (GstObject * object, GstObject * ancestor)
  *
  * MT safe. Grabs and releases @object's locks.
  */
-/* FIXME 2.0: remove */
 #ifndef GST_REMOVE_DEPRECATED
-#ifdef GST_DISABLE_DEPRECATED
-gboolean gst_object_has_ancestor (GstObject * object, GstObject * ancestor);
-#endif
 gboolean
 gst_object_has_ancestor (GstObject * object, GstObject * ancestor)
 {
@@ -1224,12 +1249,13 @@ gst_object_set_control_binding_disabled (GstObject * object,
 /**
  * gst_object_add_control_binding:
  * @object: the controller object
- * @binding: (transfer full): the #GstControlBinding that should be used
+ * @binding: (transfer floating): the #GstControlBinding that should be used
  *
  * Attach the #GstControlBinding to the object. If there already was a
  * #GstControlBinding for this property it will be replaced.
  *
- * The @object will take ownership of the @binding.
+ * The object's reference count will be incremented, and any floating
+ * reference will be removed (see gst_object_ref_sink())
  *
  * Returns: %FALSE if the given @binding has not been setup for this object or
  * has been setup for a non suitable property, %TRUE otherwise.
@@ -1442,7 +1468,7 @@ gst_object_get_g_value_array (GstObject * object, const gchar * property_name,
  *
  * Obtain the control-rate for this @object. Audio processing #GstElement
  * objects will use this rate to sub-divide their processing loop and call
- * gst_object_sync_values() inbetween. The length of the processing segment
+ * gst_object_sync_values() in between. The length of the processing segment
  * should be up to @control-rate nanoseconds.
  *
  * If the @object is not under property control, this will return
@@ -1468,7 +1494,7 @@ gst_object_get_control_rate (GstObject * object)
  *
  * Change the control-rate for this @object. Audio processing #GstElement
  * objects will use this rate to sub-divide their processing loop and call
- * gst_object_sync_values() inbetween. The length of the processing segment
+ * gst_object_sync_values() in between. The length of the processing segment
  * should be up to @control-rate nanoseconds.
  *
  * The control-rate should not change if the element is in %GST_STATE_PAUSED or