|
1 /* ALSA mixer object implementation. |
|
2 * Copyright (C) 2003 Leif Johnson <leif@ambient.2y.net> |
|
3 * |
|
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. |
|
8 * |
|
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. |
|
13 * |
|
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. |
|
18 */ |
|
19 |
|
20 #ifdef HAVE_CONFIG_H |
|
21 #include "config.h" |
|
22 #endif |
|
23 |
|
24 #include "gstalsamixeroptions.h" |
|
25 |
|
26 static void gst_alsa_mixer_options_init (GstAlsaMixerOptions * alsa_opts); |
|
27 static void gst_alsa_mixer_options_class_init (gpointer g_class, |
|
28 gpointer class_data); |
|
29 |
|
30 static GstMixerOptionsClass *parent_class = NULL; |
|
31 |
|
32 GType |
|
33 gst_alsa_mixer_options_get_type (void) |
|
34 { |
|
35 static GType opts_type = 0; |
|
36 |
|
37 if (!opts_type) { |
|
38 static const GTypeInfo opts_info = { |
|
39 sizeof (GstAlsaMixerOptionsClass), |
|
40 NULL, |
|
41 NULL, |
|
42 gst_alsa_mixer_options_class_init, |
|
43 NULL, |
|
44 NULL, |
|
45 sizeof (GstAlsaMixerOptions), |
|
46 0, |
|
47 (GInstanceInitFunc) gst_alsa_mixer_options_init, |
|
48 }; |
|
49 |
|
50 opts_type = |
|
51 g_type_register_static (GST_TYPE_MIXER_OPTIONS, "GstAlsaMixerOptions", |
|
52 &opts_info, 0); |
|
53 } |
|
54 |
|
55 return opts_type; |
|
56 } |
|
57 |
|
58 static void |
|
59 gst_alsa_mixer_options_class_init (gpointer g_class, gpointer class_data) |
|
60 { |
|
61 parent_class = g_type_class_peek_parent (g_class); |
|
62 } |
|
63 |
|
64 static void |
|
65 gst_alsa_mixer_options_init (GstAlsaMixerOptions * alsa_opts) |
|
66 { |
|
67 } |
|
68 |
|
69 GstMixerOptions * |
|
70 gst_alsa_mixer_options_new (snd_mixer_elem_t * element, gint track_num) |
|
71 { |
|
72 GstMixerOptions *opts; |
|
73 GstAlsaMixerOptions *alsa_opts; |
|
74 GstMixerTrack *track; |
|
75 const gchar *label; |
|
76 gint num, i; |
|
77 gchar str[256]; |
|
78 |
|
79 label = snd_mixer_selem_get_name (element); |
|
80 |
|
81 opts = g_object_new (GST_ALSA_MIXER_OPTIONS_TYPE, |
|
82 "untranslated-label", label, NULL); |
|
83 alsa_opts = (GstAlsaMixerOptions *) opts; |
|
84 track = (GstMixerTrack *) opts; |
|
85 |
|
86 /* set basic information */ |
|
87 track->label = g_strdup (label); /* FIXME: translate this? */ |
|
88 track->num_channels = 0; |
|
89 track->flags = 0; |
|
90 alsa_opts->element = element; |
|
91 alsa_opts->track_num = track_num; |
|
92 |
|
93 /* get enumerations for switch/options object */ |
|
94 num = snd_mixer_selem_get_enum_items (element); |
|
95 for (i = 0; i < num; i++) { |
|
96 if (snd_mixer_selem_get_enum_item_name (element, i, 255, str) < 0) { |
|
97 g_object_unref (G_OBJECT (alsa_opts)); |
|
98 return NULL; |
|
99 } |
|
100 |
|
101 opts->values = g_list_append (opts->values, g_strdup (str)); |
|
102 } |
|
103 |
|
104 return opts; |
|
105 } |