diff options
author | Michael Smith <msmith@songbirdnest.com> | 2009-02-04 18:09:58 -0800 |
---|---|---|
committer | Michael Smith <msmith@songbirdnest.com> | 2009-02-04 18:09:58 -0800 |
commit | dfa2c64bb8986b3dcf98d5ecc46319f2e2d4d426 (patch) | |
tree | bba7887917c26f28b538aca7b621d4e2631f9716 /sys | |
parent | 2e401cc71da0607966e3b5f31608d326e9819b3e (diff) | |
download | gst-plugins-bad-dfa2c64bb8986b3dcf98d5ecc46319f2e2d4d426.tar.gz gst-plugins-bad-dfa2c64bb8986b3dcf98d5ecc46319f2e2d4d426.tar.bz2 gst-plugins-bad-dfa2c64bb8986b3dcf98d5ecc46319f2e2d4d426.zip |
Fix major leaks in qtwrapper audio decoders.
Free the decoder component and audiobufferlist when caps change, or when
disposing element.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/qtwrapper/audiodecoders.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/sys/qtwrapper/audiodecoders.c b/sys/qtwrapper/audiodecoders.c index 3553c29b..d3fd6d0c 100644 --- a/sys/qtwrapper/audiodecoders.c +++ b/sys/qtwrapper/audiodecoders.c @@ -303,7 +303,7 @@ write_len (guint8 * buf, int val) } static void -aac_parse_codec_data (GstBuffer * codec_data, guint * channels) +aac_parse_codec_data (GstBuffer * codec_data, gint * channels) { guint8 *data = GST_BUFFER_DATA (codec_data); int codec_channels; @@ -389,6 +389,19 @@ make_aac_magic_cookie (GstBuffer * codec_data, gsize * len) return cookie; } +static void +close_decoder (QTWrapperAudioDecoder *qtwrapper) +{ + if (qtwrapper->adec) { + CloseComponent (qtwrapper->adec); + qtwrapper->adec = NULL; + } + + if (qtwrapper->bufferlist) { + DestroyAudioBufferList (qtwrapper->bufferlist); + qtwrapper->bufferlist = NULL; + } +} static gboolean open_decoder (QTWrapperAudioDecoder * qtwrapper, GstCaps * caps, @@ -410,6 +423,9 @@ open_decoder (QTWrapperAudioDecoder * qtwrapper, GstCaps * caps, GstBuffer *codec_data = NULL; gboolean have_esds = FALSE; + /* Clean up any existing decoder */ + close_decoder (qtwrapper); + tmp = gst_caps_to_string (caps); GST_LOG_OBJECT (qtwrapper, "caps: %s", tmp); g_free (tmp); @@ -486,6 +502,7 @@ open_decoder (QTWrapperAudioDecoder * qtwrapper, GstCaps * caps, if (status) { GST_WARNING_OBJECT (qtwrapper, "Error instantiating SCAudio component: %ld", status); + qtwrapper->adec = NULL; goto beach; } @@ -561,6 +578,8 @@ open_decoder (QTWrapperAudioDecoder * qtwrapper, GstCaps * caps, status); goto beach; } + + g_free (magiccookie); } } @@ -957,10 +976,25 @@ qtwrapper_audio_decoder_base_init (QTWrapperAudioDecoderClass * klass) klass->componentSubType = desc.componentSubType; } +static void qtwrapper_audio_decoder_dispose (GObject * object) +{ + QTWrapperAudioDecoder *qtwrapper = (QTWrapperAudioDecoder *)object; + QTWrapperAudioDecoderClass *oclass = (QTWrapperAudioDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); + GObjectClass *parent_class = g_type_class_peek_parent (oclass); + + close_decoder (qtwrapper); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + static void qtwrapper_audio_decoder_class_init (QTWrapperAudioDecoderClass * klass) { - /* FIXME : don't we need some vmethod implementations here ?? */ + GObjectClass *object_class; + + object_class = (GObjectClass *) klass; + + object_class->dispose = qtwrapper_audio_decoder_dispose; } gboolean |