summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-05-02 14:33:01 +0200
committerWim Taymans <wim@metal.(none)>2009-05-11 22:35:08 +0200
commit54401df78c138e1dcf90b984978dd785416d1f1a (patch)
tree3da1e284b54c650ce51d98a4ae6a33d32da2bf18
parent20d2734a25cd435a11d32aa050fba5d7bee7684f (diff)
gstobject: add gst_object_ref_sink
Add the gst_object_ref_sink() method to match the glib one. API: GstObject::gst_object_ref_sink()
-rw-r--r--docs/gst/gstreamer-sections.txt1
-rw-r--r--gst/gstobject.c33
-rw-r--r--gst/gstobject.h1
-rw-r--r--win32/common/libgstreamer.def1
4 files changed, 36 insertions, 0 deletions
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index eb28680fc6..789ef4f456 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -1214,6 +1214,7 @@ gst_object_save_thyself
gst_object_restore_thyself
gst_object_ref
gst_object_unref
+gst_object_ref_sink
gst_object_sink
gst_object_replace
gst_object_get_path_string
diff --git a/gst/gstobject.c b/gst/gstobject.c
index 701c3eb787..ef0a86bb43 100644
--- a/gst/gstobject.c
+++ b/gst/gstobject.c
@@ -327,6 +327,39 @@ gst_object_unref (gpointer object)
}
/**
+ * gst_object_ref_sink:
+ * @object: a #GstObject to sink
+ *
+ * Increase the reference count of @object, and possibly remove the floating
+ * reference, if @object has a floating reference.
+ *
+ * In other words, if the object is floating, then this call "assumes ownership"
+ * of the floating reference, converting it to a normal reference by clearing
+ * 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.
+ *
+ * MT safe. This function grabs and releases @object lock.
+ *
+ * Since: 0.10.24
+ */
+void
+gst_object_ref_sink (gpointer object)
+{
+ g_return_if_fail (GST_IS_OBJECT (object));
+
+ GST_OBJECT_LOCK (object);
+ if (G_LIKELY (GST_OBJECT_IS_FLOATING (object))) {
+ GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "unsetting floating flag");
+ GST_OBJECT_FLAG_UNSET (object, GST_OBJECT_FLOATING);
+ GST_OBJECT_UNLOCK (object);
+ } else {
+ GST_OBJECT_UNLOCK (object);
+ gst_object_ref (object);
+ }
+}
+
+/**
* gst_object_sink:
* @object: a #GstObject to sink
*
diff --git a/gst/gstobject.h b/gst/gstobject.h
index f49a727ade..5d7a50bdb8 100644
--- a/gst/gstobject.h
+++ b/gst/gstobject.h
@@ -290,6 +290,7 @@ void gst_object_default_deep_notify (GObject *object, GstObject *ori
/* refcounting + life cycle */
gpointer gst_object_ref (gpointer object);
void gst_object_unref (gpointer object);
+void gst_object_ref_sink (gpointer object);
void gst_object_sink (gpointer object);
/* replace object pointer */
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index 0840222816..339f2e6a7e 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -511,6 +511,7 @@ EXPORTS
gst_object_get_type
gst_object_has_ancestor
gst_object_ref
+ gst_object_ref_sink
gst_object_replace
gst_object_restore_thyself
gst_object_save_thyself