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 GST_DEBUG_CATEGORY_EXTERN (sunaudio_debug);
44 #define GST_CAT_DEFAULT sunaudio_debug
46 #define MASK_BIT_IS_SET(mask, bit) \
49 G_DEFINE_TYPE (GstSunAudioMixerTrack, gst_sunaudiomixer_track,
50 GST_TYPE_MIXER_TRACK);
53 gst_sunaudiomixer_track_class_init (GstSunAudioMixerTrackClass * klass)
59 gst_sunaudiomixer_track_init (GstSunAudioMixerTrack * track)
62 track->balance = AUDIO_MID_BALANCE;
67 gst_sunaudiomixer_track_new (GstSunAudioTrackType track_num)
69 const gchar *labels[] = { N_("Volume"),
72 N_("Built-in Speaker"),
81 GstSunAudioMixerTrack *sunaudiotrack;
83 const gchar *untranslated_label;
85 if ((guint) track_num < G_N_ELEMENTS (labels))
86 untranslated_label = labels[track_num];
88 untranslated_label = NULL;
90 sunaudiotrack = g_object_new (GST_TYPE_SUNAUDIO_MIXER_TRACK,
91 "untranslated-label", untranslated_label, NULL);
93 GST_DEBUG_OBJECT (sunaudiotrack, "Creating new mixer track of type %d: %s",
94 track_num, GST_STR_NULL (untranslated_label));
97 case GST_SUNAUDIO_TRACK_OUTPUT:
98 /* these are sliders */
99 track = GST_MIXER_TRACK (sunaudiotrack);
100 track->label = g_strdup (_(untranslated_label));
101 track->num_channels = 2;
102 track->flags = GST_MIXER_TRACK_OUTPUT | GST_MIXER_TRACK_WHITELIST |
103 GST_MIXER_TRACK_MASTER;
104 track->min_volume = 0;
105 track->max_volume = 255;
106 sunaudiotrack->track_num = track_num;
107 sunaudiotrack->gain = (0 & 0xff);
108 sunaudiotrack->balance = AUDIO_MID_BALANCE;
110 case GST_SUNAUDIO_TRACK_RECORD:
111 /* these are sliders */
112 track = GST_MIXER_TRACK (sunaudiotrack);
113 track->label = g_strdup (_(untranslated_label));
114 track->num_channels = 2;
115 track->flags = GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD |
116 GST_MIXER_TRACK_WHITELIST;
117 track->min_volume = 0;
118 track->max_volume = 255;
119 sunaudiotrack->track_num = track_num;
120 sunaudiotrack->gain = (0 & 0xff);
121 sunaudiotrack->balance = AUDIO_MID_BALANCE;
123 case GST_SUNAUDIO_TRACK_MONITOR:
124 /* these are sliders */
125 track = GST_MIXER_TRACK (sunaudiotrack);
126 track->label = g_strdup (_(untranslated_label));
127 track->num_channels = 2;
128 track->flags = GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD;
129 track->min_volume = 0;
130 track->max_volume = 255;
131 sunaudiotrack->track_num = track_num;
132 sunaudiotrack->gain = (0 & 0xff);
133 sunaudiotrack->balance = AUDIO_MID_BALANCE;
135 case GST_SUNAUDIO_TRACK_SPEAKER:
136 case GST_SUNAUDIO_TRACK_HP:
137 case GST_SUNAUDIO_TRACK_LINEOUT:
138 case GST_SUNAUDIO_TRACK_SPDIFOUT:
139 case GST_SUNAUDIO_TRACK_AUX1OUT:
140 case GST_SUNAUDIO_TRACK_AUX2OUT:
141 /* these are switches */
142 track = GST_MIXER_TRACK (sunaudiotrack);
143 track->label = g_strdup (_(untranslated_label));
144 track->num_channels = 0;
145 track->flags = GST_MIXER_TRACK_OUTPUT | GST_MIXER_TRACK_WHITELIST;
146 track->min_volume = 0;
147 track->max_volume = 255;
148 sunaudiotrack->track_num = track_num;
149 sunaudiotrack->gain = (0 & 0xff);
150 sunaudiotrack->balance = AUDIO_MID_BALANCE;
153 g_warning ("Unknown sun audio track num %d", track_num);