*/
/**
* SECTION:gstminiobject
+ * @title: GstMiniObject
* @short_description: Lightweight base class for the GStreamer object hierarchy
*
* #GstMiniObject is a simple structure that can be used to implement refcounted
#include "gst/gstinfo.h"
#include <gobject/gvaluecollector.h>
-#ifndef GST_DISABLE_TRACE
-#include "gsttrace.h"
-static GstAllocTrace *_gst_mini_object_trace;
-#endif
-
/* Mutex used for weak referencing */
G_LOCK_DEFINE_STATIC (qdata_mutex);
static GQuark weak_ref_quark;
_priv_gst_mini_object_initialize (void)
{
weak_ref_quark = g_quark_from_static_string ("GstMiniObjectWeakRefQuark");
-
-#ifndef GST_DISABLE_TRACE
- _gst_mini_object_trace = _gst_alloc_trace_register ("GstMiniObject", 0);
-#endif
}
/**
* @mini_object: a #GstMiniObject
* @flags: initial #GstMiniObjectFlags
* @type: the #GType of the mini-object to create
- * @copy_func: (allow-none): the copy function, or NULL
- * @dispose_func: (allow-none): the dispose function, or NULL
- * @free_func: (allow-none): the free function or NULL
+ * @copy_func: (allow-none): the copy function, or %NULL
+ * @dispose_func: (allow-none): the dispose function, or %NULL
+ * @free_func: (allow-none): the free function or %NULL
*
* Initializes a mini-object with the desired type and copy/dispose/free
* functions.
mini_object->n_qdata = 0;
mini_object->qdata = NULL;
-#ifndef GST_DISABLE_TRACE
- _gst_alloc_trace_new (_gst_mini_object_trace, mini_object);
-#endif
+ GST_TRACER_MINI_OBJECT_CREATED (mini_object);
}
/**
- * gst_mini_object_copy:
+ * gst_mini_object_copy: (skip)
* @mini_object: the mini-object to copy
*
* Creates a copy of the mini-object.
access_mode &= ~GST_LOCK_FLAG_EXCLUSIVE;
}
- if (access_mode) {
- /* shared counter > 1 and write access is not allowed */
- if (access_mode & GST_LOCK_FLAG_WRITE && IS_SHARED (state))
- goto lock_failed;
+ /* shared counter > 1 and write access is not allowed */
+ if (((state & GST_LOCK_FLAG_WRITE) != 0
+ || (access_mode & GST_LOCK_FLAG_WRITE) != 0)
+ && IS_SHARED (newstate))
+ goto lock_failed;
+ if (access_mode) {
if ((state & LOCK_FLAG_MASK) == 0) {
/* nothing mapped, set access_mode */
newstate |= access_mode;
* Modification of a mini-object should only be done after verifying that it
* is writable.
*
- * Returns: TRUE if the object is writable.
+ * Returns: %TRUE if the object is writable.
*/
gboolean
gst_mini_object_is_writable (const GstMiniObject * mini_object)
}
/**
- * gst_mini_object_make_writable:
+ * gst_mini_object_make_writable: (skip)
* @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
}
/**
- * gst_mini_object_ref:
+ * gst_mini_object_ref: (skip)
* @mini_object: the mini-object
*
* Increase the reference count of the mini-object.
g_return_val_if_fail (mini_object->refcount > 0, NULL);
*/
+ GST_TRACER_MINI_OBJECT_REFFED (mini_object, mini_object->refcount + 1);
GST_CAT_TRACE (GST_CAT_REFCOUNTING, "%p ref %d->%d", mini_object,
GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object),
GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) + 1);
}
/**
- * gst_mini_object_unref:
+ * gst_mini_object_unref: (skip)
* @mini_object: the mini-object
*
* Decreases the reference count of the mini-object, possibly freeing
if (G_UNLIKELY (g_atomic_int_dec_and_test (&mini_object->refcount))) {
gboolean do_free;
+ GST_TRACER_MINI_OBJECT_UNREFFED (mini_object, mini_object->refcount);
if (mini_object->dispose)
do_free = mini_object->dispose (mini_object);
else
call_finalize_notify (mini_object);
g_free (mini_object->qdata);
}
-#ifndef GST_DISABLE_TRACE
- _gst_alloc_trace_free (_gst_mini_object_trace, mini_object);
-#endif
+ GST_TRACER_MINI_OBJECT_DESTROYED (mini_object);
if (mini_object->free)
mini_object->free (mini_object);
}
+ } else {
+ GST_TRACER_MINI_OBJECT_UNREFFED (mini_object, mini_object->refcount);
}
}
/**
* gst_mini_object_replace:
- * @olddata: (inout) (transfer full): pointer to a pointer to a mini-object to
- * be replaced
- * @newdata: pointer to new mini-object
+ * @olddata: (inout) (transfer full) (nullable): pointer to a pointer to a
+ * mini-object to be replaced
+ * @newdata: (allow-none): pointer to new mini-object
*
* Atomically modifies a pointer to point to a new mini-object.
* The reference count of @olddata is decreased and the reference count of
* @newdata is increased.
*
- * Either @newdata and the value pointed to by @olddata may be NULL.
+ * Either @newdata and the value pointed to by @olddata may be %NULL.
*
- * Returns: TRUE if @newdata was different from @olddata
+ * Returns: %TRUE if @newdata was different from @olddata
*/
gboolean
gst_mini_object_replace (GstMiniObject ** olddata, GstMiniObject * newdata)
}
/**
- * gst_mini_object_steal:
+ * gst_mini_object_steal: (skip)
* @olddata: (inout) (transfer full): pointer to a pointer to a mini-object to
* be stolen
*
- * Replace the current #GstMiniObject pointer to by @olddata with NULL and
+ * Replace the current #GstMiniObject pointer to by @olddata with %NULL and
* return the old value.
*
* Returns: the #GstMiniObject at @oldata
* except that it does not increase the refcount of @newdata and thus
* takes ownership of @newdata.
*
- * Either @newdata and the value pointed to by @olddata may be NULL.
+ * Either @newdata and the value pointed to by @olddata may be %NULL.
*
- * Returns: TRUE if @newdata was different from @olddata
+ * Returns: %TRUE if @newdata was different from @olddata
*/
gboolean
gst_mini_object_take (GstMiniObject ** olddata, GstMiniObject * newdata)
if ((i = find_notify (object, weak_ref_quark, TRUE, notify, data)) != -1) {
remove_notify (object, i);
} else {
- g_warning ("%s: couldn't find weak ref %p(%p)", G_STRFUNC, notify, data);
+ g_warning ("%s: couldn't find weak ref %p (object:%p data:%p)", G_STRFUNC,
+ notify, object, data);
}
G_UNLOCK (qdata_mutex);
}
* can be gotten back from the @object with gst_mini_object_get_qdata()
* until the @object is disposed.
* Setting a previously set user data pointer, overrides (frees)
- * the old pointer set, using #NULL as pointer essentially
+ * the old pointer set, using %NULL as pointer essentially
* removes the data stored.
*
* @destroy may be specified which is called with @data as argument
* This function gets back user data pointers stored via
* gst_mini_object_set_qdata().
*
- * Returns: (transfer none): The user data pointer set, or %NULL
+ * Returns: (transfer none) (nullable): The user data pointer set, or
+ * %NULL
*/
gpointer
gst_mini_object_get_qdata (GstMiniObject * object, GQuark quark)
* and removes the data from @object without invoking its destroy() function (if
* any was set).
*
- * Returns: (transfer full): The user data pointer set, or %NULL
+ * Returns: (transfer full) (nullable): The user data pointer set, or
+ * %NULL
*/
gpointer
gst_mini_object_steal_qdata (GstMiniObject * object, GQuark quark)