1 /* GStreamer OSS4 audio tests
2 * Copyright (C) 2007-2008 Tim-Philipp Müller <tim centricular net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 /* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
21 * with newer GLib versions (>= 2.31.0) */
22 #define GLIB_DISABLE_DEPRECATION_WARNINGS
33 static gboolean opt_show_mixer_messages = FALSE;
35 #define WAIT_TIME 60.0 /* in seconds */
38 probe_pad (GstElement * element, const gchar * pad_name)
44 pad = gst_element_get_static_pad (element, pad_name);
48 caps = gst_pad_query_caps (pad, NULL);
49 g_return_if_fail (caps != NULL);
51 for (i = 0; i < gst_caps_get_size (caps); ++i) {
54 s = gst_structure_to_string (gst_caps_get_structure (caps, i));
55 g_print (" %4s[%d]: %s\n", GST_PAD_NAME (pad), i, s);
58 gst_caps_unref (caps);
59 gst_object_unref (pad);
63 probe_details (GstElement * element)
65 GstStateChangeReturn ret;
67 ret = gst_element_set_state (element, GST_STATE_READY);
68 if (ret == GST_STATE_CHANGE_FAILURE) {
69 g_print ("Could not set element %s to READY.", GST_ELEMENT_NAME (element));
73 probe_pad (element, "sink");
74 probe_pad (element, "src");
76 gst_element_set_state (element, GST_STATE_NULL);
80 probe_element (const gchar * name)
83 gchar *devname = NULL;
85 element = gst_element_factory_make (name, name);
87 /* make sure we don't deadlock on GST_ELEMENT_ERROR or do other silly things
88 * if we try to query the "device-name" property when the device isn't open */
89 g_object_set (element, "device", "/dev/does/not/exist", NULL);
90 g_object_get (element, "device-name", &devname, NULL);
91 GST_LOG ("devname: '%s'", GST_STR_NULL (devname));
92 g_assert (devname == NULL || *devname == '\0');
94 /* and now for real */
96 probe_details (element);
98 gst_object_unref (element);
102 main (int argc, char **argv)
104 GOptionEntry options[] = {
105 {"show-mixer-messages", 'm', 0, G_OPTION_ARG_NONE, &opt_show_mixer_messages,
106 "For mixer elements, wait 60 seconds and show any mixer messages "
107 "(for debugging auto-notifications)", NULL},
113 ctx = g_option_context_new ("");
114 g_option_context_add_main_entries (ctx, options, NULL);
115 g_option_context_add_group (ctx, gst_init_get_option_group ());
116 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
117 g_print ("Error initializing: %s\n", err->message);
118 g_option_context_free (ctx);
119 g_clear_error (&err);
122 g_option_context_free (ctx);
124 probe_element ("oss4sink");
125 probe_element ("oss4src");