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 static void gst_sunaudiomixer_options_init (GstSunAudioMixerOptions * sun_opts);
44 static void gst_sunaudiomixer_options_class_init (gpointer g_class,
47 static GstMixerOptionsClass *parent_class = NULL;
50 gst_sunaudiomixer_options_get_type (void)
52 static GType opts_type = 0;
55 static const GTypeInfo opts_info = {
56 sizeof (GstSunAudioMixerOptionsClass),
59 gst_sunaudiomixer_options_class_init,
62 sizeof (GstSunAudioMixerOptions),
64 (GInstanceInitFunc) gst_sunaudiomixer_options_init,
68 g_type_register_static (GST_TYPE_MIXER_OPTIONS,
69 "GstSunAudioMixerOptions", &opts_info, 0);
76 gst_sunaudiomixer_options_class_init (gpointer g_class, gpointer class_data)
78 parent_class = g_type_class_peek_parent (g_class);
82 gst_sunaudiomixer_options_init (GstSunAudioMixerOptions * sun_opts)
87 gst_sunaudiomixer_options_new (GstSunAudioMixerCtrl * mixer, gint track_num)
89 GstMixerOptions *opts;
90 GstSunAudioMixerOptions *sun_opts;
94 struct audio_info audioinfo;
96 if ((mixer == NULL) || (mixer->mixer_fd == -1)) {
97 g_warning ("mixer not initialized");
101 if (track_num != GST_SUNAUDIO_TRACK_RECSRC) {
102 g_warning ("invalid options track");
106 label = N_("Record Source");
108 opts = g_object_new (GST_TYPE_SUNAUDIO_MIXER_OPTIONS,
109 "untranslated-label", label, NULL);
110 sun_opts = GST_SUNAUDIO_MIXER_OPTIONS (opts);
111 track = GST_MIXER_TRACK (opts);
113 /* save off names for the record sources */
114 sun_opts->names[0] = g_quark_from_string (_("Microphone"));
115 sun_opts->names[1] = g_quark_from_string (_("Line In"));
116 sun_opts->names[2] = g_quark_from_string (_("Internal CD"));
117 sun_opts->names[3] = g_quark_from_string (_("SPDIF In"));
118 sun_opts->names[4] = g_quark_from_string (_("AUX 1 In"));
119 sun_opts->names[5] = g_quark_from_string (_("AUX 2 In"));
120 sun_opts->names[6] = g_quark_from_string (_("Codec Loopback"));
121 sun_opts->names[7] = g_quark_from_string (_("SunVTS Loopback"));
123 /* set basic information */
124 track->label = g_strdup (_(label));
125 track->num_channels = 0;
126 track->min_volume = 0;
127 track->max_volume = 0;
129 GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_WHITELIST |
130 GST_MIXER_TRACK_NO_RECORD;
132 if (ioctl (mixer->mixer_fd, AUDIO_GETINFO, &audioinfo) < 0) {
133 g_warning ("Error getting audio device settings");
134 g_object_unref (G_OBJECT (sun_opts));
138 sun_opts->avail = audioinfo.record.avail_ports;
139 sun_opts->track_num = track_num;
141 for (i = 0; i < 8; i++) {
142 if ((1 << i) & audioinfo.record.avail_ports) {
143 const char *s = g_quark_to_string (sun_opts->names[i]);
144 opts->values = g_list_append (opts->values, g_strdup (s));