mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-10 01:54:11 +00:00
gst/gstminiobject.c: Some cleanup and checking against invalid function parameters.
Original commit message from CVS: * gst/gstminiobject.c: (gst_mini_object_get_type), (gst_mini_object_class_init), (gst_mini_object_copy_default), (gst_mini_object_finalize), (gst_mini_object_copy), (gst_mini_object_is_writable), (gst_mini_object_make_writable), (gst_mini_object_replace), (param_mini_object_validate), (gst_param_spec_mini_object_get_type): Some cleanup and checking against invalid function parameters.
This commit is contained in:
parent
0e0caaf16a
commit
d8f8df9c49
2 changed files with 45 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-11-28 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* gst/gstminiobject.c: (gst_mini_object_get_type),
|
||||
(gst_mini_object_class_init), (gst_mini_object_copy_default),
|
||||
(gst_mini_object_finalize), (gst_mini_object_copy),
|
||||
(gst_mini_object_is_writable), (gst_mini_object_make_writable),
|
||||
(gst_mini_object_replace), (param_mini_object_validate),
|
||||
(gst_param_spec_mini_object_get_type):
|
||||
Some cleanup and checking against invalid function parameters.
|
||||
|
||||
2007-11-28 Wim Taymans <wim.taymans@gmail.com>
|
||||
|
||||
* docs/gst/gstreamer-sections.txt:
|
||||
|
|
|
@ -48,8 +48,8 @@ static GstAllocTrace *_gst_mini_object_trace;
|
|||
#if 0
|
||||
static void gst_mini_object_base_init (gpointer g_class);
|
||||
static void gst_mini_object_base_finalize (gpointer g_class);
|
||||
static void gst_mini_object_class_init (gpointer g_class, gpointer class_data);
|
||||
#endif
|
||||
static void gst_mini_object_class_init (gpointer g_class, gpointer class_data);
|
||||
static void gst_mini_object_init (GTypeInstance * instance, gpointer klass);
|
||||
|
||||
static void gst_value_mini_object_init (GValue * value);
|
||||
|
@ -62,6 +62,9 @@ static gchar *gst_value_mini_object_collect (GValue * value,
|
|||
static gchar *gst_value_mini_object_lcopy (const GValue * value,
|
||||
guint n_collect_values, GTypeCValue * collect_values, guint collect_flags);
|
||||
|
||||
static GstMiniObject *gst_mini_object_copy_default (const GstMiniObject * obj);
|
||||
static void gst_mini_object_finalize (GstMiniObject * obj);
|
||||
|
||||
GType
|
||||
gst_mini_object_get_type (void)
|
||||
{
|
||||
|
@ -83,10 +86,10 @@ gst_mini_object_get_type (void)
|
|||
#if 0
|
||||
gst_mini_object_base_init,
|
||||
gst_mini_object_base_finalize,
|
||||
gst_mini_object_class_init,
|
||||
#else
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL,
|
||||
#endif
|
||||
gst_mini_object_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstMiniObject),
|
||||
|
@ -126,13 +129,16 @@ gst_mini_object_base_finalize (gpointer g_class)
|
|||
{
|
||||
/* do nothing */
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gst_mini_object_class_init (gpointer g_class, gpointer class_data)
|
||||
{
|
||||
/* do nothing */
|
||||
GstMiniObjectClass *mo_class = GST_MINI_OBJECT_CLASS (g_class);
|
||||
|
||||
mo_class->copy = gst_mini_object_copy_default;
|
||||
mo_class->finalize = gst_mini_object_finalize;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gst_mini_object_init (GTypeInstance * instance, gpointer klass)
|
||||
|
@ -142,6 +148,19 @@ gst_mini_object_init (GTypeInstance * instance, gpointer klass)
|
|||
mini_object->refcount = 1;
|
||||
}
|
||||
|
||||
static GstMiniObject *
|
||||
gst_mini_object_copy_default (const GstMiniObject * obj)
|
||||
{
|
||||
g_warning ("GstMiniObject classes must implement GstMiniObject::copy");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mini_object_finalize (GstMiniObject * obj)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_mini_object_new:
|
||||
* @type: the #GType of the mini-object to create
|
||||
|
@ -183,6 +202,8 @@ gst_mini_object_copy (const GstMiniObject * mini_object)
|
|||
{
|
||||
GstMiniObjectClass *mo_class;
|
||||
|
||||
g_return_val_if_fail (mini_object != NULL, NULL);
|
||||
|
||||
mo_class = GST_MINI_OBJECT_GET_CLASS (mini_object);
|
||||
|
||||
return mo_class->copy (mini_object);
|
||||
|
@ -204,6 +225,8 @@ gst_mini_object_copy (const GstMiniObject * mini_object)
|
|||
gboolean
|
||||
gst_mini_object_is_writable (const GstMiniObject * mini_object)
|
||||
{
|
||||
g_return_val_if_fail (mini_object != NULL, FALSE);
|
||||
|
||||
return (GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) == 1) &&
|
||||
((mini_object->flags & GST_MINI_OBJECT_FLAG_READONLY) == 0);
|
||||
}
|
||||
|
@ -225,6 +248,8 @@ gst_mini_object_make_writable (GstMiniObject * mini_object)
|
|||
{
|
||||
GstMiniObject *ret;
|
||||
|
||||
g_return_val_if_fail (mini_object != NULL, NULL);
|
||||
|
||||
if (gst_mini_object_is_writable (mini_object)) {
|
||||
ret = (GstMiniObject *) mini_object;
|
||||
} else {
|
||||
|
@ -331,6 +356,8 @@ gst_mini_object_replace (GstMiniObject ** olddata, GstMiniObject * newdata)
|
|||
{
|
||||
GstMiniObject *olddata_val;
|
||||
|
||||
g_return_if_fail (olddata != NULL);
|
||||
|
||||
#ifdef DEBUG_REFCOUNT
|
||||
GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %p (%d) with %p (%d)",
|
||||
*olddata, *olddata ? (*olddata)->refcount : 0,
|
||||
|
@ -505,14 +532,14 @@ param_mini_object_validate (GParamSpec * pspec, GValue * value)
|
|||
{
|
||||
GstParamSpecMiniObject *ospec = GST_PARAM_SPEC_MINI_OBJECT (pspec);
|
||||
GstMiniObject *mini_object = value->data[0].v_pointer;
|
||||
guint changed = 0;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
if (mini_object
|
||||
&& !g_value_type_compatible (G_OBJECT_TYPE (mini_object),
|
||||
G_PARAM_SPEC_VALUE_TYPE (ospec))) {
|
||||
gst_mini_object_unref (mini_object);
|
||||
value->data[0].v_pointer = NULL;
|
||||
changed++;
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
@ -546,6 +573,7 @@ gst_param_spec_mini_object_get_type (void)
|
|||
param_mini_object_validate, /* value_validate */
|
||||
param_mini_object_values_cmp, /* values_cmp */
|
||||
};
|
||||
/* FIXME 0.11: Should really be GstParamSpecMiniObject */
|
||||
type = g_param_type_register_static ("GParamSpecMiniObject", &pspec_info);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue