summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2009-09-28 15:41:52 +0200
committerEdward Hervey <bilboed@bilboed.com>2009-10-07 09:15:13 +0200
commitd28a3e743502d64c2a96bdb637043d6df0589009 (patch)
treef175a482fdc25681a848bdebe8a8ae0031466be7 /plugins
parent9be7fdc8574724d8a2ec3f24cd24adde82de2414 (diff)
plugins/queue: Use previous knowledge of data type to avoid typecheck.
We know whether we have a buffer or an event, use that instead of going trough the expensive GLib typecheck. The overall instruction fetch reduction introduced by this commit and the 2 previous commits: * receiving a buffer (_chain) by 20% * popping a buffer (_loop) by 14% Numbers acquired through callgrind passing 100000 buffers through queue.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/elements/gstqueue.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c
index 9aa4aa414a..4090da8bd5 100644
--- a/plugins/elements/gstqueue.c
+++ b/plugins/elements/gstqueue.c
@@ -655,10 +655,10 @@ gst_queue_locked_flush (GstQueue * queue)
}
/* enqueue an item an update the level stats, with QUEUE_LOCK */
-static void
-gst_queue_locked_enqueue (GstQueue * queue, gpointer item)
+static inline void
+gst_queue_locked_enqueue (GstQueue * queue, gpointer item, gboolean isbuffer)
{
- if (GST_IS_BUFFER (item)) {
+ if (isbuffer) {
GstBuffer *buffer = GST_BUFFER_CAST (item);
/* add buffer to the statistics */
@@ -674,7 +674,7 @@ gst_queue_locked_enqueue (GstQueue * queue, gpointer item)
* See #482147 */
/* if (queue->cur_level.buffers == 1) */
/* apply_buffer (queue, buffer, &queue->src_segment, FALSE); */
- } else if (GST_IS_EVENT (item)) {
+ } else {
GstEvent *event = GST_EVENT_CAST (item);
switch (GST_EVENT_TYPE (event)) {
@@ -695,11 +695,6 @@ gst_queue_locked_enqueue (GstQueue * queue, gpointer item)
default:
break;
}
- } else {
- g_warning ("Unexpected item %p added in queue %s (refcounting problem?)",
- item, GST_OBJECT_NAME (queue));
- /* we can't really unref since we don't know what it is */
- item = NULL;
}
if (item)
@@ -822,7 +817,7 @@ gst_queue_handle_sink_event (GstPad * pad, GstEvent * event)
/* refuse more events on EOS */
if (queue->eos)
goto out_eos;
- gst_queue_locked_enqueue (queue, event);
+ gst_queue_locked_enqueue (queue, event, FALSE);
GST_QUEUE_MUTEX_UNLOCK (queue);
} else {
/* non-serialized events are passed upstream. */
@@ -986,7 +981,7 @@ gst_queue_chain (GstPad * pad, GstBuffer * buffer)
}
/* put buffer in queue now */
- gst_queue_locked_enqueue (queue, buffer);
+ gst_queue_locked_enqueue (queue, buffer, TRUE);
GST_QUEUE_MUTEX_UNLOCK (queue);
return GST_FLOW_OK;