mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
messages: make message a simple boxed type
This commit is contained in:
parent
fda9686b35
commit
56a3364183
6 changed files with 160 additions and 184 deletions
191
gst/gstcaps.c
191
gst/gstcaps.c
|
@ -77,7 +77,7 @@
|
|||
|
||||
#define CAPS_POISON(caps) G_STMT_START{ \
|
||||
if (caps) { \
|
||||
GstCaps *_newcaps = gst_caps_copy (caps); \
|
||||
GstCaps *_newcaps = _gst_caps_copy (caps); \
|
||||
gst_caps_unref(caps); \
|
||||
caps = _newcaps; \
|
||||
} \
|
||||
|
@ -90,11 +90,11 @@
|
|||
} \
|
||||
} G_STMT_END
|
||||
#define IS_WRITABLE(caps) \
|
||||
(g_atomic_int_get (&(caps)->refcount) == 1)
|
||||
(GST_CAPS_REFCOUNT_VALUE (caps) == 1)
|
||||
|
||||
/* same as gst_caps_is_any () */
|
||||
#define CAPS_IS_ANY(caps) \
|
||||
((caps)->flags & GST_CAPS_FLAGS_ANY)
|
||||
(GST_CAPS_FLAGS(caps) & GST_CAPS_FLAGS_ANY)
|
||||
|
||||
/* same as gst_caps_is_empty () */
|
||||
#define CAPS_IS_EMPTY(caps) \
|
||||
|
@ -121,7 +121,6 @@ static void gst_caps_transform_to_string (const GValue * src_value,
|
|||
GValue * dest_value);
|
||||
static gboolean gst_caps_from_string_inplace (GstCaps * caps,
|
||||
const gchar * string);
|
||||
static GstCaps *gst_caps_copy_conditional (GstCaps * src);
|
||||
|
||||
GType
|
||||
gst_caps_get_type (void)
|
||||
|
@ -129,9 +128,7 @@ gst_caps_get_type (void)
|
|||
static GType gst_caps_type = 0;
|
||||
|
||||
if (G_UNLIKELY (gst_caps_type == 0)) {
|
||||
gst_caps_type = g_boxed_type_register_static ("GstCaps",
|
||||
(GBoxedCopyFunc) gst_caps_copy_conditional,
|
||||
(GBoxedFreeFunc) gst_caps_unref);
|
||||
gst_caps_type = gst_mini_object_register ("GstCaps");
|
||||
|
||||
g_value_register_transform_func (gst_caps_type,
|
||||
G_TYPE_STRING, gst_caps_transform_to_string);
|
||||
|
@ -140,6 +137,27 @@ gst_caps_get_type (void)
|
|||
return gst_caps_type;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
_gst_caps_copy (const GstCaps * caps)
|
||||
{
|
||||
GstCaps *newcaps;
|
||||
GstStructure *structure;
|
||||
guint i, n;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
|
||||
newcaps = gst_caps_new_empty ();
|
||||
GST_CAPS_FLAGS (newcaps) = GST_CAPS_FLAGS (caps);
|
||||
n = caps->structs->len;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
structure = gst_caps_get_structure_unchecked (caps, i);
|
||||
gst_caps_append_structure (newcaps, gst_structure_copy (structure));
|
||||
}
|
||||
|
||||
return newcaps;
|
||||
}
|
||||
|
||||
/* creation/deletion */
|
||||
static void
|
||||
_gst_caps_free (GstCaps * caps)
|
||||
|
@ -180,12 +198,14 @@ _gst_caps_free (GstCaps * caps)
|
|||
GstCaps *
|
||||
gst_caps_new_empty (void)
|
||||
{
|
||||
GstCaps *caps = g_slice_new (GstCaps);
|
||||
GstCaps *caps;
|
||||
|
||||
caps = g_slice_new (GstCaps);
|
||||
|
||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (caps),
|
||||
GST_TYPE_CAPS, sizeof (GstCaps));
|
||||
|
||||
caps->mini_object.copy = (GstMiniObjectCopyFunction) gst_caps_copy;
|
||||
caps->mini_object.copy = (GstMiniObjectCopyFunction) _gst_caps_copy;
|
||||
caps->mini_object.free = (GstMiniObjectFreeFunction) _gst_caps_free;
|
||||
|
||||
caps->structs = g_ptr_array_new ();
|
||||
|
@ -301,43 +321,6 @@ gst_caps_new_full_valist (GstStructure * structure, va_list var_args)
|
|||
return caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_caps_copy:
|
||||
* @caps: the #GstCaps to copy
|
||||
*
|
||||
* 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: (transfer full): the new #GstCaps
|
||||
*/
|
||||
GstCaps *
|
||||
gst_caps_copy (const GstCaps * caps)
|
||||
{
|
||||
GstCaps *newcaps;
|
||||
GstStructure *structure;
|
||||
guint i, n;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
|
||||
newcaps = gst_caps_new_empty ();
|
||||
newcaps->flags = caps->flags;
|
||||
n = caps->structs->len;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
structure = gst_caps_get_structure_unchecked (caps, i);
|
||||
gst_caps_append_structure_unchecked (newcaps,
|
||||
gst_structure_copy (structure));
|
||||
}
|
||||
|
||||
return newcaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_caps_make_writable:
|
||||
* @caps: (transfer full): the #GstCaps to make writable
|
||||
|
@ -369,67 +352,12 @@ gst_caps_make_writable (GstCaps * caps)
|
|||
|
||||
/* else copy */
|
||||
GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy caps");
|
||||
copy = gst_caps_copy (caps);
|
||||
copy = _gst_caps_copy (caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: (transfer full): the same #GstCaps object.
|
||||
*/
|
||||
GstCaps *
|
||||
gst_caps_ref (GstCaps * caps)
|
||||
{
|
||||
g_return_val_if_fail (caps != NULL, NULL);
|
||||
|
||||
#ifdef DEBUG_REFCOUNT
|
||||
GST_CAT_TRACE (GST_CAT_REFCOUNTING, "%p %d->%d", caps,
|
||||
GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) + 1);
|
||||
#endif
|
||||
g_return_val_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0, NULL);
|
||||
|
||||
g_atomic_int_inc (&caps->refcount);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_caps_unref:
|
||||
* @caps: (transfer full): the #GstCaps to unref
|
||||
*
|
||||
* Unref a #GstCaps and and free all its structures and the
|
||||
* structures' values when the refcount reaches 0.
|
||||
*/
|
||||
void
|
||||
gst_caps_unref (GstCaps * caps)
|
||||
{
|
||||
g_return_if_fail (caps != NULL);
|
||||
|
||||
#ifdef DEBUG_REFCOUNT
|
||||
GST_CAT_TRACE (GST_CAT_REFCOUNTING, "%p %d->%d", caps,
|
||||
GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) - 1);
|
||||
#endif
|
||||
|
||||
g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0);
|
||||
|
||||
/* if we ended up with the refcount at zero, free the caps */
|
||||
if (G_UNLIKELY (g_atomic_int_dec_and_test (&caps->refcount)))
|
||||
_gst_caps_free (caps);
|
||||
}
|
||||
|
||||
GType
|
||||
gst_static_caps_get_type (void)
|
||||
{
|
||||
|
@ -462,13 +390,13 @@ gst_static_caps_get (GstStaticCaps * static_caps)
|
|||
caps = (GstCaps *) static_caps;
|
||||
|
||||
/* refcount is 0 when we need to convert */
|
||||
if (G_UNLIKELY (g_atomic_int_get (&caps->refcount) == 0)) {
|
||||
if (G_UNLIKELY (GST_CAPS_REFCOUNT_VALUE (caps) == 0)) {
|
||||
const char *string;
|
||||
GstCaps temp;
|
||||
|
||||
G_LOCK (static_caps_lock);
|
||||
/* check if other thread already updated */
|
||||
if (G_UNLIKELY (g_atomic_int_get (&caps->refcount) > 0))
|
||||
if (G_UNLIKELY (GST_CAPS_REFCOUNT_VALUE (caps) > 0))
|
||||
goto done;
|
||||
|
||||
string = static_caps->string;
|
||||
|
@ -482,24 +410,21 @@ gst_static_caps_get (GstStaticCaps * static_caps)
|
|||
* real caps, refcount last. We do this because we must leave the refcount
|
||||
* of the result caps to 0 so that other threads don't run away with the
|
||||
* caps while we are constructing it. */
|
||||
temp.type = GST_TYPE_CAPS;
|
||||
temp.flags = 0;
|
||||
temp.structs = g_ptr_array_new ();
|
||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (&temp),
|
||||
GST_TYPE_CAPS, sizeof (GstCaps));
|
||||
|
||||
/* initialize the caps to a refcount of 1 so the caps can be writable for
|
||||
* the next statement */
|
||||
temp.refcount = 1;
|
||||
temp.structs = g_ptr_array_new ();
|
||||
|
||||
/* convert to string */
|
||||
if (G_UNLIKELY (!gst_caps_from_string_inplace (&temp, string)))
|
||||
g_critical ("Could not convert static caps \"%s\"", string);
|
||||
|
||||
/* now copy stuff over to the real caps. */
|
||||
caps->type = temp.type;
|
||||
caps->flags = temp.flags;
|
||||
GST_MINI_OBJECT_TYPE (caps) = GST_MINI_OBJECT_TYPE (&temp);
|
||||
GST_CAPS_FLAGS (caps) = GST_CAPS_FLAGS (&temp);
|
||||
caps->structs = temp.structs;
|
||||
/* and bump the refcount so other threads can now read */
|
||||
g_atomic_int_set (&caps->refcount, 1);
|
||||
GST_CAPS_REFCOUNT (caps) = 1;
|
||||
|
||||
GST_CAT_LOG (GST_CAT_CAPS, "created %p", static_caps);
|
||||
done:
|
||||
|
@ -657,7 +582,7 @@ gst_caps_append (GstCaps * caps1, GstCaps * caps2)
|
|||
#endif
|
||||
if (G_UNLIKELY (CAPS_IS_ANY (caps1) || CAPS_IS_ANY (caps2))) {
|
||||
/* FIXME: this leaks */
|
||||
caps1->flags |= GST_CAPS_FLAGS_ANY;
|
||||
GST_CAPS_FLAGS (caps1) |= GST_CAPS_FLAGS_ANY;
|
||||
for (i = caps2->structs->len - 1; i >= 0; i--) {
|
||||
structure = gst_caps_remove_and_get_structure (caps2, i);
|
||||
gst_structure_free (structure);
|
||||
|
@ -703,7 +628,7 @@ gst_caps_merge (GstCaps * caps1, GstCaps * caps2)
|
|||
gst_structure_free (structure);
|
||||
}
|
||||
} else if (G_UNLIKELY (CAPS_IS_ANY (caps2))) {
|
||||
caps1->flags |= GST_CAPS_FLAGS_ANY;
|
||||
GST_CAPS_FLAGS (caps1) |= GST_CAPS_FLAGS_ANY;
|
||||
for (i = caps1->structs->len - 1; i >= 0; i--) {
|
||||
structure = gst_caps_remove_and_get_structure (caps1, i);
|
||||
gst_structure_free (structure);
|
||||
|
@ -881,7 +806,7 @@ gst_caps_copy_nth (const GstCaps * caps, guint nth)
|
|||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
|
||||
newcaps = gst_caps_new_empty ();
|
||||
newcaps->flags = caps->flags;
|
||||
GST_CAPS_FLAGS (newcaps) = GST_CAPS_FLAGS (caps);
|
||||
|
||||
if (G_LIKELY (caps->structs->len > nth)) {
|
||||
structure = gst_caps_get_structure_unchecked (caps, nth);
|
||||
|
@ -1433,7 +1358,7 @@ gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2)
|
|||
|
||||
/* caps are exactly the same pointers, just copy one caps */
|
||||
if (G_UNLIKELY (caps1 == caps2))
|
||||
return gst_caps_copy (caps1);
|
||||
return _gst_caps_copy (caps1);
|
||||
|
||||
/* empty caps on either side, return empty */
|
||||
if (G_UNLIKELY (CAPS_IS_EMPTY (caps1) || CAPS_IS_EMPTY (caps2)))
|
||||
|
@ -1441,9 +1366,9 @@ gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2)
|
|||
|
||||
/* one of the caps is any, just copy the other caps */
|
||||
if (G_UNLIKELY (CAPS_IS_ANY (caps1)))
|
||||
return gst_caps_copy (caps2);
|
||||
return _gst_caps_copy (caps2);
|
||||
if (G_UNLIKELY (CAPS_IS_ANY (caps2)))
|
||||
return gst_caps_copy (caps1);
|
||||
return _gst_caps_copy (caps1);
|
||||
|
||||
dest = gst_caps_new_empty ();
|
||||
|
||||
|
@ -1578,7 +1503,7 @@ gst_caps_subtract (const GstCaps * minuend, const GstCaps * subtrahend)
|
|||
return gst_caps_new_empty ();
|
||||
}
|
||||
if (CAPS_IS_EMPTY_SIMPLE (subtrahend))
|
||||
return gst_caps_copy (minuend);
|
||||
return _gst_caps_copy (minuend);
|
||||
|
||||
/* FIXME: Do we want this here or above?
|
||||
The reason we need this is that there is no definition about what
|
||||
|
@ -1589,7 +1514,7 @@ gst_caps_subtract (const GstCaps * minuend, const GstCaps * subtrahend)
|
|||
sublen = subtrahend->structs->len;
|
||||
g_assert (sublen > 0);
|
||||
|
||||
src = gst_caps_copy (minuend);
|
||||
src = _gst_caps_copy (minuend);
|
||||
for (i = 0; i < sublen; i++) {
|
||||
guint srclen;
|
||||
|
||||
|
@ -1694,16 +1619,16 @@ gst_caps_union (const GstCaps * caps1, const GstCaps * caps2)
|
|||
g_return_val_if_fail (caps2 != NULL, NULL);
|
||||
|
||||
if (CAPS_IS_EMPTY (caps1))
|
||||
return gst_caps_copy (caps2);
|
||||
return _gst_caps_copy (caps2);
|
||||
|
||||
if (CAPS_IS_EMPTY (caps2))
|
||||
return gst_caps_copy (caps1);
|
||||
return _gst_caps_copy (caps1);
|
||||
|
||||
if (CAPS_IS_ANY (caps1) || CAPS_IS_ANY (caps2))
|
||||
return gst_caps_new_any ();
|
||||
|
||||
dest1 = gst_caps_copy (caps1);
|
||||
dest2 = gst_caps_copy (caps2);
|
||||
dest1 = _gst_caps_copy (caps1);
|
||||
dest2 = _gst_caps_copy (caps2);
|
||||
gst_caps_append (dest1, dest2);
|
||||
|
||||
gst_caps_do_simplify (dest1);
|
||||
|
@ -1764,7 +1689,7 @@ gst_caps_normalize (const GstCaps * caps)
|
|||
|
||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
|
||||
newcaps = gst_caps_copy (caps);
|
||||
newcaps = _gst_caps_copy (caps);
|
||||
nf.caps = newcaps;
|
||||
|
||||
for (i = 0; i < gst_caps_get_size (newcaps); i++) {
|
||||
|
@ -1890,7 +1815,7 @@ gst_caps_switch_structures (GstCaps * caps, GstStructure * old,
|
|||
{
|
||||
gst_structure_set_parent_refcount (old, NULL);
|
||||
gst_structure_free (old);
|
||||
gst_structure_set_parent_refcount (new, &caps->refcount);
|
||||
gst_structure_set_parent_refcount (new, &GST_CAPS_REFCOUNT (caps));
|
||||
g_ptr_array_index (caps->structs, i) = new;
|
||||
}
|
||||
|
||||
|
@ -2064,7 +1989,7 @@ gst_caps_from_string_inplace (GstCaps * caps, const gchar * string)
|
|||
gchar *s;
|
||||
|
||||
if (strcmp ("ANY", string) == 0) {
|
||||
caps->flags = GST_CAPS_FLAGS_ANY;
|
||||
GST_CAPS_FLAGS (caps) = GST_CAPS_FLAGS_ANY;
|
||||
return TRUE;
|
||||
}
|
||||
if (strcmp ("EMPTY", string) == 0) {
|
||||
|
@ -2131,13 +2056,3 @@ gst_caps_transform_to_string (const GValue * src_value, GValue * dest_value)
|
|||
dest_value->data[0].v_pointer =
|
||||
gst_caps_to_string (src_value->data[0].v_pointer);
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_caps_copy_conditional (GstCaps * src)
|
||||
{
|
||||
if (src) {
|
||||
return gst_caps_ref (src);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
if (G_UNLIKELY (_gst_event_type == 0)) {
|
||||
_gst_event_type = gst_mini_object_register ("GstEvent");
|
||||
}
|
||||
|
||||
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
|
||||
klass->mini_object_class.finalize =
|
||||
(GstMiniObjectFinalizeFunction) gst_event_finalize;
|
||||
return _gst_event_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_event_init (GstEvent * event)
|
||||
{
|
||||
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue