1 /* ALSA mixer object implementation.
2 * Copyright (C) 2003 Leif Johnson <leif@ambient.2y.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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include "gstalsamixeroptions.h"
26 static void gst_alsa_mixer_options_init (GstAlsaMixerOptions * alsa_opts);
27 static void gst_alsa_mixer_options_class_init (gpointer g_class,
30 static GstMixerOptionsClass *parent_class = NULL;
33 gst_alsa_mixer_options_get_type (void)
35 static GType opts_type = 0;
38 static const GTypeInfo opts_info = {
39 sizeof (GstAlsaMixerOptionsClass),
42 gst_alsa_mixer_options_class_init,
45 sizeof (GstAlsaMixerOptions),
47 (GInstanceInitFunc) gst_alsa_mixer_options_init,
51 g_type_register_static (GST_TYPE_MIXER_OPTIONS, "GstAlsaMixerOptions",
59 gst_alsa_mixer_options_class_init (gpointer g_class, gpointer class_data)
61 parent_class = g_type_class_peek_parent (g_class);
65 gst_alsa_mixer_options_init (GstAlsaMixerOptions * alsa_opts)
70 gst_alsa_mixer_options_new (snd_mixer_elem_t * element, gint track_num)
72 GstMixerOptions *opts;
73 GstAlsaMixerOptions *alsa_opts;
80 label = snd_mixer_selem_get_name (element);
81 index = snd_mixer_selem_get_index (element);
83 GST_LOG ("[%s,%u]", label, index);
85 opts = g_object_new (GST_ALSA_MIXER_OPTIONS_TYPE,
86 "untranslated-label", label, "index", index, NULL);
87 alsa_opts = (GstAlsaMixerOptions *) opts;
88 track = (GstMixerTrack *) opts;
90 /* set basic information */
91 track->label = g_strdup (label); /* FIXME: translate this? */
92 track->num_channels = 0;
94 alsa_opts->element = element;
95 alsa_opts->track_num = track_num;
97 /* get enumerations for switch/options object */
98 num = snd_mixer_selem_get_enum_items (element);
99 for (i = 0; i < num; i++) {
100 if (snd_mixer_selem_get_enum_item_name (element, i, 255, str) < 0) {
101 g_object_unref (G_OBJECT (alsa_opts));
105 opts->values = g_list_append (opts->values, g_strdup (str));