1 /* ALSA mixer interface implementation.
2 * Copyright (C) 2003 Leif Johnson <leif@ambient.2y.net>
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.
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.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __GST_ALSA_MIXER_H__
21 #define __GST_ALSA_MIXER_H__
26 #include <gst/interfaces/mixer.h>
27 #include "gstalsamixeroptions.h"
28 #include "gstalsamixertrack.h"
33 /* This does not get you what you think it does, use obj->mixer */
34 /* #define GST_ALSA_MIXER(obj) ((GstAlsaMixer*)(obj)) */
36 typedef struct _GstAlsaMixer GstAlsaMixer;
39 GST_ALSA_MIXER_CAPTURE = 1<<0,
40 GST_ALSA_MIXER_PLAYBACK = 1<<1,
41 GST_ALSA_MIXER_ALL = GST_ALSA_MIXER_CAPTURE | GST_ALSA_MIXER_PLAYBACK
42 } GstAlsaMixerDirection;
47 * Opaque data structure
51 GList * tracklist; /* list of available tracks */
56 GStaticRecMutex * task_mutex;
57 GStaticRecMutex * rec_mutex;
65 GstAlsaMixerDirection dir;
69 GstAlsaMixer* gst_alsa_mixer_new (const gchar *device,
70 GstAlsaMixerDirection dir);
71 void gst_alsa_mixer_free (GstAlsaMixer *mixer);
73 const GList* gst_alsa_mixer_list_tracks (GstAlsaMixer * mixer);
74 void gst_alsa_mixer_set_volume (GstAlsaMixer * mixer,
75 GstMixerTrack * track,
77 void gst_alsa_mixer_get_volume (GstAlsaMixer * mixer,
78 GstMixerTrack * track,
80 void gst_alsa_mixer_set_record (GstAlsaMixer * mixer,
81 GstMixerTrack * track,
83 void gst_alsa_mixer_set_mute (GstAlsaMixer * mixer,
84 GstMixerTrack * track,
86 void gst_alsa_mixer_set_option (GstAlsaMixer * mixer,
87 GstMixerOptions * opts,
89 const gchar* gst_alsa_mixer_get_option (GstAlsaMixer * mixer,
90 GstMixerOptions * opts);
91 void _gst_alsa_mixer_set_interface (GstAlsaMixer * mixer,
92 GstMixer * interface);
93 GstMixerFlags gst_alsa_mixer_get_mixer_flags (GstAlsaMixer *mixer);
95 #define GST_IMPLEMENT_ALSA_MIXER_METHODS(Type, interface_as_function) \
97 interface_as_function ## _supported (Type *this, GType iface_type) \
99 g_assert (iface_type == GST_TYPE_MIXER); \
101 return (this->mixer != NULL); \
104 static const GList* \
105 interface_as_function ## _list_tracks (GstMixer * mixer) \
107 Type *this = (Type*) mixer; \
109 g_return_val_if_fail (this != NULL, NULL); \
110 g_return_val_if_fail (this->mixer != NULL, NULL); \
112 return gst_alsa_mixer_list_tracks (this->mixer); \
116 interface_as_function ## _set_volume (GstMixer * mixer, GstMixerTrack * track, \
119 Type *this = (Type*) mixer; \
121 g_return_if_fail (this != NULL); \
122 g_return_if_fail (this->mixer != NULL); \
124 gst_alsa_mixer_set_volume (this->mixer, track, volumes); \
128 interface_as_function ## _get_volume (GstMixer * mixer, GstMixerTrack * track, \
131 Type *this = (Type*) mixer; \
133 g_return_if_fail (this != NULL); \
134 g_return_if_fail (this->mixer != NULL); \
136 gst_alsa_mixer_get_volume (this->mixer, track, volumes); \
140 interface_as_function ## _set_record (GstMixer * mixer, GstMixerTrack * track, \
143 Type *this = (Type*) mixer; \
145 g_return_if_fail (this != NULL); \
146 g_return_if_fail (this->mixer != NULL); \
148 gst_alsa_mixer_set_record (this->mixer, track, record); \
152 interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track, \
155 Type *this = (Type*) mixer; \
157 g_return_if_fail (this != NULL); \
158 g_return_if_fail (this->mixer != NULL); \
160 gst_alsa_mixer_set_mute (this->mixer, track, mute); \
164 interface_as_function ## _set_option (GstMixer * mixer, GstMixerOptions * opts, \
167 Type *this = (Type*) mixer; \
169 g_return_if_fail (this != NULL); \
170 g_return_if_fail (this->mixer != NULL); \
172 gst_alsa_mixer_set_option (this->mixer, opts, value); \
175 static const gchar* \
176 interface_as_function ## _get_option (GstMixer * mixer, GstMixerOptions * opts) \
178 Type *this = (Type*) mixer; \
180 g_return_val_if_fail (this != NULL, NULL); \
181 g_return_val_if_fail (this->mixer != NULL, NULL); \
183 return gst_alsa_mixer_get_option (this->mixer, opts); \
186 static GstMixerFlags \
187 interface_as_function ## _get_mixer_flags (GstMixer * mixer) \
189 Type *this = (Type*) mixer; \
191 g_return_val_if_fail (this != NULL, GST_MIXER_FLAG_NONE); \
192 g_return_val_if_fail (this->mixer != NULL, GST_MIXER_FLAG_NONE); \
194 return gst_alsa_mixer_get_mixer_flags (this->mixer); \
198 interface_as_function ## _interface_init (GstMixerClass * klass) \
200 GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE; \
202 /* set up the interface hooks */ \
203 klass->list_tracks = interface_as_function ## _list_tracks; \
204 klass->set_volume = interface_as_function ## _set_volume; \
205 klass->get_volume = interface_as_function ## _get_volume; \
206 klass->set_mute = interface_as_function ## _set_mute; \
207 klass->set_record = interface_as_function ## _set_record; \
208 klass->set_option = interface_as_function ## _set_option; \
209 klass->get_option = interface_as_function ## _get_option; \
210 klass->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
217 #endif /* __GST_ALSA_MIXER_H__ */