mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
libs/gst/base/gstadapter.c: Make take_buffer a bit quicker by removing redundant checks caused by calling gst_adapter...
Original commit message from CVS: * libs/gst/base/gstadapter.c: (gst_adapter_take_buffer): Make take_buffer a bit quicker by removing redundant checks caused by calling gst_adapter_take.
This commit is contained in:
parent
df244cef04
commit
d3c98affb0
2 changed files with 17 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
|||
2007-03-29 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* libs/gst/base/gstadapter.c: (gst_adapter_take_buffer):
|
||||
Make take_buffer a bit quicker by removing redundant checks
|
||||
caused by calling gst_adapter_take.
|
||||
|
||||
2007-03-28 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* plugins/elements/gstmultiqueue.c: (gst_single_queue_free):
|
||||
|
|
|
@ -458,7 +458,6 @@ gst_adapter_take_buffer (GstAdapter * adapter, guint nbytes)
|
|||
{
|
||||
GstBuffer *buffer;
|
||||
GstBuffer *cur;
|
||||
guint8 *data;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ADAPTER (adapter), NULL);
|
||||
g_return_val_if_fail (nbytes > 0, NULL);
|
||||
|
@ -483,14 +482,18 @@ gst_adapter_take_buffer (GstAdapter * adapter, guint nbytes)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
data = gst_adapter_take (adapter, nbytes);
|
||||
if (data == NULL)
|
||||
return NULL;
|
||||
buffer = gst_buffer_new_and_alloc (nbytes);
|
||||
|
||||
buffer = gst_buffer_new ();
|
||||
GST_BUFFER_DATA (buffer) = data;
|
||||
GST_BUFFER_MALLOCDATA (buffer) = data;
|
||||
GST_BUFFER_SIZE (buffer) = nbytes;
|
||||
/* we have enough assembled data, copy from there */
|
||||
if (adapter->assembled_len >= nbytes) {
|
||||
GST_LOG_OBJECT (adapter, "taking %u bytes already assembled", nbytes);
|
||||
memcpy (GST_BUFFER_DATA (buffer), adapter->assembled_data, nbytes);
|
||||
} else {
|
||||
GST_LOG_OBJECT (adapter, "taking %u bytes by collection", nbytes);
|
||||
gst_adapter_peek_into (adapter, GST_BUFFER_DATA (buffer), nbytes);
|
||||
}
|
||||
|
||||
gst_adapter_flush (adapter, nbytes);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue