From 0bfbce44638949e53983beda930dd05219be60e7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 11 May 2011 12:04:43 +0200 Subject: [PATCH] event: clean up some macros Avoid executing a method for GST_TYPE_EVENT but instead use the type variable directly. We can do this because we register it before anything else. --- gst/gstevent.c | 14 +++----------- gst/gstevent.h | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/gst/gstevent.c b/gst/gstevent.c index b573cf0..af0cf02 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -85,7 +85,7 @@ #include "gstutils.h" #include "gstquark.h" -static GType _gst_event_type = 0; +GType _gst_event_type = 0; typedef struct { @@ -147,7 +147,8 @@ _gst_event_initialize (void) { gint i; - gst_event_get_type (); + _gst_event_type = gst_mini_object_register ("GstEvent"); + g_type_class_ref (gst_seek_flags_get_type ()); g_type_class_ref (gst_seek_type_get_type ()); @@ -214,15 +215,6 @@ gst_event_type_get_flags (GstEventType type) return ret; } -GType -gst_event_get_type (void) -{ - if (G_UNLIKELY (_gst_event_type == 0)) { - _gst_event_type = gst_mini_object_register ("GstEvent"); - } - return _gst_event_type; -} - static void _gst_event_free (GstEvent * event) { diff --git a/gst/gstevent.h b/gst/gstevent.h index 8d49477..f3522eb 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -34,6 +34,22 @@ G_BEGIN_DECLS +extern GType _gst_event_type; + +typedef struct _GstEvent GstEvent; + +#define GST_TYPE_EVENT (_gst_event_type) +#define GST_IS_EVENT(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_EVENT)) +#define GST_EVENT_CAST(obj) ((GstEvent *)(obj)) +#define GST_EVENT(obj) (GST_EVENT_CAST(obj)) + +/** + * GST_EVENT_TRACE_NAME: + * + * The name used for memory allocation tracing + */ +#define GST_EVENT_TRACE_NAME "GstEvent" + /** * GstEventTypeFlags: * @GST_EVENT_TYPE_UPSTREAM: Set if the event can travel upstream. @@ -164,20 +180,6 @@ typedef enum { #undef FLAG /** - * GST_EVENT_TRACE_NAME: - * - * The name used for memory allocation tracing - */ -#define GST_EVENT_TRACE_NAME "GstEvent" - -typedef struct _GstEvent GstEvent; - -#define GST_TYPE_EVENT (gst_event_get_type()) -#define GST_IS_EVENT(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_EVENT)) -#define GST_EVENT(obj) ((GstEvent *)(obj)) -#define GST_EVENT_CAST(obj) ((GstEvent *)(obj)) - -/** * GST_EVENT_TYPE: * @event: the event to query * @@ -396,8 +398,6 @@ GstEventTypeFlags gst_event_type_get_flags (GstEventType type); -GType gst_event_get_type (void); - /* refcounting */ /** * gst_event_ref: -- 2.7.4