2001-05-25 21:00:07 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#define ITERS 100000
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "mem.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, gchar *argv[])
|
|
|
|
{
|
|
|
|
GstElement *element;
|
|
|
|
GstElement *element2;
|
|
|
|
GstPad *pad;
|
|
|
|
long usage1;
|
|
|
|
gint i, iters;
|
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
iters = atoi (argv[1]);
|
|
|
|
else
|
|
|
|
iters = ITERS;
|
|
|
|
|
|
|
|
|
|
|
|
g_print ("starting element with pad test with %d iterations\n", iters);
|
|
|
|
usage1 = vmsize();
|
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
|
|
|
g_assert (GST_OBJECT_FLOATING (element));
|
|
|
|
g_assert (!GST_OBJECT_FLOATING (pad));
|
|
|
|
g_assert (gst_pad_get_parent (pad) == element);
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
g_print ("create/addpad/unref new element %ld\n", vmsize()-usage1);
|
|
|
|
|
|
|
|
for (i=0; i<iters; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make
|
|
|
|
("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
|
|
|
g_print ("create/addpad/unref %d elements %ld\n", iters, vmsize()-usage1);
|
|
|
|
|
|
|
|
for (i=0; i<iters/2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
element2 = gst_element_factory_make ("fakesrc", NULL);
|
2003-01-10 04:54:20 +00:00
|
|
|
gst_element_link_pads (element, "sink", element2, "src");
|
|
|
|
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
|
|
|
|
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink")));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
2003-01-10 04:54:20 +00:00
|
|
|
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element2));
|
|
|
|
}
|
2003-01-10 04:54:20 +00:00
|
|
|
g_print ("create/link/unref %d elements %ld\n", iters/2, vmsize()-usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
for (i=0; i<iters/2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
element2 = gst_element_factory_make ("fakesrc", NULL);
|
2003-01-10 04:54:20 +00:00
|
|
|
gst_element_link_pads (element, "sink", element2, "src");
|
|
|
|
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
|
|
|
|
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink")));
|
2003-04-15 18:17:24 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
g_assert (GST_OBJECT_DESTROYED (element));
|
2003-01-10 04:54:20 +00:00
|
|
|
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element2));
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
2003-01-10 04:54:20 +00:00
|
|
|
g_print ("create/link/destroy %d elements %ld\n", iters/2, vmsize()-usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
|
|
|
gst_element_remove_pad (element, pad);
|
|
|
|
g_assert (gst_element_get_pad (element, "sink") == NULL);
|
|
|
|
|
|
|
|
g_print ("pad removal ok %ld\n", vmsize()-usage1);
|
|
|
|
for (i=0; i<iters/2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
|
|
|
gst_element_remove_pad (element, pad);
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
|
|
|
g_print ("pad removal loop %d %ld\n", iters/2, vmsize()-usage1);
|
|
|
|
|
|
|
|
for (i=0; i<iters/2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
|
|
|
gst_object_ref (GST_OBJECT (pad));
|
|
|
|
gst_element_remove_pad (element, pad);
|
|
|
|
g_assert (gst_pad_get_parent (pad) == NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (pad));
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
|
|
|
g_print ("pad removal and test loop %d %ld\n", iters/2, vmsize()-usage1);
|
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2003-04-15 18:17:24 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
g_assert (GST_OBJECT_DESTROYED (element));
|
|
|
|
g_assert (gst_element_get_pad (element, "sink") == NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
|
|
|
|
g_print ("pad destroy/removal ok %ld\n", vmsize()-usage1);
|
|
|
|
|
|
|
|
for (i=0; i<iters/2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2003-04-15 18:17:24 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
|
|
|
g_print ("pad destroy/removal loop %d %ld\n", iters/2, vmsize()-usage1);
|
|
|
|
|
|
|
|
for (i=0; i<iters/2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2003-04-15 18:17:24 +00:00
|
|
|
gst_object_unref (GST_OBJECT (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
g_assert (gst_element_get_pad (element, "sink") == NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
|
|
|
g_print ("pad destroy loop %d %ld\n", iters/2, vmsize()-usage1);
|
|
|
|
|
|
|
|
g_print ("leaked: %ld\n", vmsize()-usage1);
|
|
|
|
|
|
|
|
return (vmsize()-usage1 ? -1 : 0);
|
|
|
|
}
|