docs: gst: more gobject introspection annotations
[platform/upstream/gstreamer.git] / gst / gstbuffer.c
index fa9c412..871b34d 100644 (file)
@@ -237,7 +237,7 @@ gst_buffer_copy_metadata (GstBuffer * dest, const GstBuffer * src,
 
 #if GST_VERSION_NANO == 1
   /* we enable this extra debugging in git versions only for now */
-  g_return_if_fail (gst_buffer_is_metadata_writable (dest));
+  g_warn_if_fail (gst_buffer_is_metadata_writable (dest));
 #endif
 
   GST_CAT_LOG (GST_CAT_BUFFER, "copy %p to %p", src, dest);
@@ -283,8 +283,7 @@ _gst_buffer_copy (GstBuffer * buffer)
     if (G_LIKELY (buffer->size)) {
       if (G_UNLIKELY (!aligned_malloc (&memptr, buffer->size))) {
         /* terminate on error like g_memdup() would */
-        g_error ("%s: failed to allocate %" G_GSIZE_FORMAT " bytes",
-            G_STRLOC, buffer->size);
+        g_error ("%s: failed to allocate %u bytes", G_STRLOC, buffer->size);
       } else {
         memcpy (memptr, buffer->data, buffer->size);
       }
@@ -324,7 +323,8 @@ gst_buffer_init (GstBuffer * buffer)
  * Creates a newly allocated buffer without any data.
  *
  * MT safe.
- * Returns: the new #GstBuffer.
+ *
+ * Returns: (transfer full): the new #GstBuffer.
  */
 GstBuffer *
 gst_buffer_new (void)
@@ -353,7 +353,8 @@ gst_buffer_new (void)
  * Note that when @size == 0, the buffer data pointer will be NULL.
  *
  * MT safe.
- * Returns: the new #GstBuffer.
+ *
+ * Returns: (transfer full): the new #GstBuffer.
  */
 GstBuffer *
 gst_buffer_new_and_alloc (guint size)
@@ -369,8 +370,7 @@ gst_buffer_new_and_alloc (guint size)
     if (G_LIKELY (size)) {
       if (G_UNLIKELY (!aligned_malloc (&memptr, size))) {
         /* terminate on error like g_memdup() would */
-        g_error ("%s: failed to allocate %" G_GSIZE_FORMAT " bytes",
-            G_STRLOC, size);
+        g_error ("%s: failed to allocate %u bytes", G_STRLOC, size);
       }
     }
     newbuf->malloc_data = (guint8 *) memptr;
@@ -399,7 +399,8 @@ gst_buffer_new_and_alloc (guint size)
  *
  * MT safe.
  *
- * Returns: a new #GstBuffer, or NULL if the memory couldn't be allocated.
+ * Returns: (transfer full): a new #GstBuffer, or NULL if the memory couldn't
+ *     be allocated.
  *
  * Since: 0.10.13
  */
@@ -450,7 +451,7 @@ gst_buffer_try_new_and_alloc (guint size)
  * Gets the media type of the buffer. This can be NULL if there
  * is no media type attached to this buffer.
  *
- * Returns: a reference to the #GstCaps. unref after usage.
+ * Returns: (transfer full): a reference to the #GstCaps. unref after usage.
  * Returns NULL if there were no caps on this buffer.
  */
 /* this is not made atomic because if the buffer were reffed from multiple
@@ -474,7 +475,7 @@ gst_buffer_get_caps (GstBuffer * buffer)
 /**
  * gst_buffer_set_caps:
  * @buffer: a #GstBuffer.
- * @caps: a #GstCaps.
+ * @caps: (transfer none): a #GstCaps.
  *
  * Sets the media type on the buffer. The refcount of the caps will
  * be increased and any previous caps on the buffer will be
@@ -487,9 +488,12 @@ void
 gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps)
 {
   g_return_if_fail (buffer != NULL);
+  g_return_if_fail (caps == NULL || GST_CAPS_IS_SIMPLE (caps));
+
 #if GST_VERSION_NANO == 1
   /* we enable this extra debugging in git versions only for now */
-  g_return_if_fail (gst_buffer_is_metadata_writable (buffer));
+  g_warn_if_fail (gst_buffer_is_metadata_writable (buffer));
+  /* FIXME: would be nice to also check if caps are fixed here, but expensive */
 #endif
 
   gst_caps_replace (&GST_BUFFER_CAPS (buffer), caps);
@@ -513,7 +517,7 @@ gst_buffer_is_metadata_writable (GstBuffer * buf)
 
 /**
  * gst_buffer_make_metadata_writable:
- * @buf: a #GstBuffer
+ * @buf: (transfer full): a #GstBuffer
  *
  * Similar to gst_buffer_make_writable, but does not ensure that the buffer
  * data array is writable. Instead, this just ensures that the returned buffer
@@ -523,7 +527,8 @@ gst_buffer_is_metadata_writable (GstBuffer * buf)
  * After calling this function, @buf should not be referenced anymore. The
  * result of this function has guaranteed writable metadata.
  *
- * Returns: A new #GstBuffer with writable metadata.
+ * Returns: (transfer full): a new #GstBuffer with writable metadata, which
+ *     may or may not be the same as @buf.
  */
 GstBuffer *
 gst_buffer_make_metadata_writable (GstBuffer * buf)
@@ -560,8 +565,9 @@ gst_buffer_make_metadata_writable (GstBuffer * buf)
  * to #GST_CLOCK_TIME_NONE and #GST_BUFFER_OFFSET_NONE.
  *
  * MT safe.
- * Returns: the new #GstBuffer.
- * Returns NULL if the arguments were invalid.
+ *
+ * Returns: (transfer full): the new #GstBuffer or NULL if the arguments were
+ *     invalid.
  */
 GstBuffer *
 gst_buffer_create_sub (GstBuffer * buffer, guint offset, guint size)
@@ -571,7 +577,7 @@ gst_buffer_create_sub (GstBuffer * buffer, guint offset, guint size)
   gboolean complete;
 
   g_return_val_if_fail (buffer != NULL, NULL);
-  g_return_val_if_fail (buffer->mini_object.refcount > 0, NULL);
+  g_return_val_if_fail (buffer->mini_object.refcount, NULL);
   g_return_val_if_fail (buffer->size >= offset + size, NULL);
 
   /* find real parent */
@@ -651,8 +657,8 @@ gboolean
 gst_buffer_is_span_fast (GstBuffer * buf1, GstBuffer * buf2)
 {
   g_return_val_if_fail (buf1 != NULL && buf2 != NULL, FALSE);
-  g_return_val_if_fail (buf1->mini_object.refcount > 0, FALSE);
-  g_return_val_if_fail (buf2->mini_object.refcount > 0, FALSE);
+  g_return_val_if_fail (buf1->mini_object.refcount, FALSE);
+  g_return_val_if_fail (buf2->mini_object.refcount, FALSE);
 
   /* it's only fast if we have subbuffers of the same parent */
   return (GST_IS_SUBBUFFER (buf1) &&
@@ -679,8 +685,9 @@ gst_buffer_is_span_fast (GstBuffer * buf1, GstBuffer * buf2)
  * gst_buffer_is_span_fast() to determine if a memcpy will be needed.
  *
  * MT safe.
- * Returns: the new #GstBuffer that spans the two source buffers.
- * Returns NULL if the arguments are invalid.
+ *
+ * Returns: (transfer full): the new #GstBuffer that spans the two source
+ *     buffers, or NULL if the arguments are invalid.
  */
 GstBuffer *
 gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
@@ -689,9 +696,9 @@ gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
   GstBuffer *newbuf;
 
   g_return_val_if_fail (buf1 != NULL && buf2 != NULL, NULL);
-  g_return_val_if_fail (buf1->mini_object.refcount > 0, NULL);
-  g_return_val_if_fail (buf2->mini_object.refcount > 0, NULL);
-  g_return_val_if_fail (len > 0, NULL);
+  g_return_val_if_fail (buf1->mini_object.refcount, NULL);
+  g_return_val_if_fail (buf2->mini_object.refcount, NULL);
+  g_return_val_if_fail (len, NULL);
   g_return_val_if_fail (len <= buf1->size + buf2->size - offset, NULL);
 
   /* if the two buffers have the same parent and are adjacent */