1 | #include <gst/gst.h> |
---|
2 | |
---|
3 | #define ITERS 100 |
---|
4 | #include <stdlib.h> |
---|
5 | #include "mem.h" |
---|
6 | |
---|
7 | GstStaticPadTemplate templ = GST_STATIC_PAD_TEMPLATE ("default", |
---|
8 | GST_PAD_SINK, |
---|
9 | GST_PAD_ALWAYS, |
---|
10 | GST_STATIC_CAPS_ANY); |
---|
11 | |
---|
12 | int |
---|
13 | main (int argc, gchar * argv[]) |
---|
14 | { |
---|
15 | GstPad *pad; |
---|
16 | GstPadTemplate *padtempl; |
---|
17 | long usage1; |
---|
18 | gint i, iters; |
---|
19 | |
---|
20 | gst_alloc_trace_set_flags_all (GST_ALLOC_TRACE_LIVE); |
---|
21 | |
---|
22 | gst_init (&argc, &argv); |
---|
23 | |
---|
24 | g_mem_profile (); |
---|
25 | |
---|
26 | if (argc == 2) |
---|
27 | iters = atoi (argv[1]); |
---|
28 | else |
---|
29 | iters = ITERS; |
---|
30 | |
---|
31 | //gst_alloc_trace_print_all (); |
---|
32 | |
---|
33 | g_print ("starting pad test\n"); |
---|
34 | usage1 = vmsize (); |
---|
35 | |
---|
36 | g_print ("DEBUG: creating new pad with name padname\n"); |
---|
37 | pad = |
---|
38 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
39 | "padname"); |
---|
40 | g_print ("DEBUG: unreffing new pad with name padname\n"); |
---|
41 | gst_object_unref (GST_OBJECT (pad)); |
---|
42 | g_print ("create/unref new pad %ld\n", vmsize () - usage1); |
---|
43 | |
---|
44 | for (i = 0; i < iters; i++) { |
---|
45 | pad = |
---|
46 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
47 | "padname"); |
---|
48 | gst_object_unref (GST_OBJECT (pad)); |
---|
49 | } |
---|
50 | g_print ("create/unref %d pads %ld\n", iters, vmsize () - usage1); |
---|
51 | |
---|
52 | pad = |
---|
53 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
54 | "padname"); |
---|
55 | g_assert (GST_OBJECT_FLOATING (pad)); |
---|
56 | gst_object_ref (GST_OBJECT (pad)); |
---|
57 | gst_object_sink (GST_OBJECT (pad)); |
---|
58 | g_assert (!GST_OBJECT_FLOATING (pad)); |
---|
59 | gst_object_unref (GST_OBJECT (pad)); |
---|
60 | g_print ("create/ref/sink/unref new pad %ld\n", vmsize () - usage1); |
---|
61 | |
---|
62 | for (i = 0; i < iters; i++) { |
---|
63 | pad = |
---|
64 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
65 | "padname"); |
---|
66 | gst_object_ref (GST_OBJECT (pad)); |
---|
67 | gst_object_sink (GST_OBJECT (pad)); |
---|
68 | gst_object_unref (GST_OBJECT (pad)); |
---|
69 | } |
---|
70 | g_print ("create/ref/sink/unref %d pads %ld\n", iters, vmsize () - usage1); |
---|
71 | |
---|
72 | pad = |
---|
73 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
74 | "padname"); |
---|
75 | gst_object_ref (GST_OBJECT (pad)); |
---|
76 | gst_object_unref (GST_OBJECT (pad)); |
---|
77 | gst_object_unref (GST_OBJECT (pad)); |
---|
78 | g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1); |
---|
79 | |
---|
80 | for (i = 0; i < iters; i++) { |
---|
81 | pad = |
---|
82 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
83 | "padname"); |
---|
84 | gst_object_ref (GST_OBJECT (pad)); |
---|
85 | gst_object_unref (GST_OBJECT (pad)); |
---|
86 | gst_object_unref (GST_OBJECT (pad)); |
---|
87 | } |
---|
88 | g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1); |
---|
89 | |
---|
90 | pad = |
---|
91 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
92 | "padname"); |
---|
93 | gst_object_ref (GST_OBJECT (pad)); |
---|
94 | gst_object_unref (GST_OBJECT (pad)); |
---|
95 | gst_object_unref (GST_OBJECT (pad)); |
---|
96 | g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1); |
---|
97 | |
---|
98 | for (i = 0; i < iters; i++) { |
---|
99 | pad = |
---|
100 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
101 | "padname"); |
---|
102 | gst_object_ref (GST_OBJECT (pad)); |
---|
103 | gst_object_unref (GST_OBJECT (pad)); |
---|
104 | gst_object_unref (GST_OBJECT (pad)); |
---|
105 | } |
---|
106 | g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1); |
---|
107 | |
---|
108 | for (i = 0; i < iters; i++) { |
---|
109 | pad = |
---|
110 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
111 | "padname"); |
---|
112 | gst_object_ref (GST_OBJECT (pad)); |
---|
113 | gst_pad_set_name (pad, "testing123"); |
---|
114 | gst_object_unref (GST_OBJECT (pad)); |
---|
115 | gst_pad_set_name (pad, "testing123"); |
---|
116 | gst_object_unref (GST_OBJECT (pad)); |
---|
117 | } |
---|
118 | g_print ("create/ref/unref/unref %d pads %ld with name\n", iters, |
---|
119 | vmsize () - usage1); |
---|
120 | |
---|
121 | pad = |
---|
122 | gst_pad_new_from_template (gst_static_pad_template_get (&templ), |
---|
123 | "padname"); |
---|
124 | for (i = 0; i < iters; i++) { |
---|
125 | gst_pad_set_name (pad, "testing"); |
---|
126 | } |
---|
127 | gst_object_unref (GST_OBJECT (pad)); |
---|
128 | g_print ("set name %d times %ld\n", iters, vmsize () - usage1); |
---|
129 | |
---|
130 | for (i = 0; i < iters; i++) { |
---|
131 | padtempl = |
---|
132 | gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, |
---|
133 | gst_caps_new_any ()); |
---|
134 | gst_object_unref (GST_OBJECT (padtempl)); |
---|
135 | } |
---|
136 | g_print ("%d padtemplates create/unref %ld\n", iters, vmsize () - usage1); |
---|
137 | |
---|
138 | for (i = 0; i < iters; i++) { |
---|
139 | padtempl = |
---|
140 | gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, |
---|
141 | gst_caps_new_any ()); |
---|
142 | pad = gst_pad_new_from_template (padtempl, "sink1"); |
---|
143 | gst_object_unref (GST_OBJECT (pad)); |
---|
144 | } |
---|
145 | g_print ("%d pads create/unref from padtemplate %ld\n", iters, |
---|
146 | vmsize () - usage1); |
---|
147 | |
---|
148 | g_print ("leaked: %ld\n", vmsize () - usage1); |
---|
149 | |
---|
150 | //gst_alloc_trace_print_all (); |
---|
151 | |
---|
152 | return 0; |
---|
153 | } |
---|