Preparing for merge to HEAD.

Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* gst/elements/gstidentity.c: (gst_identity_event):
* gst/gstobject.c: (gst_object_get_type), (gst_object_class_init),
(gst_object_init), (gst_object_ref), (gst_object_unref),
(gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed),
(gst_object_set_name_default), (gst_object_set_name),
(gst_object_set_name_prefix), (gst_object_set_parent),
(gst_object_unparent), (gst_object_check_uniqueness):
* gst/gstobject.h:
Preparing for merge to HEAD.
Backported some HEAD changes to the set_name_default
method.
Updated refcounting docs.
This commit is contained in:
Wim Taymans 2005-03-03 18:18:06 +00:00
parent bffbacfaae
commit 6a480f3c7c
6 changed files with 51 additions and 28 deletions

View file

@ -1,3 +1,20 @@
2005-03-03 Wim Taymans <wim@fluendo.com>
* docs/design/part-MT-refcounting.txt:
* gst/elements/gstidentity.c: (gst_identity_event):
* gst/gstobject.c: (gst_object_get_type), (gst_object_class_init),
(gst_object_init), (gst_object_ref), (gst_object_unref),
(gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed),
(gst_object_set_name_default), (gst_object_set_name),
(gst_object_set_name_prefix), (gst_object_set_parent),
(gst_object_unparent), (gst_object_check_uniqueness):
* gst/gstobject.h:
Preparing for merge to HEAD.
Backported some HEAD changes to the set_name_default
method.
Updated refcounting docs.
2005-03-03 Andy Wingo <wingo@pobox.com>
* gst/gstiterator.c (gst_iterator_find_custom)

View file

@ -234,6 +234,10 @@ Objects
This means that all properties that require access beyond the scope of the
critial section should be copied or refcounted before releasing the lock.
Most object provide a _get_<property>() method to get a copy or refcounted
instance of the property value. The caller should not wory about any locks
but should unref/free the object after usage.
Example:
the following example correctly gets the peer pad of an element. It is
@ -255,6 +259,19 @@ Objects
anymore of the pad. If you need to be sure it is, you need to extend the
critical section to include the operations on the peer.
Example:
Accessing the name of an object makes a copy of the name. The caller of the
function should g_free() the name after usage.
GST_LOCK (object)
name = g_strdup (object->name);
GST_UNLOCK (object)
... use name ...
g_free (name);
* Accessor methods
For aplications it is encouraged to use the public methods of the object. Most

View file

@ -352,7 +352,6 @@ gst_identity_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH:
g_print ("identity received flush event\n");
/* forward event */
gst_pad_event_default (pad, event);
if (GST_EVENT_FLUSH_DONE (event)) {
@ -369,20 +368,16 @@ gst_identity_event (GstPad * pad, GstEvent * event)
/* unblock both functions */
identity_queue_flush (identity);
g_print ("identity after flush\n");
}
ret = TRUE;
goto done;
case GST_EVENT_EOS:
/* g_print ("identity got eos\n"); */
if (identity->sink_mode == GST_ACTIVATE_PULL) {
/* already have the sink stream lock */
gst_task_pause (GST_RPAD_TASK (identity->sinkpad));
}
break;
default:
g_print ("identity got event %p of type %d\n", event,
GST_EVENT_TYPE (event));
break;
}

View file

