3 * Copyright (C) 2005,2008, 2009 Sun Microsystems, Inc.,
4 * Brian Cameron <brian.cameron@sun.com>
5 * Copyright (C) 2009 Sun Microsystems, Inc.,
6 * Garrett D'Amore <garrett.damore@sun.com>
8 * gstsunaudiomixer.c: mixer interface implementation for OSS
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
36 #include <sys/ioctl.h>
37 #include <sys/audioio.h>
39 #include <gst/gst-i18n-plugin.h>
41 #include "gstsunaudiomixertrack.h"
43 #define MASK_BIT_IS_SET(mask, bit) \
46 G_DEFINE_TYPE (GstSunAudioMixerTrack, gst_sunaudiomixer_track,
50 gst_sunaudiomixer_track_class_init (GstSunAudioMixerTrackClass * klass)
56 gst_sunaudiomixer_track_init (GstSunAudioMixerTrack * track)
59 track->balance = AUDIO_MID_BALANCE;
64 gst_sunaudiomixer_track_new (GstSunAudioTrackType track_num)
66 const gchar *labels[] = { N_("Volume"),
69 N_("Built-in Speaker"),
78 GstSunAudioMixerTrack *sunaudiotrack;
81 const gchar *untranslated_label;
83 if ((guint) track_num < G_N_ELEMENTS (labels))
84 untranslated_label = labels[track_num];
86 untranslated_label = NULL;
88 /* FIXME: remove this check once we depend on -base >= 0.10.12.1 */
89 klass = G_OBJECT_CLASS (g_type_class_ref (GST_TYPE_SUNAUDIO_MIXER_TRACK));
90 if (g_object_class_find_property (klass, "untranslated-label")) {
91 sunaudiotrack = g_object_new (GST_TYPE_SUNAUDIO_MIXER_TRACK,
92 "untranslated-label", untranslated_label, NULL);
94 sunaudiotrack = g_object_new (GST_TYPE_SUNAUDIO_MIXER_TRACK, NULL);
96 g_type_class_unref (klass);
99 case GST_SUNAUDIO_TRACK_OUTPUT:
100 /* these are sliders */
101 track = GST_MIXER_TRACK (sunaudiotrack);
102 track->label = g_strdup (_(untranslated_label));
103 track->num_channels = 2;
104 track->flags = GST_MIXER_TRACK_OUTPUT | GST_MIXER_TRACK_WHITELIST |
105 GST_MIXER_TRACK_MASTER;
106 track->min_volume = 0;
107 track->max_volume = 255;
108 sunaudiotrack->track_num = track_num;
109 sunaudiotrack->gain = (0 & 0xff);
110 sunaudiotrack->balance = AUDIO_MID_BALANCE;
112 case GST_SUNAUDIO_TRACK_RECORD:
113 /* these are sliders */
114 track = GST_MIXER_TRACK (sunaudiotrack);
115 track->label = g_strdup (_(untranslated_label));
116 track->num_channels = 2;
117 track->flags = GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD |
118 GST_MIXER_TRACK_WHITELIST;
119 track->min_volume = 0;
120 track->max_volume = 255;
121 sunaudiotrack->track_num = track_num;
122 sunaudiotrack->gain = (0 & 0xff);
123 sunaudiotrack->balance = AUDIO_MID_BALANCE;
125 case GST_SUNAUDIO_TRACK_MONITOR:
126 /* these are sliders */
127 track = GST_MIXER_TRACK (sunaudiotrack);
128 track->label = g_strdup (_(untranslated_label));
129 track->num_channels = 2;
130 track->flags = GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD;
131 track->min_volume = 0;
132 track->max_volume = 255;
133 sunaudiotrack->track_num = track_num;
134 sunaudiotrack->gain = (0 & 0xff);
135 sunaudiotrack->balance = AUDIO_MID_BALANCE;
137 case GST_SUNAUDIO_TRACK_SPEAKER:
138 case GST_SUNAUDIO_TRACK_HP:
139 case GST_SUNAUDIO_TRACK_LINEOUT:
140 case GST_SUNAUDIO_TRACK_SPDIFOUT:
141 case GST_SUNAUDIO_TRACK_AUX1OUT:
142 case GST_SUNAUDIO_TRACK_AUX2OUT:
143 /* these are switches */
144 track = GST_MIXER_TRACK (sunaudiotrack);
145 track->label = g_strdup (_(untranslated_label));
146 track->num_channels = 0;
147 track->flags = GST_MIXER_TRACK_OUTPUT | GST_MIXER_TRACK_WHITELIST;
148 track->min_volume = 0;
149 track->max_volume = 255;
150 sunaudiotrack->track_num = track_num;
151 sunaudiotrack->gain = (0 & 0xff);
152 sunaudiotrack->balance = AUDIO_MID_BALANCE;
155 g_warning ("Unknown sun audio track num %d", track_num);