fixing up tests to work with property callbacks
[platform/upstream/gstreamer.git] / testsuite / elements / property.h
1 /* extracted from gst-launch */
2 static void
3 property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec)
4 {
5   GValue value = { 0, }; /* the important thing is that value.type = 0 */
6   gchar *str = 0;
7
8   if (pspec->flags & G_PARAM_READABLE) {
9     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
10     g_object_get_property (G_OBJECT (orig), pspec->name, &value);
11     /* fix current bug with g_strdup_value_contents not working with gint64 */
12     if (G_IS_PARAM_SPEC_INT64 (pspec))
13       str = g_strdup_printf ("%lld", g_value_get_int64 (&value));
14     else
15       str = g_strdup_value_contents (&value);
16     g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str);
17     g_free (str);
18     g_value_unset(&value);
19   } else {
20     g_warning ("Parameter not readable. What's up with that?");
21   }
22 }
23