/** * gst_mini_object_make_writable: * @mini_object: the mini-object to make writable * * Checks if a mini-object is writable. If not, a writable copy is made and * returned. This gives away the reference to the original mini object, * and returns a reference to the new object. * * MT safe * * Returns: a mini-object (possibly the same pointer) that is writable. */ GstMiniObject * gst_mini_object_make_writable (GstMiniObject * mini_object) { GstMiniObject *ret; g_return_val_if_fail (mini_object != NULL, NULL); if (gst_mini_object_is_writable (mini_object)) { ret = mini_object; } else { GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy %s miniobject", g_type_name (G_TYPE_FROM_INSTANCE (mini_object))); ret = gst_mini_object_copy (mini_object); gst_mini_object_unref (mini_object); } return ret; }
/** * gst_mini_object_make_writable: * @mini_object: (transfer full): the mini-object to make writable * * Checks if a mini-object is writable. If not, a writable copy is made and * returned. This gives away the reference to the original mini object, * and returns a reference to the new object. * * MT safe * * Returns: (transfer full): a mini-object (possibly the same pointer) that * is writable. */ GstMiniObject * gst_mini_object_make_writable (GstMiniObject * mini_object) { GstMiniObject *ret; g_return_val_if_fail (mini_object != NULL, NULL); if (gst_mini_object_is_writable (mini_object)) { ret = mini_object; } else { ret = gst_mini_object_copy (mini_object); GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy %s miniobject %p -> %p", g_type_name (GST_MINI_OBJECT_TYPE (mini_object)), mini_object, ret); gst_mini_object_unref (mini_object); } return ret; }
void test_copy() { GstBuffer *buffer, *copy; xmlfile = "gstminiobject_test_copy"; std_log(LOG_FILENAME_LINE, "Test Started test_copy"); buffer = gst_buffer_new_and_alloc (4); copy = GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT (buffer))); fail_if (copy == NULL, "Copy of buffer returned NULL"); fail_unless (GST_BUFFER_SIZE (copy) == 4, "Copy of buffer has different size"); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
MiniObjectPtr MiniObject::copy() const { return MiniObjectPtr::wrap(gst_mini_object_copy(object<GstMiniObject>()), false); }