gst: Don't pass miniobjects to GST_DEBUG_OBJECT() and similar macros
[platform/upstream/gstreamer.git] / gst / gstminiobject.h
index 08f1071..b931e76 100644 (file)
@@ -15,8 +15,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 
@@ -62,7 +62,7 @@ typedef gboolean (*GstMiniObjectDisposeFunction) (GstMiniObject *obj);
  * GstMiniObjectFreeFunction:
  * @obj: MiniObject to free
  *
- * Virtual function prototype for methods to free ressources used by
+ * Virtual function prototype for methods to free resources used by
  * mini-objects.
  */
 typedef void (*GstMiniObjectFreeFunction) (GstMiniObject *obj);
@@ -73,7 +73,8 @@ typedef void (*GstMiniObjectFreeFunction) (GstMiniObject *obj);
  * @obj: the mini object
  *
  * A #GstMiniObjectNotify function can be added to a mini object as a
- * callback that gets triggered with gst_mini_object_notify().
+ * callback that gets triggered when gst_mini_object_unref() drops the
+ * last ref and @obj is about to be freed.
  */
 typedef void (*GstMiniObjectNotify) (gpointer user_data, GstMiniObject * obj);
 
@@ -113,7 +114,7 @@ typedef void (*GstMiniObjectNotify) (gpointer user_data, GstMiniObject * obj);
  * @obj: MiniObject to unset flag in.
  * @flag: Flag to set, must be a single bit in guint32.
  *
- * This macro usets the given bits.
+ * This macro unsets the given bits.
  */
 #define GST_MINI_OBJECT_FLAG_UNSET(obj,flag)         (GST_MINI_OBJECT_FLAGS (obj) &= ~(flag))
 
@@ -123,6 +124,9 @@ typedef void (*GstMiniObjectNotify) (gpointer user_data, GstMiniObject * obj);
  * gst_mini_object_lock() and gst_mini_object_unlock().
  * @GST_MINI_OBJECT_FLAG_LOCK_READONLY: the object is permanently locked in
  * READONLY mode. Only read locks can be performed on the object.
+ * @GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED: the object is expected to stay alive
+ * even after gst_deinit() has been called and so should be ignored by leak
+ * detection tools. (Since: 1.10)
  * @GST_MINI_OBJECT_FLAG_LAST: first flag that can be used by subclasses.
  *
  * Flags for the mini object
@@ -131,6 +135,7 @@ typedef enum
 {
   GST_MINI_OBJECT_FLAG_LOCKABLE      = (1 << 0),
   GST_MINI_OBJECT_FLAG_LOCK_READONLY = (1 << 1),
+  GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED = (1 << 2),
   /* padding */
   GST_MINI_OBJECT_FLAG_LAST          = (1 << 4)
 } GstMiniObjectFlags;
@@ -158,15 +163,15 @@ typedef enum {
   GST_LOCK_FLAG_WRITE     = (1 << 1),
   GST_LOCK_FLAG_EXCLUSIVE = (1 << 2),
 
-  GST_LOCK_FLAG_LAST      = (1 << 4)
+  GST_LOCK_FLAG_LAST      = (1 << 8)
 } GstLockFlags;
 
 /**
- * GST_LOCK_FLAG_READWRITE:
+ * GST_LOCK_FLAG_READWRITE: (value 3) (type GstLockFlags)
  *
  * GstLockFlags value alias for GST_LOCK_FLAG_READ | GST_LOCK_FLAG_WRITE
  */
