tests: audiodecoder: fix broken refcounting in unit test

The set_format vfunc does not pass ownership of the caps
to the decoder, so we mustn't unref the caps there.

gst_event_new_caps() does not take ownership of the caps
passed, so we must unref the caps afterwards.

Fixes leaks when running test in valgrind in 1.4 branch.
This commit is contained in:
Tim-Philipp Müller 2014-12-12 14:56:36 +00:00
parent ee2418effd
commit c57bb51c03

View file

@ -77,7 +77,6 @@ gst_audio_decoder_tester_set_format (GstAudioDecoder * dec, GstCaps * caps)
{ {
GstAudioDecoderTester *tester = (GstAudioDecoderTester *) dec; GstAudioDecoderTester *tester = (GstAudioDecoderTester *) dec;
GstAudioInfo info; GstAudioInfo info;
gst_caps_unref (caps);
if (!tester->setoutputformat_on_decoding) { if (!tester->setoutputformat_on_decoding) {
caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "S32LE", caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "S32LE",
@ -242,7 +241,7 @@ send_startup_events (void)
gst_caps_new_simple ("audio/x-test-custom", "channels", G_TYPE_INT, 2, gst_caps_new_simple ("audio/x-test-custom", "channels", G_TYPE_INT, 2,
"rate", G_TYPE_INT, 44100, NULL); "rate", G_TYPE_INT, 44100, NULL);
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_caps (caps))); fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_caps (caps)));
gst_caps_unref (caps);
} }
#define NUM_BUFFERS 1000 #define NUM_BUFFERS 1000