- sink the systemclock

Original commit message from CVS:
- sink the systemclock
- unref scheduler in pipeline with new API
- better ref/unref debug info in gstobject
This commit is contained in:
Wim Taymans 2003-01-17 18:48:17 +00:00
parent b28455b1d6
commit 2268739955
3 changed files with 51 additions and 21 deletions

View file

@ -180,8 +180,10 @@ gst_object_ref (GstObject *object)
{ {
g_return_val_if_fail (GST_IS_OBJECT (object), NULL); g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
GST_DEBUG (GST_CAT_REFCOUNTING, "ref '%s' %d->%d",GST_OBJECT_NAME(object), GST_DEBUG (GST_CAT_REFCOUNTING, "ref %p '%s' %d->%d", object,
G_OBJECT(object)->ref_count,G_OBJECT(object)->ref_count+1); GST_OBJECT_NAME (object),
G_OBJECT (object)->ref_count,
G_OBJECT (object)->ref_count + 1);
g_object_ref (G_OBJECT (object)); g_object_ref (G_OBJECT (object));
return object; return object;
@ -199,8 +201,10 @@ gst_object_unref (GstObject *object)
{ {
g_return_if_fail (GST_IS_OBJECT (object)); g_return_if_fail (GST_IS_OBJECT (object));
GST_DEBUG (GST_CAT_REFCOUNTING, "unref '%s' %d->%d",GST_OBJECT_NAME(object), GST_DEBUG (GST_CAT_REFCOUNTING, "unref %p '%s' %d->%d", object,
G_OBJECT(object)->ref_count,G_OBJECT(object)->ref_count-1); GST_OBJECT_NAME (object),
G_OBJECT (object)->ref_count,
G_OBJECT (object)->ref_count - 1);
g_object_unref (G_OBJECT (object)); g_object_unref (G_OBJECT (object));
} }
@ -220,9 +224,9 @@ gst_object_sink (GstObject *object)
g_return_if_fail (object != NULL); g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object)); g_return_if_fail (GST_IS_OBJECT (object));
GST_DEBUG (GST_CAT_REFCOUNTING, "sink '%s'",GST_OBJECT_NAME(object)); GST_DEBUG (GST_CAT_REFCOUNTING, "sink %p '%s'", object, GST_OBJECT_NAME (object));
if (GST_OBJECT_FLOATING (object))
{ if (GST_OBJECT_FLOATING (object)) {
GST_FLAG_UNSET (object, GST_FLOATING); GST_FLAG_UNSET (object, GST_FLOATING);
gst_object_unref (object); gst_object_unref (object);
} }
@ -262,7 +266,8 @@ gst_object_destroy (GstObject *object)
g_return_if_fail (object != NULL); g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object)); g_return_if_fail (GST_IS_OBJECT (object));
GST_DEBUG (GST_CAT_REFCOUNTING, "destroy '%s'",GST_OBJECT_NAME(object)); GST_DEBUG (GST_CAT_REFCOUNTING, "destroy %p '%s'", object, GST_OBJECT_NAME (object));
if (!GST_OBJECT_DESTROYED (object)) if (!GST_OBJECT_DESTROYED (object))
{ {
/* need to hold a reference count around all class method /* need to hold a reference count around all class method
@ -275,7 +280,8 @@ gst_object_destroy (GstObject *object)
static void static void
gst_object_dispose (GObject *object) gst_object_dispose (GObject *object)
{ {
GST_DEBUG (GST_CAT_REFCOUNTING, "dispose '%s'",GST_OBJECT_NAME(object)); GST_DEBUG (GST_CAT_REFCOUNTING, "dispose %p '%s'", object, GST_OBJECT_NAME (object));
GST_FLAG_SET (GST_OBJECT (object), GST_DESTROYED); GST_FLAG_SET (GST_OBJECT (object), GST_DESTROYED);
GST_OBJECT_PARENT (object) = NULL; GST_OBJECT_PARENT (object) = NULL;
@ -288,7 +294,7 @@ gst_object_finalize (GObject *object)
{ {
GstObject *gstobject = GST_OBJECT (object); GstObject *gstobject = GST_OBJECT (object);
GST_DEBUG (GST_CAT_REFCOUNTING, "finalize '%s'",GST_OBJECT_NAME(object)); GST_DEBUG (GST_CAT_REFCOUNTING, "finalize %p '%s'", object, GST_OBJECT_NAME (object));
g_signal_handlers_destroy (object); g_signal_handlers_destroy (object);

View file

@ -29,6 +29,7 @@
static void gst_scheduler_class_init (GstSchedulerClass *klass); static void gst_scheduler_class_init (GstSchedulerClass *klass);
static void gst_scheduler_init (GstScheduler *sched); static void gst_scheduler_init (GstScheduler *sched);
static void gst_scheduler_dispose (GObject *object);
static GstObjectClass *parent_class = NULL; static GstObjectClass *parent_class = NULL;
@ -62,7 +63,13 @@ gst_scheduler_get_type (void)
static void static void
gst_scheduler_class_init (GstSchedulerClass *klass) gst_scheduler_class_init (GstSchedulerClass *klass)
{ {
GObjectClass *gobject_class;
gobject_class = (GObjectClass*) klass;
parent_class = g_type_class_ref (GST_TYPE_OBJECT); parent_class = g_type_class_ref (GST_TYPE_OBJECT);
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_scheduler_dispose);
} }
static void static void
@ -77,6 +84,17 @@ gst_scheduler_init (GstScheduler *sched)
sched->clock = NULL; sched->clock = NULL;
} }
static void
gst_scheduler_dispose (GObject *object)
{
GstScheduler *sched = GST_SCHEDULER (object);
gst_object_swap ((GstObject **)&sched->current_clock, NULL);
gst_object_swap ((GstObject **)&sched->clock, NULL);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
/** /**
* gst_scheduler_setup: * gst_scheduler_setup:
* @sched: the scheduler * @sched: the scheduler
@ -274,7 +292,6 @@ gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint t
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE); g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
if (element == sched->parent && sched->parent_sched == NULL) { if (element == sched->parent && sched->parent_sched == NULL) {
switch (transition) { switch (transition) {
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
{ {
@ -286,7 +303,7 @@ gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint t
GST_DEBUG (GST_CAT_CLOCK, "scheduler READY to PAUSED clock is %p (%s)", clock, GST_DEBUG (GST_CAT_CLOCK, "scheduler READY to PAUSED clock is %p (%s)", clock,
(clock ? GST_OBJECT_NAME (clock) : "nil")); (clock ? GST_OBJECT_NAME (clock) : "nil"));
sched->current_clock = clock; gst_object_swap ((GstObject **)&sched->current_clock, (GstObject *)clock);
break; break;
} }
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
@ -296,7 +313,7 @@ gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint t
GST_DEBUG (GST_CAT_CLOCK, "scheduler PAUSED to PLAYING clock is %p (%s)", clock, GST_DEBUG (GST_CAT_CLOCK, "scheduler PAUSED to PLAYING clock is %p (%s)", clock,
(clock ? GST_OBJECT_NAME (clock) : "nil")); (clock ? GST_OBJECT_NAME (clock) : "nil"));
sched->current_clock = clock; gst_object_swap ((GstObject **)&sched->current_clock, (GstObject *)clock);
gst_scheduler_set_clock (sched, sched->current_clock); gst_scheduler_set_clock (sched, sched->current_clock);
if (sched->current_clock) { if (sched->current_clock) {
@ -577,7 +594,8 @@ gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock)
g_return_if_fail (GST_IS_SCHEDULER (sched)); g_return_if_fail (GST_IS_SCHEDULER (sched));
GST_FLAG_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK); GST_FLAG_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK);
sched->clock = clock;
gst_object_swap ((GstObject **)&sched->clock, (GstObject *)clock);
GST_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock, GST_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
(clock ? GST_OBJECT_NAME (clock) : "nil")); (clock ? GST_OBJECT_NAME (clock) : "nil"));
@ -603,7 +621,7 @@ gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock)
receivers = sched->clock_receivers; receivers = sched->clock_receivers;
schedulers = sched->schedulers; schedulers = sched->schedulers;
sched->current_clock = clock; gst_object_swap ((GstObject **)&sched->current_clock, (GstObject *)clock);
while (receivers) { while (receivers) {
GstElement *element = GST_ELEMENT (receivers->data); GstElement *element = GST_ELEMENT (receivers->data);
@ -637,7 +655,8 @@ gst_scheduler_auto_clock (GstScheduler *sched)
g_return_if_fail (GST_IS_SCHEDULER (sched)); g_return_if_fail (GST_IS_SCHEDULER (sched));
GST_FLAG_UNSET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK); GST_FLAG_UNSET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK);
sched->clock = NULL;
gst_object_swap ((GstObject **)&sched->clock, NULL);
GST_DEBUG (GST_CAT_CLOCK, "scheduler using automatic clock"); GST_DEBUG (GST_CAT_CLOCK, "scheduler using automatic clock");
} }
@ -789,14 +808,16 @@ gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type)
GstSchedulerFactory *factory; GstSchedulerFactory *factory;
g_return_val_if_fail(name != NULL, NULL); g_return_val_if_fail(name != NULL, NULL);
factory = gst_scheduler_factory_find (name); factory = gst_scheduler_factory_find (name);
if (!factory) { if (!factory) {
factory = GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL)); factory = GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL));
} }
else {
GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
if (factory->longdesc)
g_free (factory->longdesc); g_free (factory->longdesc);
}
factory->longdesc = g_strdup (longdesc); factory->longdesc = g_strdup (longdesc);
factory->type = type; factory->type = type;
@ -835,6 +856,7 @@ gst_scheduler_factory_find (const gchar *name)
GST_DEBUG (0,"gstscheduler: find \"%s\"", name); GST_DEBUG (0,"gstscheduler: find \"%s\"", name);
feature = gst_registry_pool_find_feature (name, GST_TYPE_SCHEDULER_FACTORY); feature = gst_registry_pool_find_feature (name, GST_TYPE_SCHEDULER_FACTORY);
if (feature) if (feature)
return GST_SCHEDULER_FACTORY (feature); return GST_SCHEDULER_FACTORY (feature);
@ -920,7 +942,6 @@ gst_scheduler_factory_make (const gchar *name, GstElement *parent)
void void
gst_scheduler_factory_set_default_name (const gchar* name) gst_scheduler_factory_set_default_name (const gchar* name)
{ {
if (_default_name)
g_free (_default_name); g_free (_default_name);
_default_name = g_strdup (name); _default_name = g_strdup (name);

View file

@ -109,6 +109,9 @@ gst_system_clock_obtain (void)
_the_system_clock = GST_CLOCK (g_object_new (GST_TYPE_SYSTEM_CLOCK, NULL)); _the_system_clock = GST_CLOCK (g_object_new (GST_TYPE_SYSTEM_CLOCK, NULL));
gst_object_set_name (GST_OBJECT (_the_system_clock), "GstSystemClock"); gst_object_set_name (GST_OBJECT (_the_system_clock), "GstSystemClock");
gst_object_ref (GST_OBJECT (_the_system_clock));
gst_object_sink (GST_OBJECT (_the_system_clock));
} }
return _the_system_clock; return _the_system_clock;
} }