From 24226284b89b65d7c10784ef9eb5508210c5a1e7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 7 Sep 2010 18:09:12 +0200 Subject: [PATCH] baseaudio: avoid taking extra ref on sink/src Don't take an extra ref on the sink and source because that creates a reference cycle. Instead, use the invalidate method of the clock when the sink and source are freed. This way, we don't call into the time function anymore after the objects are disposed. --- gst-libs/gst/audio/gstbaseaudiosink.c | 11 ++++++----- gst-libs/gst/audio/gstbaseaudiosrc.c | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index 4b40a5e..218984a 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -272,9 +272,8 @@ gst_base_audio_sink_init (GstBaseAudioSink * baseaudiosink, baseaudiosink->provide_clock = DEFAULT_PROVIDE_CLOCK; baseaudiosink->priv->slave_method = DEFAULT_SLAVE_METHOD; - baseaudiosink->provided_clock = gst_audio_clock_new_full ("GstAudioSinkClock", - (GstAudioClockGetTimeFunc) gst_base_audio_sink_get_time, - gst_object_ref (baseaudiosink), (GDestroyNotify) gst_object_unref); + baseaudiosink->provided_clock = gst_audio_clock_new ("GstAudioSinkClock", + (GstAudioClockGetTimeFunc) gst_base_audio_sink_get_time, baseaudiosink); GST_BASE_SINK (baseaudiosink)->can_activate_push = TRUE; GST_BASE_SINK (baseaudiosink)->can_activate_pull = DEFAULT_CAN_ACTIVATE_PULL; @@ -311,9 +310,11 @@ gst_base_audio_sink_dispose (GObject * object) sink = GST_BASE_AUDIO_SINK (object); - if (sink->provided_clock) + if (sink->provided_clock) { + gst_audio_clock_invalidate (sink->provided_clock); gst_object_unref (sink->provided_clock); - sink->provided_clock = NULL; + sink->provided_clock = NULL; + } if (sink->ringbuffer) { gst_object_unparent (GST_OBJECT_CAST (sink->ringbuffer)); diff --git a/gst-libs/gst/audio/gstbaseaudiosrc.c b/gst-libs/gst/audio/gstbaseaudiosrc.c index b870ff4..a12dd59 100644 --- a/gst-libs/gst/audio/gstbaseaudiosrc.c +++ b/gst-libs/gst/audio/gstbaseaudiosrc.c @@ -250,9 +250,8 @@ gst_base_audio_src_init (GstBaseAudioSrc * baseaudiosrc, * value based on negotiated format. */ GST_BASE_SRC (baseaudiosrc)->blocksize = 0; - baseaudiosrc->clock = gst_audio_clock_new_full ("GstAudioSrcClock", - (GstAudioClockGetTimeFunc) gst_base_audio_src_get_time, - gst_object_ref (baseaudiosrc), (GDestroyNotify) gst_object_unref); + baseaudiosrc->clock = gst_audio_clock_new ("GstAudioSrcClock", + (GstAudioClockGetTimeFunc) gst_base_audio_src_get_time, baseaudiosrc); /* we are always a live source */ gst_base_src_set_live (GST_BASE_SRC (baseaudiosrc), TRUE); @@ -268,9 +267,11 @@ gst_base_audio_src_dispose (GObject * object) src = GST_BASE_AUDIO_SRC (object); GST_OBJECT_LOCK (src); - if (src->clock) + if (src->clock) { + gst_audio_clock_invalidate (src->clock); gst_object_unref (src->clock); - src->clock = NULL; + src->clock = NULL; + } if (src->ringbuffer) { gst_object_unparent (GST_OBJECT_CAST (src->ringbuffer)); -- 2.7.4