Refcounting fixes to make the testsuite succeed.

Original commit message from CVS:
Refcounting fixes to make the testsuite succeed.
Added a ne w category for REFCOUNTING.
This commit is contained in:
Wim Taymans 2001-05-12 00:04:32 +00:00
parent 13c4e92c04
commit d5cb52427f
6 changed files with 47 additions and 17 deletions

View file

@ -51,7 +51,7 @@ static void gst_element_init (GstElement *element);
static void gst_element_set_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_element_get_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_element_finalize (GtkObject *object);
static void gst_element_real_destroy (GtkObject *object);
static GstElementStateReturn gst_element_change_state (GstElement *element);
@ -120,7 +120,7 @@ gst_element_class_init (GstElementClass *klass)
gtkobject_class->set_arg = GST_DEBUG_FUNCPTR(gst_element_set_arg);
gtkobject_class->get_arg = GST_DEBUG_FUNCPTR(gst_element_get_arg);
gtkobject_class->finalize = GST_DEBUG_FUNCPTR(gst_element_finalize);
gtkobject_class->destroy = GST_DEBUG_FUNCPTR(gst_element_real_destroy);
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR(gst_element_save_thyself);
gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR(gst_element_restore_thyself);
@ -836,24 +836,25 @@ GST_ELEMENT_NAME(element),GST_ELEMENT_NAME(GST_ELEMENT_PARENT(element)),GST_ELEM
}
static void
gst_element_finalize (GtkObject *object)
gst_element_real_destroy (GtkObject *object)
{
GstElement *element = GST_ELEMENT (object);
GList *pads;
GstPad *pad;
//g_print("element_finalize()\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "destroy\n");
pads = element->pads;
while (pads) {
pad = GST_PAD (pads->data);
gst_pad_destroy (pad);
gst_object_unref (GST_OBJECT (pad));
pads = g_list_next (pads);
}
g_list_free (element->pads);
GTK_OBJECT_CLASS (parent_class)->finalize (object);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
/*

View file

@ -55,6 +55,7 @@ static gchar *_gst_info_category_strings[] = {
"TYPES",
"XML",
"NEGOTIATION",
"REFCOUNTING",
};
/**
@ -106,6 +107,7 @@ const gchar *_gst_category_colors[32] = {
[GST_CAT_TYPES] = "01;37;41", // !!
[GST_CAT_XML] = "01;37;41", // !!
[GST_CAT_NEGOTIATION] = "07;34",
[GST_CAT_REFCOUNTING] = "00;34:42",
[31] = "",
};

View file

@ -87,6 +87,7 @@ enum {
GST_CAT_TYPES, // Typing
GST_CAT_XML, // XML load/save of everything
GST_CAT_NEGOTIATION, // Caps Negotiation stuff
GST_CAT_REFCOUNTING, // Ref Counting stuff
GST_CAT_MAX_CATEGORY = 31
};

View file

@ -158,7 +158,8 @@ gst_object_ref (GstObject *object)
{
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
//g_print ("object_ref\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "ref\n");
gtk_object_ref (GTK_OBJECT (object));
return object;
@ -177,7 +178,8 @@ gst_object_unref (GstObject *object)
{
g_return_if_fail (GST_IS_OBJECT (object));
//g_print ("object_unref\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "unref\n");
gtk_object_unref (GTK_OBJECT (object));
}
#define gst_object_unref gst_object_unref
@ -196,7 +198,7 @@ gst_object_sink (GstObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
//g_print ("object_sink\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "sink\n");
if (GST_OBJECT_FLOATING (object))
{
GST_FLAG_UNSET (object, GST_FLOATING);
@ -210,7 +212,7 @@ gst_object_destroy (GstObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
//g_print ("object_destroy\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "destroy\n");
if (!GST_OBJECT_DESTROYED (object))
{
/* need to hold a reference count around all class method
@ -225,7 +227,7 @@ gst_object_destroy (GstObject *object)
static void
gst_object_shutdown (GtkObject *object)
{
//g_print ("object_shutdown\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "shutdown\n");
GST_FLAG_SET (GST_OBJECT (object), GST_DESTROYED);
parent_class->shutdown (GTK_OBJECT (object));
}
@ -234,6 +236,8 @@ gst_object_shutdown (GtkObject *object)
static void
gst_object_real_destroy (GtkObject *gtk_object)
{
GST_DEBUG (GST_CAT_REFCOUNTING, "destroy\n");
parent_class->destroy (gtk_object);
}
@ -245,7 +249,7 @@ gst_object_finalize (GtkObject *gtk_object)
object = GST_OBJECT (gtk_object);
//g_print ("object_finalize\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "finalize\n");
if (object->name != NULL)
g_free (object->name);

View file

@ -272,6 +272,8 @@ gst_pad_new_from_template (GstPadTemplate *templ,
g_return_val_if_fail (templ != NULL, NULL);
pad = gst_pad_new (name, templ->direction);
gst_object_ref (GST_OBJECT (templ));
gst_object_sink (GST_OBJECT (templ));
GST_PAD_PADTEMPLATE(pad) = templ;
return pad;
@ -554,6 +556,14 @@ gst_pad_disconnect (GstPad *srcpad,
g_return_if_fail (GST_RPAD_PEER(realsrc) != NULL);
g_return_if_fail (GST_RPAD_PEER(realsink) != NULL);
if ((GST_RPAD_DIRECTION(realsrc) == GST_PAD_SINK) &&
(GST_RPAD_DIRECTION(realsink) == GST_PAD_SRC)) {
GstRealPad *temppad;
temppad = realsrc;
realsrc = realsink;
realsink = temppad;
}
g_return_if_fail ((GST_RPAD_DIRECTION(realsrc) == GST_PAD_SRC) &&
(GST_RPAD_DIRECTION(realsink) == GST_PAD_SINK));
@ -566,7 +576,10 @@ gst_pad_disconnect (GstPad *srcpad,
gtk_signal_emit(GTK_OBJECT(realsink), gst_real_pad_signals[REAL_DISCONNECTED], realsrc);
// now tell the scheduler
if (realsrc->sched)
GST_SCHEDULE_PAD_DISCONNECT (realsrc->sched, (GstPad *)realsrc, (GstPad *)realsink);
if (realsink->sched)
GST_SCHEDULE_PAD_DISCONNECT (realsink->sched, (GstPad *)realsrc, (GstPad *)realsink);
GST_INFO (GST_CAT_ELEMENT_PADS, "disconnected %s:%s and %s:%s",
GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad));
@ -586,7 +599,6 @@ gst_pad_connect (GstPad *srcpad,
GstPad *sinkpad)
{
GstRealPad *realsrc, *realsink;
GstRealPad *temppad;
gboolean negotiated = FALSE;
/* generic checks */
@ -605,6 +617,8 @@ gst_pad_connect (GstPad *srcpad,
/* check for reversed directions and swap if necessary */
if ((GST_RPAD_DIRECTION(realsrc) == GST_PAD_SINK) &&
(GST_RPAD_DIRECTION(realsink) == GST_PAD_SRC)) {
GstRealPad *temppad;
temppad = realsrc;
realsrc = realsink;
realsink = temppad;
@ -996,15 +1010,23 @@ gst_pad_get_bufferpool (GstPad *pad)
}
// FIXME this needs to be rethought soon
static void
gst_real_pad_destroy (GtkObject *object)
{
GstPad *pad = GST_PAD (object);
// g_print("in gst_pad_real_destroy()\n");
GST_DEBUG (GST_CAT_REFCOUNTING, "destroy\n");
if (GST_PAD (pad)->padtemplate)
gst_object_unref (GST_OBJECT (GST_PAD (pad)->padtemplate));
if (GST_PAD_PEER (object))
gst_pad_disconnect (GST_PAD (object), GST_PAD (GST_PAD_PEER (object)));
g_list_free (GST_REAL_PAD(pad)->ghostpads);
if (GTK_OBJECT_CLASS (real_pad_parent_class)->destroy)
GTK_OBJECT_CLASS (real_pad_parent_class)->destroy (object);
}

View file

@ -360,6 +360,7 @@ GstBuffer* gst_pad_pullregion (GstPad *pad, GstRegionType type, guint64 offset
#define gst_pad_eos(pad) (GST_RPAD_EOSFUNC(GST_RPAD_PEER(pad))(GST_PAD(GST_RPAD_PEER(pad))))
gboolean gst_pad_set_eos (GstPad *pad);
gboolean gst_pad_eos_func (GstPad *pad);
void gst_pad_handle_qos (GstPad *pad, glong qos_message);
void gst_pad_load_and_connect (xmlNodePtr self, GstObject *parent);
@ -383,7 +384,6 @@ GstCaps* gst_padtemplate_get_caps_by_name (GstPadTemplate *templ, const gchar *
xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *templ, xmlNodePtr parent);
GstPadTemplate* gst_padtemplate_load_thyself (xmlNodePtr parent);
gboolean gst_pad_eos_func (GstPad *pad);
#ifdef __cplusplus
}