gst/gstutils.c: Don't leak pad references.

Original commit message from CVS:
* gst/gstutils.c: (gst_element_unlink_pads):
Don't leak pad references.

* tests/check/elements/fakesink.c: (GST_START_TEST):
* tests/check/generic/sinks.c: (GST_START_TEST):
* tests/check/generic/states.c: (GST_START_TEST):
* tests/check/gst/gstbin.c: (GST_START_TEST):
* tests/check/gst/gstcaps.c: (GST_START_TEST):
* tests/check/gst/gstelement.c: (GST_START_TEST):
* tests/check/gst/gstghostpad.c: (GST_START_TEST):
* tests/check/gst/gstiterator.c: (GST_START_TEST):
* tests/check/gst/gstvalue.c: (GST_START_TEST):
Fix a bunch of leaks. Make generic/sinks.c
use a bit less cpu by slowing the buffer rate
between fakesrc and fakesink.
This commit is contained in:
Jan Schmidt 2006-01-28 00:59:37 +00:00
parent a53172d79d
commit 1559c57a8e
10 changed files with 46 additions and 8 deletions

View file

@ -1710,14 +1710,17 @@ gst_element_unlink_pads (GstElement * src, const gchar * srcpadname,
return;
}
destpad = gst_element_get_pad (dest, destpadname);
if (srcpad == NULL) {
if (destpad == NULL) {
GST_WARNING_OBJECT (dest, "destination element has no pad \"%s\"",
destpadname);
gst_object_unref (srcpad);
return;
}
/* we're satisified they can be unlinked, let's do it */
gst_pad_unlink (srcpad, destpad);
gst_object_unref (srcpad);
gst_object_unref (destpad);
}
/**

View file

@ -208,6 +208,11 @@ GST_START_TEST (test_clipping)
fret = gst_pad_chain (sinkpad, buffer);
fail_if (fret != GST_FLOW_OK);
}
gst_element_set_state (sink, GST_STATE_NULL);
gst_element_get_state (sink, NULL, NULL, GST_CLOCK_TIME_NONE);
gst_object_unref (sinkpad);
gst_object_unref (sink);
}
GST_END_TEST;

View file

@ -86,6 +86,7 @@ GST_START_TEST (test_sink_completion)
GstState current, pending;
sink = gst_element_factory_make ("fakesink", "sink");
g_object_set (G_OBJECT (sink), "sync", TRUE, NULL);
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");
@ -96,6 +97,7 @@ GST_START_TEST (test_sink_completion)
fail_unless (pending == GST_STATE_PLAYING, "bad pending state");
src = gst_element_factory_make ("fakesrc", "src");
g_object_set (G_OBJECT (src), "datarate", 200, "sizetype", 2, NULL);
gst_element_link (src, sink);
ret = gst_element_set_state (src, GST_STATE_PLAYING);
@ -200,6 +202,8 @@ GST_START_TEST (test_livesrc_remove)
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_PAUSED, "not paused");
gst_object_unref (pipeline);
}
GST_END_TEST

View file

@ -54,6 +54,7 @@ GST_START_TEST (test_state_changes)
gst_object_unref (GST_OBJECT (element));
}
gst_plugin_feature_list_free (features);
gst_task_cleanup_all ();
}

View file

@ -57,10 +57,13 @@ GST_START_TEST (test_interface)
gst_bin_add (bin, filesrc);
fail_unless (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
gst_object_unref (filesrc);
it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
fail_unless (it != NULL);
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
fail_unless (item == (gpointer) filesrc);
gst_object_unref (GST_OBJECT (item));
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
gst_iterator_free (it);
@ -68,11 +71,11 @@ GST_START_TEST (test_interface)
gst_element_factory_make ("identity", NULL),
gst_element_factory_make ("identity", NULL),
gst_element_factory_make ("identity", NULL), NULL);
fail_unless (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
fail_unless (it != NULL);
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
fail_unless (item == (gpointer) filesrc);
gst_object_unref (GST_OBJECT (item));
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
gst_iterator_free (it);
@ -83,10 +86,10 @@ GST_START_TEST (test_interface)
gst_element_factory_make ("identity", NULL),
gst_element_factory_make ("identity", NULL),
GST_ELEMENT (bin2), gst_element_factory_make ("identity", NULL), NULL);
fail_unless (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
fail_unless (item == (gpointer) filesrc);
gst_object_unref (GST_OBJECT (item));
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
gst_iterator_free (it);
@ -94,8 +97,11 @@ GST_START_TEST (test_interface)
gst_bin_add (bin2, gst_element_factory_make ("filesrc", NULL));
it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
gst_object_unref (GST_OBJECT (item));
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
gst_object_unref (GST_OBJECT (item));
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
gst_object_unref (GST_OBJECT (item));
fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
gst_iterator_free (it);

View file

@ -43,8 +43,8 @@ GST_START_TEST (test_from_string)
fail_unless (gst_caps_is_equal (caps, caps2));
g_free (caps);
g_free (caps2);
gst_caps_unref (caps);
gst_caps_unref (caps2);
g_free (to_str);
}
}
@ -61,9 +61,13 @@ GST_START_TEST (test_buffer)
"buffer", GST_TYPE_BUFFER, buffer, NULL);
GST_DEBUG ("caps: %" GST_PTR_FORMAT, c1);
gst_buffer_set_caps (buffer, c1); /* gives away our c1 ref */
gst_buffer_unref (buffer);
buffer = gst_buffer_new_and_alloc (1000);
gst_buffer_set_caps (buffer, c1); /* doesn't give away our c1 ref */
gst_caps_unref (c1);
gst_buffer_unref (buffer); /* Should now drop both references */
}
GST_END_TEST;
@ -115,7 +119,7 @@ GST_END_TEST;
GST_START_TEST (test_static_caps)
{
GstStaticCaps scaps = GST_STATIC_CAPS ("audio/x-raw-int,rate=44100");
static GstStaticCaps scaps = GST_STATIC_CAPS ("audio/x-raw-int,rate=44100");
GstCaps *caps1;
GstCaps *caps2;

View file

@ -45,6 +45,7 @@ GST_START_TEST (test_add_remove_pad)
/* clean up our own reference */
gst_object_unref (p);
gst_object_unref (e);
}
GST_END_TEST;
@ -127,11 +128,17 @@ GST_START_TEST (test_link)
gst_element_set_state (sink, GST_STATE_NULL);
gst_element_set_state (src, GST_STATE_NULL);
gst_element_get_state (sink, NULL, NULL, GST_CLOCK_TIME_NONE);
g_usleep (G_USEC_PER_SEC / 2);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
gst_element_unlink_pads (src, "src", sink, "sink");
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
gst_object_unref (src);
gst_object_unref (sink);
}
GST_END_TEST;

View file

@ -58,6 +58,8 @@ GST_START_TEST (test_remove1)
srcpad = gst_element_get_pad (src, "src");
/* pad cannot be linked now */
fail_if (gst_pad_is_linked (srcpad));
gst_object_unref (b1);
}
GST_END_TEST;

View file

@ -70,6 +70,7 @@ GST_START_TEST (test_manual_iteration)
/* clean up */
gst_iterator_free (iter);
g_mutex_free (m);
g_list_free (l);
}
GST_END_TEST;
@ -119,6 +120,7 @@ GST_START_TEST (test_resync)
/* clean up */
gst_iterator_free (iter);
g_mutex_free (m);
g_list_free (l);
}
GST_END_TEST;
@ -160,6 +162,7 @@ GST_START_TEST (test_fold)
/* clean up */
gst_iterator_free (iter);
g_mutex_free (m);
g_list_free (l);
}
GST_END_TEST;

View file

@ -472,6 +472,9 @@ GST_START_TEST (test_value_intersect)
fail_unless (GST_VALUE_HOLDS_FOURCC (&dest));
fail_unless (gst_value_get_fourcc (&dest) ==
GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
g_value_unset (&src1);
g_value_unset (&src2);
}
GST_END_TEST;