diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2011-05-17 11:45:46 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2011-05-17 11:45:46 +0200 |
commit | 50f91c0825af5390ab58d082d899f48af8c7c15e (patch) | |
tree | 5fe60e0b1edac5d3f15fb81bcd00bde891786226 /gst/gstevent.c | |
parent | b7482263ccb9fd34b8ec318e98eca3e239f65d97 (diff) | |
download | gstreamer-50f91c0825af5390ab58d082d899f48af8c7c15e.tar.gz |
Revert "event: example of how to optimize events"
This reverts commit fa28e2c5e6e5e172be308c0c50f44ed6f39e1a71.
The optimization only has minimal impact on the performance and
makes everything more complex.
Diffstat (limited to 'gst/gstevent.c')
-rw-r--r-- | gst/gstevent.c | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/gst/gstevent.c b/gst/gstevent.c index 35a6a42f43..18a3985131 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -89,26 +89,12 @@ GType _gst_event_type = 0; typedef struct { - GstQOSType type; - gdouble proportion; - gint64 diff; - GstClockTime timestamp; -} GstEventQOSData; - -typedef struct -{ GstEvent event; GstStructure *structure; - - union - { - GstEventQOSData qos; - }; } GstEventImpl; -#define GST_EVENT_STRUCTURE(e) (((GstEventImpl *)(e))->structure) -#define GST_EVENT_IMPL(e,data,field) (((GstEventImpl *)(e))->data.field) +#define GST_EVENT_STRUCTURE(e) (((GstEventImpl *)(e))->structure) typedef struct { @@ -236,25 +222,26 @@ _gst_event_free (GstEvent * event) g_slice_free1 (GST_MINI_OBJECT_SIZE (event), event); } +static void gst_event_init (GstEventImpl * event, gsize size, + GstEventType type); + static GstEvent * -_gst_event_copy (GstEventImpl * event) +_gst_event_copy (GstEvent * event) { GstEventImpl *copy; GstStructure *s; - copy = g_slice_dup (GstEventImpl, event); - gst_mini_object_init (GST_MINI_OBJECT_CAST (copy), _gst_event_type, - sizeof (GstEventImpl)); + copy = g_slice_new0 (GstEventImpl); + + gst_event_init (copy, sizeof (GstEventImpl), GST_EVENT_TYPE (event)); - GST_EVENT_TYPE (copy) = GST_EVENT_TYPE (event); GST_EVENT_TIMESTAMP (copy) = GST_EVENT_TIMESTAMP (event); GST_EVENT_SEQNUM (copy) = GST_EVENT_SEQNUM (event); s = GST_EVENT_STRUCTURE (event); if (s) { GST_EVENT_STRUCTURE (copy) = gst_structure_copy (s); - gst_structure_set_parent_refcount (GST_EVENT_STRUCTURE (copy), - ©->event.mini_object.refcount); + gst_structure_set_parent_refcount (s, ©->event.mini_object.refcount); } return GST_EVENT_CAST (copy); } @@ -858,6 +845,7 @@ gst_event_new_qos (GstQOSType type, gdouble proportion, GstClockTimeDiff diff, GstClockTime timestamp) { GstEvent *event; + GstStructure *structure; /* diff must be positive or timestamp + diff must be positive */ g_return_val_if_fail (diff >= 0 || -diff <= timestamp, NULL); @@ -867,12 +855,12 @@ gst_event_new_qos (GstQOSType type, gdouble proportion, ", timestamp %" GST_TIME_FORMAT, type, proportion, diff, GST_TIME_ARGS (timestamp)); - event = gst_event_new (GST_EVENT_QOS); - - GST_EVENT_IMPL (event, qos, type) = type; - GST_EVENT_IMPL (event, qos, proportion) = proportion; - GST_EVENT_IMPL (event, qos, diff) = diff; - GST_EVENT_IMPL (event, qos, timestamp) = timestamp; + structure = gst_structure_id_new (GST_QUARK (EVENT_QOS), + GST_QUARK (TYPE), GST_TYPE_QOS_TYPE, type, + GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion, + GST_QUARK (DIFF), G_TYPE_INT64, diff, + GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp, NULL); + event = gst_event_new_custom (GST_EVENT_QOS, structure); return event; } @@ -892,17 +880,28 @@ void gst_event_parse_qos (GstEvent * event, GstQOSType * type, gdouble * proportion, GstClockTimeDiff * diff, GstClockTime * timestamp) { + const GstStructure *structure; + g_return_if_fail (GST_IS_EVENT (event)); g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_QOS); + structure = GST_EVENT_STRUCTURE (event); if (type) - *type = GST_EVENT_IMPL (event, qos, type); + *type = + g_value_get_enum (gst_structure_id_get_value (structure, + GST_QUARK (TYPE))); if (proportion) - *proportion = GST_EVENT_IMPL (event, qos, proportion); + *proportion = + g_value_get_double (gst_structure_id_get_value (structure, + GST_QUARK (PROPORTION))); if (diff) - *diff = GST_EVENT_IMPL (event, qos, diff); + *diff = + g_value_get_int64 (gst_structure_id_get_value (structure, + GST_QUARK (DIFF))); if (timestamp) - *timestamp = GST_EVENT_IMPL (event, qos, timestamp); + *timestamp = + g_value_get_uint64 (gst_structure_id_get_value (structure, + GST_QUARK (TIMESTAMP))); } /** |