@ -94,7 +94,7 @@ static guint gst_signal_object_signals[SO_LAST_SIGNAL] = { 0 };
#endif
static void gst_object_class_init (GstObjectClass * klass);
static void gst_object_init (GstObject * object);
static void gst_object_init (GTypeInstance * instance, gpointer g_class);
#ifndef GST_DISABLE_TRACE
static GObject *gst_object_constructor (GType type,
@ -111,6 +111,9 @@ static void gst_object_dispatch_properties_changed (GObject * object,
static void gst_object_dispose (GObject * object);
static void gst_object_finalize (GObject * object);
static gboolean gst_object_set_name_default (GstObject * object,
const gchar * type_name);
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
static void gst_object_real_restore_thyself (GstObject * object,
xmlNodePtr self);
@ -132,7 +135,7 @@ gst_object_get_type (void)
NULL,
sizeof (GstObject),
0,
(GInstanceInitFunc) gst_object_init,
gst_object_init,
NULL
};
@ -200,14 +203,16 @@ gst_object_class_init (GstObjectClass * klass)
}
static void
gst_object_init (GstObject * object)
gst_object_init (GTypeInstance * instance, gpointer g_class)
{
object->lock = g_mutex_new ();
GstObject *object = GST_OBJECT (instance);
object->lock = g_mutex_new ();
object->parent = NULL;
object->name = NULL;
gst_atomic_int_init (&(object)->refcount, 1);
PATCH_REFCOUNT (object);
gst_object_set_name_default (object, G_OBJECT_CLASS_NAME (g_class));
object->flags = 0;
GST_FLAG_SET (object, GST_OBJECT_FLOATING);
@ -358,7 +363,6 @@ gst_object_sink (GstObject * object)
} else {
GST_UNLOCK (object);
}
return;
}
/**
@ -577,15 +581,12 @@ gst_object_default_deep_notify (GObject * object, GstObject * orig,
}
static gboolean
gst_object_set_name_default (GstObject * object)
gst_object_set_name_default (GstObject * object, const gchar * type_name)
{
gint count;
gchar *name, *tmp;
const gchar *type_name;
gboolean result;
type_name = G_OBJECT_TYPE_NAME (object);
/* to ensure guaranteed uniqueness across threads, only one thread
* may ever assign a name */
G_LOCK (object_name_mutex);
@ -649,7 +650,7 @@ gst_object_set_name (GstObject * object, const gchar * name)
result = TRUE;
} else {
GST_UNLOCK (object);
result = gst_object_set_name_default (object);
result = gst_object_set_name_default (object, G_OBJECT_TYPE_NAME (object));
}
return result;
@ -705,10 +706,8 @@ gst_object_set_name_prefix (GstObject * object, const gchar * name_prefix)
g_return_if_fail (GST_IS_OBJECT (object));
GST_LOCK (object);
g_free (object->name_prefix);
object->name_prefix = g_strdup (name_prefix); /* NULL gives NULL */
GST_UNLOCK (object);
}
@ -785,10 +784,12 @@ gst_object_set_parent (GstObject * object, GstObject * parent)
g_signal_emit (G_OBJECT (object), gst_object_signals[PARENT_SET], 0, parent);
return TRUE;
/* ERROR */
had_parent:
GST_UNLOCK (object);
return FALSE;
{
GST_UNLOCK (object);
return FALSE;
}
}
/**

View file

@ -123,8 +123,6 @@ struct _GstObjectClass {
void (*deep_notify) (GstObject *object, GstObject *orig, GParamSpec *pspec);
/* vtable */
void (*destroy) (GstObject *object);
xmlNodePtr (*save_thyself) (GstObject *object, xmlNodePtr parent);
void (*restore_thyself) (GstObject *object, xmlNodePtr self);
@ -136,7 +134,7 @@ struct _GstObjectClass {
GType gst_object_get_type (void);
/* name routines */
gboolean gst_object_set_name (GstObject *object, const gchar *name_prefix);
gboolean gst_object_set_name (GstObject *object, const gchar *name);
gchar* gst_object_get_name (GstObject *object);
void gst_object_set_name_prefix (GstObject *object, const gchar *name_prefix);
gchar* gst_object_get_name_prefix (GstObject *object);

View file

@ -352,7 +352,6 @@ gst_identity_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH:
g_print ("identity received flush event\n");
/* forward event */
gst_pad_event_default (pad, event);
if (GST_EVENT_FLUSH_DONE (event)) {
@ -369,20 +368,16 @@ gst_identity_event (GstPad * pad, GstEvent * event)
/* unblock both functions */
identity_queue_flush (identity);
g_print ("identity after flush\n");
}
ret = TRUE;
goto done;
case GST_EVENT_EOS:
/* g_print ("identity got eos\n"); */
if (identity->sink_mode == GST_ACTIVATE_PULL) {
/* already have the sink stream lock */
gst_task_pause (GST_RPAD_TASK (identity->sinkpad));
}
break;
default:
g_print ("identity got event %p of type %d\n", event,
GST_EVENT_TYPE (event));
break;
}