Commit 56a33641 authored by Wim Taymans's avatar Wim Taymans

messages: make message a simple boxed type

parent fda9686b
This diff is collapsed.
......@@ -28,7 +28,7 @@ G_BEGIN_DECLS
#define GST_TYPE_CAPS (gst_caps_get_type())
#define GST_CAPS(object) ((GstCaps*)object)
#define GST_IS_CAPS(object) ((object) && (GST_CAPS(object)->type == GST_TYPE_CAPS))
#define GST_IS_CAPS(object) ((object) && (GST_MINI_OBJECT_TYPE(object) == GST_TYPE_CAPS))
#define GST_TYPE_STATIC_CAPS (gst_static_caps_get_type())
......@@ -125,29 +125,99 @@ typedef struct _GstStaticCaps GstStaticCaps;
/**
* GST_CAPS_FLAG_IS_SET:
* @caps: a #GstBuffer.
* @flag: the #GstBufferFlag to check.
* @caps: a #GstCaps.
* @flag: the #GstCapsFlag to check.
*
* Gives the status of a specific flag on a caps.
*/
#define GST_CAPS_FLAG_IS_SET(caps,flag) GST_MINI_OBJECT_FLAG_IS_SET (caps, flag)
/**
* GST_CAPS_FLAG_SET:
* @caps: a #GstBuffer.
* @flag: the #GstBufferFlag to set.
* @caps: a #GstCaps.
* @flag: the #GstCapsFlag to set.
*
* Sets a caps flag on a caps.
*/
#define GST_CAPS_FLAG_SET(caps,flag) GST_MINI_OBJECT_FLAG_SET (caps, flag)
/**
* GST_CAPS_FLAG_UNSET:
* @caps: a #GstBuffer.
* @flag: the #GstBufferFlag to clear.
* @caps: a #GstCaps.
* @flag: the #GstCapsFlag to clear.
*
* Clears a caps flag.
*/
#define GST_CAPS_FLAG_UNSET(caps,flag) GST_MINI_OBJECT_FLAG_UNSET (caps, flag)
/* refcounting */
/**
* gst_caps_ref:
* @caps: the #GstCaps to reference
*
* Add a reference to a #GstCaps object.
*
* From this point on, until the caller calls gst_caps_unref() or
* gst_caps_make_writable(), it is guaranteed that the caps object will not
* change. This means its structures won't change, etc. To use a #GstCaps
* object, you must always have a refcount on it -- either the one made
* implicitly by e.g. gst_caps_new_simple(), or via taking one explicitly with
* this function.
*
* Returns: the same #GstCaps object.
*/
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC GstCaps * gst_caps_ref (GstCaps * caps);
#endif
static inline GstCaps *
gst_caps_ref (GstCaps * caps)
{
return (GstCaps *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (caps));
}
/**
* gst_caps_unref:
* @caps: a #GstCaps.
*
* Unref a #GstCaps and and free all its structures and the
* structures' values when the refcount reaches 0.
*/
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC void gst_caps_unref (GstCaps * caps);
#endif
static inline void
gst_caps_unref (GstCaps * caps)
{
gst_mini_object_unref (GST_MINI_OBJECT_CAST (caps));
}
/* copy caps */
/**
* gst_caps_copy:
* @caps: a #GstCaps.
*
* Creates a new #GstCaps as a copy of the old @caps. The new caps will have a
* refcount of 1, owned by the caller. The structures are copied as well.
*
* Note that this function is the semantic equivalent of a gst_caps_ref()
* followed by a gst_caps_make_writable(). If you only want to hold on to a
* reference to the data, you should use gst_caps_ref().
*
* When you are finished with the caps, call gst_caps_unref() on it.
*
* Returns: the new #GstCaps
*/
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC GstCaps * gst_caps_copy (const GstCaps * caps);
#endif
static inline GstCaps *
gst_caps_copy (const GstCaps * caps)
{
return GST_CAPS (gst_mini_object_copy (GST_MINI_OBJECT_CAST (caps)));
}
/**
* GstCaps:
* @mini_object: the parent type
......@@ -193,10 +263,7 @@ GstCaps * gst_caps_new_full_valist (GstStructure *structure,
va_list var_args);
/* reference counting */
GstCaps * gst_caps_ref (GstCaps *caps);
GstCaps * gst_caps_copy (const GstCaps *caps);
GstCaps * gst_caps_make_writable (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT;
void gst_caps_unref (GstCaps *caps);
GstCaps * gst_caps_make_writable (GstCaps *caps);
GType gst_static_caps_get_type (void);
GstCaps * gst_static_caps_get (GstStaticCaps *static_caps);
......
......@@ -163,7 +163,7 @@ gst_element_factory_cleanup (GstElementFactory * factory)
GstCaps *caps = (GstCaps *) & (templ->static_caps);
/* FIXME: this is not threadsafe */
if (caps->refcount == 1) {
if (GST_CAPS_REFCOUNT_VALUE (caps) == 1) {
GstStructure *structure;
guint i;
......@@ -173,7 +173,7 @@ gst_element_factory_cleanup (GstElementFactory * factory)
gst_structure_free (structure);
}
g_ptr_array_free (caps->structs, TRUE);
caps->refcount = 0;
GST_CAPS_REFCOUNT (caps) = 0;
}
g_slice_free (GstStaticPadTemplate, templ);
}
......
......@@ -85,10 +85,7 @@
#include "gstutils.h"
#include "gstquark.h"
static void gst_event_finalize (GstEvent * event);
static GstEvent *_gst_event_copy (GstEvent * event);
static GstMiniObjectClass *parent_class = NULL;
static GType _gst_event_type = 0;
void
_gst_event_initialize (void)
......@@ -195,26 +192,19 @@ gst_event_type_get_flags (GstEventType type)
} \
}
G_DEFINE_TYPE_WITH_CODE (GstEvent, gst_event, GST_TYPE_MINI_OBJECT, _do_init);
static void
gst_event_class_init (GstEventClass * klass)
GType
gst_event_get_type (void)
{
parent_class = g_type_class_peek_parent (klass);
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
klass->mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_event_finalize;
}
if (G_UNLIKELY (_gst_event_type == 0)) {
_gst_event_type = gst_mini_object_register ("GstEvent");
}
static void
gst_event_init (GstEvent * event)
{
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
return _gst_event_type;
}
static void
gst_event_finalize (GstEvent * event)
_gst_event_free (GstEvent * event)
{
g_return_if_fail (event != NULL);
g_return_if_fail (GST_IS_EVENT (event));
......@@ -231,7 +221,7 @@ gst_event_finalize (GstEvent * event)
gst_structure_free (event->structure);
}
/* GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (event)); */
g_slice_free (GstEvent, event);
}
static GstEvent *
......@@ -239,7 +229,12 @@ _gst_event_copy (GstEvent * event)
{
GstEvent *copy;
copy = (GstEvent *) gst_mini_object_new (GST_TYPE_EVENT);
copy = g_slice_new0 (GstEvent);
gst_mini_object_init (GST_MINI_OBJECT_CAST (copy),
_gst_event_type, sizeof (GstEvent));
event->mini_object.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
event->mini_object.free = (GstMiniObjectFreeFunction) _gst_event_free;
GST_EVENT_TYPE (copy) = GST_EVENT_TYPE (event);
GST_EVENT_TIMESTAMP (copy) = GST_EVENT_TIMESTAMP (event);
......@@ -261,14 +256,18 @@ gst_event_new (GstEventType type)
{
GstEvent *event;
event = (GstEvent *) gst_mini_object_new (GST_TYPE_EVENT);
event = g_slice_new0 (GstEvent);
GST_CAT_DEBUG (GST_CAT_EVENT, "creating new event %p %s %d", event,
gst_event_type_get_name (type), type);
event->type = type;
event->src = NULL;
event->structure = NULL;
gst_mini_object_init (GST_MINI_OBJECT_CAST (event),
_gst_event_type, sizeof (GstEvent));
event->mini_object.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
event->mini_object.free = (GstMiniObjectFreeFunction) _gst_event_free;
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
GST_EVENT_SEQNUM (event) = gst_util_seqnum_next ();
return event;
......@@ -1295,6 +1294,6 @@ gst_event_parse_sink_message (GstEvent * event, GstMessage ** msg)
if (msg)
*msg =
GST_MESSAGE (gst_value_dup_mini_object (gst_structure_id_get_value
(event->structure, GST_QUARK (MESSAGE))));
GST_MESSAGE (g_value_dup_boxed (gst_structure_id_get_value
(structure, GST_QUARK (MESSAGE))));
}
......@@ -159,11 +159,8 @@ typedef enum {
typedef struct _GstEvent GstEvent;
#define GST_TYPE_EVENT (gst_event_get_type())
#define GST_IS_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EVENT))
#define GST_IS_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EVENT))
#define GST_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EVENT, GstEventClass))
#define GST_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EVENT, GstEvent))
#define GST_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EVENT, GstEventClass))
#define GST_IS_EVENT(obj) ((obj) && GST_MINI_OBJECT_TYPE (obj) == GST_TYPE_EVENT)
#define GST_EVENT(obj) ((GstEvent *)(obj))
#define GST_EVENT_CAST(obj) ((GstEvent *)(obj))
/**
......
......@@ -63,8 +63,6 @@
static void gst_message_finalize (GstMessage * message);
static GstMessage *_gst_message_copy (GstMessage * message);
static GstMiniObjectClass *parent_class = NULL;
void
_gst_message_initialize (void)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment