From d1e45d83b96f9e207f53eda0ae9cffd4eb5e50f6 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 10 May 2003 11:35:59 +0000 Subject: [PATCH] properly get rid of clocks on disposal - be parent of own clock Original commit message from CVS: properly get rid of clocks on disposal - be parent of own clock --- sys/oss/gstosssink.c | 14 +++++++++++++- sys/oss/gstosssrc.c | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c index 639500511b..6a523753e2 100644 --- a/sys/oss/gstosssink.c +++ b/sys/oss/gstosssink.c @@ -39,6 +39,7 @@ static GstElementDetails gst_osssink_details = { static void gst_osssink_class_init (GstOssSinkClass *klass); static void gst_osssink_init (GstOssSink *osssink); +static void gst_osssink_dispose (GObject *object); static void gst_osssink_finalize (GObject *object); static GstElementStateReturn gst_osssink_change_state (GstElement *element); @@ -147,6 +148,16 @@ gst_osssink_get_bufferpool (GstPad *pad) return oss->sinkpool; } +static void +gst_osssink_dispose (GObject *object) +{ + GstOssSink *osssink = (GstOssSink *) object; + + gst_object_unparent (GST_OBJECT (osssink->provided_clock)); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + static void gst_osssink_finalize (GObject *object) { @@ -192,6 +203,7 @@ gst_osssink_class_init (GstOssSinkClass *klass) gobject_class->set_property = gst_osssink_set_property; gobject_class->get_property = gst_osssink_get_property; + gobject_class->dispose = gst_osssink_dispose; gobject_class->finalize = gst_osssink_finalize; gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_osssink_change_state); @@ -223,6 +235,7 @@ gst_osssink_init (GstOssSink *osssink) osssink->sync = TRUE; osssink->sinkpool = NULL; osssink->provided_clock = GST_CLOCK (gst_oss_clock_new ("ossclock", gst_osssink_get_time, osssink)); + gst_object_set_parent (GST_OBJECT (osssink->provided_clock), GST_OBJECT (osssink)); osssink->handled = 0; GST_FLAG_SET (osssink, GST_ELEMENT_THREAD_SUGGESTED); @@ -623,4 +636,3 @@ gst_osssink_factory_init (GstPlugin *plugin) return TRUE; } - diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c index db810f5908..5f545db0fd 100644 --- a/sys/oss/gstosssrc.c +++ b/sys/oss/gstosssrc.c @@ -87,6 +87,8 @@ GST_PAD_TEMPLATE_FACTORY (osssrc_src_factory, static void gst_osssrc_class_init (GstOssSrcClass *klass); static void gst_osssrc_init (GstOssSrc *osssrc); +static void gst_osssrc_dispose (GObject *object); +static void gst_osssrc_finalize (GObject *object); static GstPadLinkReturn gst_osssrc_srcconnect (GstPad *pad, GstCaps *caps); static const GstFormat* gst_osssrc_get_formats (GstPad *pad); @@ -162,6 +164,8 @@ gst_osssrc_class_init (GstOssSrcClass *klass) gobject_class->set_property = gst_osssrc_set_property; gobject_class->get_property = gst_osssrc_get_property; + gobject_class->dispose = gst_osssrc_dispose; + gobject_class->finalize = gst_osssrc_finalize; gstelement_class->change_state = gst_osssrc_change_state; gstelement_class->send_event = gst_osssrc_send_event; @@ -195,8 +199,29 @@ gst_osssrc_init (GstOssSrc *osssrc) osssrc->provided_clock = GST_CLOCK (gst_oss_clock_new ("ossclock", gst_osssrc_get_time, osssrc)); + gst_object_set_parent (GST_OBJECT (osssrc->provided_clock), GST_OBJECT (osssrc)); + osssrc->clock = NULL; } +static void +gst_osssrc_dispose (GObject *object) +{ + GstOssSrc *osssrc = (GstOssSrc *) object; + + gst_object_unparent (GST_OBJECT (osssrc->provided_clock)); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} +static void +gst_osssrc_finalize (GObject *object) +{ + GstOssSrc *osssrc = (GstOssSrc *) object; + + g_free (osssrc->common.device); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + static GstPadLinkReturn gst_osssrc_srcconnect (GstPad *pad, GstCaps *caps)