buffer: invert meaning of GST_BUFFER_FLAG_TAG_MEMORY

It's nicer to only have it set when something noteworthy
happened and otherwise unset.

https://bugzilla.gnome.org/show_bug.cgi?id=725862
This commit is contained in:
Tim-Philipp Müller 2014-03-07 20:43:44 +00:00
parent 7077d347a3
commit 313f01ab79
4 changed files with 18 additions and 17 deletions

View file

@ -283,7 +283,7 @@ _replace_memory (GstBuffer * buffer, guint len, guint idx, guint length,
&GST_BUFFER_MEM_PTR (buffer, end), (len - end) * sizeof (gpointer));
}
GST_BUFFER_MEM_LEN (buffer) = len - length;
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
static inline void
@ -319,7 +319,7 @@ _memory_add (GstBuffer * buffer, gint idx, GstMemory * mem, gboolean lock)
GST_BUFFER_MEM_PTR (buffer, idx) = mem;
GST_BUFFER_MEM_LEN (buffer) = len + 1;
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
GST_DEFINE_MINI_OBJECT_TYPE (GstBuffer, gst_buffer);
@ -519,7 +519,7 @@ _gst_buffer_copy (GstBuffer * buffer)
if (!gst_buffer_copy_into (copy, buffer, GST_BUFFER_COPY_ALL, 0, -1))
gst_buffer_replace (&copy, NULL);
GST_BUFFER_FLAG_SET (copy, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_UNSET (copy, GST_BUFFER_FLAG_TAG_MEMORY);
return copy;
}
@ -725,7 +725,7 @@ gst_buffer_new_allocate (GstAllocator * allocator, gsize size,
if (size > 0)
_memory_add (newbuf, -1, gst_memory_ref (mem), TRUE);
#endif
GST_BUFFER_FLAG_SET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_UNSET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
return newbuf;
@ -772,7 +772,7 @@ gst_buffer_new_wrapped_full (GstMemoryFlags flags, gpointer data,
gst_memory_new_wrapped (flags, data, maxsize, offset, size, user_data,
notify);
_memory_add (newbuf, -1, mem, TRUE);
GST_BUFFER_FLAG_SET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_UNSET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
return newbuf;
}
@ -887,7 +887,7 @@ _get_mapped (GstBuffer * buffer, guint idx, GstMapInfo * info,
GST_BUFFER_MEM_PTR (buffer, idx) = mapped;
/* unlock old memory */
gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
gst_memory_unref (mem);
@ -1460,7 +1460,7 @@ gst_buffer_resize_range (GstBuffer * buffer, guint idx, gint length,
gst_memory_unref (mem);
}
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
offset = noffs;
@ -1920,7 +1920,7 @@ gst_buffer_append_region (GstBuffer * buf1, GstBuffer * buf2, gssize offset,
}
GST_BUFFER_MEM_LEN (buf2) = 0;
GST_BUFFER_FLAG_UNSET (buf2, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_TAG_MEMORY);
gst_buffer_unref (buf2);
return buf1;

View file

@ -192,7 +192,7 @@ typedef struct _GstBufferPool GstBufferPool;
* @GST_BUFFER_FLAG_DROPPABLE: the buffer can be dropped without breaking the
* stream, for example to reduce bandwidth.
* @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently.
* @GST_BUFFER_FLAG_TAG_MEMORY: this flag is cleared when the memory of the buffer
* @GST_BUFFER_FLAG_TAG_MEMORY: this flag is set when memory of the buffer
* is added/removed
* @GST_BUFFER_FLAG_LAST: additional media specific flags can be added starting from
* this flag.

View file

@ -274,9 +274,10 @@ do_alloc_buffer (GstBufferPool * pool, GstBuffer ** buffer,
* the buffer and we want to remove any other metadata that gets added
* later */
gst_buffer_foreach_meta (*buffer, mark_meta_pooled, pool);
/* tag memory, this is how we expect the buffer when it is
/* un-tag memory, this is how we expect the buffer when it is
* released again */
GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_TAG_MEMORY);
GST_BUFFER_FLAG_UNSET (*buffer, GST_BUFFER_FLAG_TAG_MEMORY);
GST_LOG_OBJECT (pool, "allocated buffer %d/%d, %p", cur_buffers,
max_buffers, buffer);
@ -1136,7 +1137,7 @@ default_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
GST_MINI_OBJECT_FLAGS (buffer));
/* memory should be untouched */
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY))
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY))
goto discard;
/* all memory should be exclusive to this buffer (and thus be writable) */

View file

@ -132,18 +132,18 @@ struct _GstBufferPool {
* buffers from the configured memory allocator and with the configured
* parameters. All metadata that is present on the allocated buffer will
* be marked as #GST_META_FLAG_POOLED and #GST_META_FLAG_LOCKED and will
* not be removed from the buffer in @reset_buffer. Memory will be marked
* with GST_BUFFER_FLAG_TAG_MEMORY.
* not be removed from the buffer in @reset_buffer. The buffer should
* have the GST_BUFFER_FLAG_TAG_MEMORY cleared.
* @reset_buffer: reset the buffer to its state when it was freshly allocated.
* The default implementation will clear the flags, timestamps and
* will remove the metadata without the #GST_META_FLAG_POOLED flag (even
* the metadata with #GST_META_FLAG_LOCKED). If the
* #GST_BUFFER_FLAG_TAG_MEMORY was removed, this function can also try to
* restore the memory and set the #GST_BUFFER_FLAG_TAG_MEMORY again.
* #GST_BUFFER_FLAG_TAG_MEMORY was set, this function can also try to
* restore the memory and clear the #GST_BUFFER_FLAG_TAG_MEMORY again.
* @release_buffer: release a buffer back in the pool. The default
* implementation will put the buffer back in the queue and notify any
* blocking acquire_buffer calls when the #GST_BUFFER_FLAG_TAG_MEMORY
* is set on the buffer. If #GST_BUFFER_FLAG_TAG_MEMORY is not set, the
* is not set on the buffer. If #GST_BUFFER_FLAG_TAG_MEMORY is set, the
* buffer will be freed with @free_buffer.
* @free_buffer: free a buffer. The default implementation unrefs the buffer.
*