summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2005-09-22 09:30:41 +0000
committerAndy Wingo <wingo@pobox.com>2005-09-22 09:30:41 +0000
commit54a2e06698ec60e526832e7c0c4b26d82b5b6efd (patch)
treee696144088f606fd2b743f623d36fb615acd4b09
parentb907cd9815150164816ecf88dddd6d780d7869d3 (diff)
gst/gstbuffer.c (gst_buffer_get_caps): Like all our _get accessors returning refcounted objects, return a ref.
Original commit message from CVS: 2005-09-22 Andy Wingo <wingo@pobox.com> * gst/gstbuffer.c (gst_buffer_get_caps): Like all our _get accessors returning refcounted objects, return a ref. * check/gst/gstbuffer.c (GST_START_TEST): Use refcount-idempotent accessor for caps. IDEMPOTENCE. Oh yes.
-rw-r--r--ChangeLog8
-rw-r--r--check/gst/gstbuffer.c4
-rw-r--r--gst/gstbuffer.c17
-rw-r--r--tests/check/gst/gstbuffer.c4
4 files changed, 22 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d0501985..e0a2c32c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-09-22 Andy Wingo <wingo@pobox.com>
+
+ * gst/gstbuffer.c (gst_buffer_get_caps): Like all our _get
+ accessors returning refcounted objects, return a ref.
+
+ * check/gst/gstbuffer.c (GST_START_TEST): Use refcount-idempotent
+ accessor for caps. IDEMPOTENCE. Oh yes.
+
2005-09-21 Francis Labonte <francis_labonte at hotmail dot com>
Reviewed by: Tim-Philipp Müller <tim at centricular dot net>
diff --git a/check/gst/gstbuffer.c b/check/gst/gstbuffer.c
index 57912147f..eee5e182f 100644
--- a/check/gst/gstbuffer.c
+++ b/check/gst/gstbuffer.c
@@ -31,12 +31,12 @@ GST_START_TEST (test_caps)
caps = gst_caps_from_string ("audio/x-raw-int");
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
- fail_unless (gst_buffer_get_caps (buffer) == NULL);
+ fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
gst_buffer_set_caps (buffer, caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
- fail_unless (gst_buffer_get_caps (buffer) == caps);
+ fail_unless (GST_BUFFER_CAPS (buffer) == caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
caps2 = gst_caps_from_string ("audio/x-raw-float");
diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c
index 34887df49..ad7e73173 100644
--- a/gst/gstbuffer.c
+++ b/gst/gstbuffer.c
@@ -274,21 +274,24 @@ gst_buffer_new_and_alloc (guint size)
* is not media type attached to this buffer or when the media
* type is the same as the previous received buffer.
*
- * This function does not increment the refcount of the caps. The
- * caps pointer will therefore remain valid until the buffer is
- * unreffed.
- *
- * Returns: the #GstCaps, or NULL if there was an error or there
- * were no caps on this buffer.
+ * Returns: a reference to the #GstCaps, or NULL if there were no caps on this
+ * buffer.
*/
/* FIXME can we make this threadsafe without a lock on the buffer?
* We can use compare and swap and atomic reads. */
GstCaps *
gst_buffer_get_caps (GstBuffer * buffer)
{
+ GstCaps *ret;
+
g_return_val_if_fail (buffer != NULL, NULL);
- return GST_BUFFER_CAPS (buffer);
+ ret = GST_BUFFER_CAPS (buffer);
+
+ if (ret)
+ gst_caps_ref (ret);
+
+ return ret;
}
/**
diff --git a/tests/check/gst/gstbuffer.c b/tests/check/gst/gstbuffer.c
index 57912147f..eee5e182f 100644
--- a/tests/check/gst/gstbuffer.c
+++ b/tests/check/gst/gstbuffer.c
@@ -31,12 +31,12 @@ GST_START_TEST (test_caps)
caps = gst_caps_from_string ("audio/x-raw-int");
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
- fail_unless (gst_buffer_get_caps (buffer) == NULL);
+ fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
gst_buffer_set_caps (buffer, caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
- fail_unless (gst_buffer_get_caps (buffer) == caps);
+ fail_unless (GST_BUFFER_CAPS (buffer) == caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
caps2 = gst_caps_from_string ("audio/x-raw-float");