2 * GStreamer SunAudio mixer track implementation
3 * Copyright (C) 2009 Sun Microsystems, Inc.,
4 * Brian Cameron <brian.cameron@sun.com>
5 * Garrett D'Amore <garrett.damore@sun.com>
7 * gstsunaudiomixeroptions.c: Sun Audio mixer options object
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
34 #include <sys/ioctl.h>
35 #include <sys/audio.h>
36 #include <sys/mixer.h>
38 #include <gst/gst-i18n-plugin.h>
40 #include "gstsunaudiomixeroptions.h"
41 #include "gstsunaudiomixertrack.h"
43 GST_DEBUG_CATEGORY_EXTERN (sunaudio_debug);
44 #define GST_CAT_DEFAULT sunaudio_debug
46 static void gst_sunaudiomixer_options_init (GstSunAudioMixerOptions * sun_opts);
47 static void gst_sunaudiomixer_options_class_init (gpointer g_class,
50 static GstMixerOptionsClass *parent_class = NULL;
53 gst_sunaudiomixer_options_get_type (void)
55 static GType opts_type = 0;
58 static const GTypeInfo opts_info = {
59 sizeof (GstSunAudioMixerOptionsClass),
62 gst_sunaudiomixer_options_class_init,
65 sizeof (GstSunAudioMixerOptions),
67 (GInstanceInitFunc) gst_sunaudiomixer_options_init,
71 g_type_register_static (GST_TYPE_MIXER_OPTIONS,
72 "GstSunAudioMixerOptions", &opts_info, 0);
79 gst_sunaudiomixer_options_class_init (gpointer g_class, gpointer class_data)
81 parent_class = g_type_class_peek_parent (g_class);
85 gst_sunaudiomixer_options_init (GstSunAudioMixerOptions * sun_opts)
90 gst_sunaudiomixer_options_new (GstSunAudioMixerCtrl * mixer, gint track_num)
92 GstMixerOptions *opts;
93 GstSunAudioMixerOptions *sun_opts;
97 struct audio_info audioinfo;
99 if ((mixer == NULL) || (mixer->mixer_fd == -1)) {
100 g_warning ("mixer not initialized");
104 if (track_num != GST_SUNAUDIO_TRACK_RECSRC) {
105 g_warning ("invalid options track");
109 label = N_("Record Source");
111 opts = g_object_new (GST_TYPE_SUNAUDIO_MIXER_OPTIONS,
112 "untranslated-label", label, NULL);
113 sun_opts = GST_SUNAUDIO_MIXER_OPTIONS (opts);
114 track = GST_MIXER_TRACK (opts);
116 GST_DEBUG_OBJECT (opts, "New mixer options, track %d: %s",
117 track_num, GST_STR_NULL (label));
119 /* save off names for the record sources */
120 sun_opts->names[0] = g_quark_from_string (_("Microphone"));
121 sun_opts->names[1] = g_quark_from_string (_("Line In"));
122 sun_opts->names[2] = g_quark_from_string (_("Internal CD"));
123 sun_opts->names[3] = g_quark_from_string (_("SPDIF In"));
124 sun_opts->names[4] = g_quark_from_string (_("AUX 1 In"));
125 sun_opts->names[5] = g_quark_from_string (_("AUX 2 In"));
126 sun_opts->names[6] = g_quark_from_string (_("Codec Loopback"));
127 sun_opts->names[7] = g_quark_from_string (_("SunVTS Loopback"));
129 /* set basic information */
130 track->label = g_strdup (_(label));
131 track->num_channels = 0;
132 track->min_volume = 0;
133 track->max_volume = 0;
135 GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_WHITELIST |
136 GST_MIXER_TRACK_NO_RECORD;
138 if (ioctl (mixer->mixer_fd, AUDIO_GETINFO, &audioinfo) < 0) {
139 g_warning ("Error getting audio device settings");
140 g_object_unref (G_OBJECT (sun_opts));
144 sun_opts->avail = audioinfo.record.avail_ports;
145 sun_opts->track_num = track_num;
147 for (i = 0; i < 8; i++) {
148 if ((1 << i) & audioinfo.record.avail_ports) {
149 const char *s = g_quark_to_string (sun_opts->names[i]);
150 opts->values = g_list_append (opts->values, g_strdup (s));
151 GST_DEBUG_OBJECT (opts, "option for track %d: %s",
152 track_num, GST_STR_NULL (s));