mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-24 13:00:36 +00:00
Also handle READONLY buffers in the copy_on_write function
Original commit message from CVS: Also handle READONLY buffers in the copy_on_write function
This commit is contained in:
parent
12fddba0bd
commit
c2a0080f90
3 changed files with 16 additions and 9 deletions
|
@ -61,8 +61,8 @@ extern GType _gst_buffer_pool_type;
|
||||||
#define GST_BUFFER_POOL_PRIVATE(buf) (GST_BUFFER(buf)->pool_private)
|
#define GST_BUFFER_POOL_PRIVATE(buf) (GST_BUFFER(buf)->pool_private)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GST_BUFFER_READONLY = GST_DATA_FLAG_LAST,
|
GST_BUFFER_READONLY = GST_DATA_READONLY,
|
||||||
GST_BUFFER_SUBBUFFER,
|
GST_BUFFER_SUBBUFFER = GST_DATA_FLAG_LAST,
|
||||||
GST_BUFFER_ORIGINAL,
|
GST_BUFFER_ORIGINAL,
|
||||||
GST_BUFFER_DONTFREE,
|
GST_BUFFER_DONTFREE,
|
||||||
GST_BUFFER_DISCONTINOUS,
|
GST_BUFFER_DISCONTINOUS,
|
||||||
|
|
|
@ -79,7 +79,9 @@ gst_data_dispose (GstData *data)
|
||||||
* Copies the given #GstData. This function will call the custom subclass
|
* Copies the given #GstData. This function will call the custom subclass
|
||||||
* copy function or return NULL if no function was provided by the subclass.
|
* copy function or return NULL if no function was provided by the subclass.
|
||||||
*
|
*
|
||||||
* Returns: a copy of the data or NULL if the data cannot be copied.
|
* Returns: a copy of the data or NULL if the data cannot be copied. The refcount
|
||||||
|
* of the original buffer is not changed so you should unref it when you don't
|
||||||
|
* need it anymore.
|
||||||
*/
|
*/
|
||||||
GstData*
|
GstData*
|
||||||
gst_data_copy (const GstData *data)
|
gst_data_copy (const GstData *data)
|
||||||
|
@ -98,20 +100,25 @@ gst_data_copy (const GstData *data)
|
||||||
* #GstData object can be written to safely.
|
* #GstData object can be written to safely.
|
||||||
*
|
*
|
||||||
* Returns: a copy of the data if the refcount is > 1, data if the refcount == 1
|
* Returns: a copy of the data if the refcount is > 1, data if the refcount == 1
|
||||||
* or NULL if the data could not be copied.
|
* or NULL if the data could not be copied. The refcount of the original buffer
|
||||||
|
* is decreased when a copy is made, so you are not supposed to use it after a
|
||||||
|
* call to this function.
|
||||||
*/
|
*/
|
||||||
GstData*
|
GstData*
|
||||||
gst_data_copy_on_write (const GstData *data)
|
gst_data_copy_on_write (GstData *data)
|
||||||
{
|
{
|
||||||
gint refcount;
|
gint refcount;
|
||||||
|
|
||||||
GST_ATOMIC_INT_READ (&data->refcount, &refcount);
|
GST_ATOMIC_INT_READ (&data->refcount, &refcount);
|
||||||
|
|
||||||
if (refcount == 1)
|
if (refcount == 1 && !GST_DATA_FLAG_IS_SET (data, GST_DATA_READONLY))
|
||||||
return GST_DATA (data);
|
return GST_DATA (data);
|
||||||
|
|
||||||
if (data->copy)
|
if (data->copy) {
|
||||||
return data->copy (data);
|
GstData *copy = data->copy (data);
|
||||||
|
gst_data_unref (data);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ void gst_data_copy_into (const GstData *data, GstData *target);
|
||||||
|
|
||||||
/* basic operations on data */
|
/* basic operations on data */
|
||||||
GstData* gst_data_copy (const GstData *data);
|
GstData* gst_data_copy (const GstData *data);
|
||||||
GstData* gst_data_copy_on_write (const GstData *data);
|
GstData* gst_data_copy_on_write (GstData *data);
|
||||||
void gst_data_free (GstData *data);
|
void gst_data_free (GstData *data);
|
||||||
|
|
||||||
/* reference counting */
|
/* reference counting */
|
||||||
|
|
Loading…
Reference in a new issue