EXPORT_C #endif gboolean gst_object_set_name (GstObject * object, const gchar * name) { gboolean result; g_return_val_if_fail (GST_IS_OBJECT (object), FALSE); GST_OBJECT_LOCK (object); /* parented objects cannot be renamed */ if (G_UNLIKELY (object->parent != NULL)) goto had_parent; if (name != NULL) { g_free (object->name); object->name = g_strdup (name); GST_OBJECT_UNLOCK (object); result = TRUE; } else { GST_OBJECT_UNLOCK (object); result = gst_object_set_name_default (object); } return result; /* error */ had_parent: { GST_WARNING ("parented objects can't be renamed"); GST_OBJECT_UNLOCK (object); return FALSE; } }
/** * gst_object_set_name: * @object: a #GstObject * @name: new name of object * * Sets the name of @object, or gives @object a guaranteed unique * name (if @name is NULL). * This function makes a copy of the provided name, so the caller * retains ownership of the name it sent. * * Returns: TRUE if the name could be set. Since Objects that have * a parent cannot be renamed, this function returns FALSE in those * cases. * * MT safe. This function grabs and releases @object's LOCK. */ gboolean gst_object_set_name (GstObject * object, const gchar * name) { gboolean result; g_return_val_if_fail (GST_IS_OBJECT (object), FALSE); GST_OBJECT_LOCK (object); /* parented objects cannot be renamed */ if (G_UNLIKELY (object->parent != NULL)) goto had_parent; if (name != NULL) { g_free (object->name); object->name = g_strdup (name); GST_OBJECT_UNLOCK (object); result = TRUE; } else { GST_OBJECT_UNLOCK (object); result = gst_object_set_name_default (object); } /* FIXME-0.11: this misses a g_object_notify (object, "name"); unless called * from gst_object_set_property. * Ideally remove such custom setters (or make it static). */ return result; /* error */ had_parent: { GST_WARNING ("parented objects can't be renamed"); GST_OBJECT_UNLOCK (object); return FALSE; } }