-#define GST_LOCK_FLAG_READWRITE  (GST_LOCK_FLAG_READ | GST_LOCK_FLAG_WRITE)
+#define GST_LOCK_FLAG_READWRITE  ((GstLockFlags) (GST_LOCK_FLAG_READ | GST_LOCK_FLAG_WRITE))
 
 /**
  * GST_MINI_OBJECT_REFCOUNT:
@@ -184,7 +189,7 @@ typedef enum {
 #define GST_MINI_OBJECT_REFCOUNT_VALUE(obj)     (g_atomic_int_get (&(GST_MINI_OBJECT_CAST(obj))->refcount))
 
 /**
- * GstMiniObject:
+ * GstMiniObject: (ref-func gst_mini_object_ref) (unref-func gst_mini_object_unref) (set-value-func g_value_set_boxed) (get-value-func g_value_get_boxed)
  * @type: the GType of the object
  * @refcount: atomic refcount
  * @lockstate: atomic state of the locks
@@ -194,10 +199,6 @@ typedef enum {
  * @free: the free function
  *
  * Base class for refcounted lightweight objects.
- * Ref Func: gst_mini_object_ref
- * Unref Func: gst_mini_object_unref
- * Set Value Func: g_value_set_boxed
- * Get Value Func: g_value_get_boxed
  */
 struct _GstMiniObject {
   GType   type;
@@ -212,11 +213,12 @@ struct _GstMiniObject {
   GstMiniObjectFreeFunction free;
 
   /* < private > */
-  /* Used to keep track of weak ref notifies and qdata */
-  guint n_qdata;
-  gpointer qdata;
+  /* Used to keep track of parents, weak ref notifies and qdata */
+  guint priv_uint;
+  gpointer priv_pointer;
 };
 
+GST_API
 void            gst_mini_object_init (GstMiniObject *mini_object,
                                       guint flags, GType type,
                                       GstMiniObjectCopyFunction copy_func,
@@ -225,36 +227,68 @@ void            gst_mini_object_init (GstMiniObject *mini_object,
 
 
 /* refcounting */
+
+GST_API
 GstMiniObject * gst_mini_object_ref            (GstMiniObject *mini_object);
+
+GST_API
 void            gst_mini_object_unref          (GstMiniObject *mini_object);
 
+GST_API
+void        gst_clear_mini_object (GstMiniObject **object_ptr);
+#define     gst_clear_mini_object(object_ptr) g_clear_pointer ((object_ptr), gst_mini_object_unref)
+
+GST_API
 void            gst_mini_object_weak_ref        (GstMiniObject *object,
                                                 GstMiniObjectNotify notify,
                                                 gpointer data);
+GST_API
 void            gst_mini_object_weak_unref     (GstMiniObject *object,
                                                 GstMiniObjectNotify notify,
                                                 gpointer data);
 
 /* locking */
+
+GST_API
 gboolean        gst_mini_object_lock            (GstMiniObject *object, GstLockFlags flags);
+
+GST_API
 void            gst_mini_object_unlock          (GstMiniObject *object, GstLockFlags flags);
 
+GST_API
 gboolean        gst_mini_object_is_writable     (const GstMiniObject *mini_object);
-GstMiniObject * gst_mini_object_make_writable  (GstMiniObject *mini_object);
+
+GST_API
+GstMiniObject * gst_mini_object_make_writable  (GstMiniObject *mini_object) G_GNUC_WARN_UNUSED_RESULT;
 
 /* copy */
-GstMiniObject * gst_mini_object_copy           (const GstMiniObject *mini_object) G_GNUC_MALLOC;
+
+GST_API
+GstMiniObject * gst_mini_object_copy           (const GstMiniObject *mini_object) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 
+GST_API
 void            gst_mini_object_set_qdata       (GstMiniObject *object, GQuark quark,
                                                  gpointer data, GDestroyNotify destroy);
+GST_API
 gpointer        gst_mini_object_get_qdata       (GstMiniObject *object, GQuark quark);
+
+GST_API
 gpointer        gst_mini_object_steal_qdata     (GstMiniObject *object, GQuark quark);
 
+GST_API
+void            gst_mini_object_add_parent      (GstMiniObject *object, GstMiniObject *parent);
+GST_API
+void            gst_mini_object_remove_parent   (GstMiniObject *object, GstMiniObject *parent);
 
+GST_API
 gboolean        gst_mini_object_replace         (GstMiniObject **olddata, GstMiniObject *newdata);
+
+GST_API
 gboolean        gst_mini_object_take            (GstMiniObject **olddata, GstMiniObject *newdata);
-GstMiniObject * gst_mini_object_steal           (GstMiniObject **olddata);
+
+GST_API
+GstMiniObject * gst_mini_object_steal           (GstMiniObject **olddata) G_GNUC_WARN_UNUSED_RESULT;
 
 /**
  * GST_DEFINE_MINI_OBJECT_TYPE: