From 3cc67ebab7f2c0f8aaa825d379c8a4b6b369ffdd Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 13 Nov 2008 18:09:45 +0000 Subject: [PATCH] gst/gstbuffer.c: Avoid costly typechecking for trivially correct pointers. Original commit message from CVS: * gst/gstbuffer.c: (gst_buffer_finalize): Avoid costly typechecking for trivially correct pointers. * gst/gstpoll.c: (gst_poll_wait): Add some G_LIKELY here and there. * libs/gst/base/gstadapter.c: (gst_adapter_push): Add some debug info. --- ChangeLog | 11 +++++++++++ gst/gstbuffer.c | 2 +- gst/gstpoll.c | 9 +++++---- libs/gst/base/gstadapter.c | 9 ++++++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0cafacced9..9f547c5314 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-11-13 Wim Taymans + + * gst/gstbuffer.c: (gst_buffer_finalize): + Avoid costly typechecking for trivially correct pointers. + + * gst/gstpoll.c: (gst_poll_wait): + Add some G_LIKELY here and there. + + * libs/gst/base/gstadapter.c: (gst_adapter_push): + Add some debug info. + 2008-11-13 Wim Taymans * docs/random/wtay/poll-timeout: diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 42b70f5bff..955e61f603 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -191,7 +191,7 @@ gst_buffer_finalize (GstBuffer * buffer) gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL); - GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (buffer)); + parent_class->finalize (GST_MINI_OBJECT_CAST (buffer)); } /** diff --git a/gst/gstpoll.c b/gst/gstpoll.c index 1c771b7253..4594a10b7d 100644 --- a/gst/gstpoll.c +++ b/gst/gstpoll.c @@ -1038,11 +1038,11 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) g_mutex_lock (set->lock); /* we cannot wait from multiple threads */ - if (set->waiting) + if (G_UNLIKELY (set->waiting)) goto already_waiting; /* flushing, exit immediatly */ - if (set->flushing) + if (G_UNLIKELY (set->flushing)) goto flushing; set->waiting = TRUE; @@ -1208,18 +1208,19 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) g_mutex_lock (set->lock); + /* FIXME, can we only do this check when (res > 0)? */ gst_poll_check_ctrl_commands (set, res, &restarting); /* update the controllable state if needed */ set->controllable = set->new_controllable; - if (set->flushing) { + if (G_UNLIKELY (set->flushing)) { /* we got woken up and we are flushing, we need to stop */ errno = EBUSY; res = -1; break; } - } while (restarting); + } while (G_UNLIKELY (restarting)); set->waiting = FALSE; diff --git a/libs/gst/base/gstadapter.c b/libs/gst/base/gstadapter.c index 2c572df4c7..f411a12a37 100644 --- a/libs/gst/base/gstadapter.c +++ b/libs/gst/base/gstadapter.c @@ -197,16 +197,23 @@ gst_adapter_clear (GstAdapter * adapter) void gst_adapter_push (GstAdapter * adapter, GstBuffer * buf) { + guint size; + g_return_if_fail (GST_IS_ADAPTER (adapter)); g_return_if_fail (GST_IS_BUFFER (buf)); - adapter->size += GST_BUFFER_SIZE (buf); + size = GST_BUFFER_SIZE (buf); + + adapter->size += size; /* Note: merging buffers at this point is premature. */ if (G_UNLIKELY (adapter->buflist == NULL)) { + GST_LOG_OBJECT (adapter, "pushing first %u bytes", size); adapter->buflist = adapter->buflist_end = g_slist_append (NULL, buf); } else { /* Otherwise append to the end, and advance our end pointer */ + GST_LOG_OBJECT (adapter, "pushing %u bytes at end, size now %u", size, + adapter->size); adapter->buflist_end = g_slist_append (adapter->buflist_end, buf); adapter->buflist_end = g_slist_next (adapter->buflist_end); }