From: Edward Hervey Date: Mon, 11 Nov 2013 12:27:27 +0000 (+0100) Subject: queue: Don't use gst_buffer_get_size() when possible X-Git-Tag: 1.3.1~334 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74a1970101347bda400ba16ebb563d461a3b2dce;p=platform%2Fupstream%2Fgstreamer.git queue: Don't use gst_buffer_get_size() when possible Makes qst_queue_locked_dequeue 20% faster --- diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index eb50c13..440c04e 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -223,6 +223,7 @@ typedef struct { gboolean is_query; GstMiniObject *item; + gsize size; } GstQueueItem; #define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ()) @@ -620,16 +621,18 @@ static inline void gst_queue_locked_enqueue_buffer (GstQueue * queue, gpointer item) { GstBuffer *buffer = GST_BUFFER_CAST (item); + gsize bsize = gst_buffer_get_size (buffer); /* add buffer to the statistics */ queue->cur_level.buffers++; - queue->cur_level.bytes += gst_buffer_get_size (buffer); + queue->cur_level.bytes += bsize; apply_buffer (queue, buffer, &queue->sink_segment, TRUE, TRUE); if (item) { GstQueueItem *qitem = g_slice_new (GstQueueItem); qitem->item = item; qitem->is_query = FALSE; + qitem->size = bsize; gst_queue_array_push_tail (queue->queue, qitem); } GST_QUEUE_SIGNAL_ADD (queue); @@ -683,12 +686,14 @@ gst_queue_locked_dequeue (GstQueue * queue) { GstQueueItem *qitem; GstMiniObject *item; + gsize bufsize; qitem = gst_queue_array_pop_head (queue->queue); if (qitem == NULL) goto no_item; item = qitem->item; + bufsize = qitem->size; g_slice_free (GstQueueItem, qitem); if (GST_IS_BUFFER (item)) { @@ -698,7 +703,7 @@ gst_queue_locked_dequeue (GstQueue * queue) "retrieved buffer %p from queue", buffer); queue->cur_level.buffers--; - queue->cur_level.bytes -= gst_buffer_get_size (buffer); + queue->cur_level.bytes -= bufsize; apply_buffer (queue, buffer, &queue->src_segment, TRUE, FALSE); /* if the queue is empty now, update the other side */