1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#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();
element = gst_element_factory_make ("fakesink", NULL);;
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++) {
element = gst_element_factory_make
("fakesink", NULL);;
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++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
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")));
gst_object_unref (GST_OBJECT (element));
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
}
g_print ("create/link/unref %d elements %ld\n", iters/2, vmsize()-usage1);
for (i=0; i<iters/2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
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")));
gst_object_unref (GST_OBJECT (element));
g_assert (GST_OBJECT_DESTROYED (element));
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
gst_object_unref (GST_OBJECT (element));
}
g_print ("create/link/destroy %d elements %ld\n", iters/2, vmsize()-usage1);
element = gst_element_factory_make ("fakesink", NULL);;
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++) {
element = gst_element_factory_make ("fakesink", NULL);;
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++) {
element = gst_element_factory_make ("fakesink", NULL);;
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);
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
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++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
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++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (pad));
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);
}
|