Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / sys / sunaudio / gstsunaudiomixerctrl.h
1 /*
2  * GStreamer - SunAudio mixer interface element.
3  * Copyright (C) 2005,2006,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>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #ifndef __GST_SUNAUDIO_MIXER_CTRL_H
24 #define __GST_SUNAUDIO_MIXER_CTRL_H
25
26 #include <sys/audioio.h>
27
28 #include <gst/gst.h>
29 #include <gst/interfaces/mixer.h>
30
31 G_BEGIN_DECLS
32
33 #define GST_SUNAUDIO_MIXER_CTRL(obj)              ((GstSunAudioMixerCtrl*)(obj))
34
35 typedef struct _GstSunAudioMixerCtrl GstSunAudioMixerCtrl;
36
37 struct _GstSunAudioMixerCtrl {
38   GList *               tracklist;      /* list of available tracks */
39
40   gint                  fd;
41   gint                  mixer_fd;
42
43   gchar *               device;
44 };
45
46 GstSunAudioMixerCtrl* gst_sunaudiomixer_ctrl_new          (const gchar *device);
47 void                  gst_sunaudiomixer_ctrl_free         (GstSunAudioMixerCtrl *mixer);
48
49 const GList*          gst_sunaudiomixer_ctrl_list_tracks  (GstSunAudioMixerCtrl * mixer);
50 void                  gst_sunaudiomixer_ctrl_set_volume   (GstSunAudioMixerCtrl * mixer,
51                                                           GstMixerTrack * track,
52                                                           gint * volumes);
53 void                  gst_sunaudiomixer_ctrl_get_volume   (GstSunAudioMixerCtrl * mixer,
54                                                           GstMixerTrack * track,
55                                                           gint * volumes);
56 void                  gst_sunaudiomixer_ctrl_set_record   (GstSunAudioMixerCtrl * mixer,
57                                                           GstMixerTrack * track,
58                                                           gboolean record);
59 void                  gst_sunaudiomixer_ctrl_set_mute     (GstSunAudioMixerCtrl * mixer,
60                                                              GstMixerTrack * track,
61                                                           gboolean mute);
62 void                  gst_sunaudiomixer_ctrl_set_option   (GstSunAudioMixerCtrl * mixer,
63                                                           GstMixerOptions * options,
64                                                           gchar * value);
65 const gchar *         gst_sunaudiomixer_ctrl_get_option   (GstSunAudioMixerCtrl * mixer,
66                                                           GstMixerOptions * options);
67 GstMixerFlags         gst_sunaudiomixer_ctrl_get_mixer_flags      (GstSunAudioMixerCtrl *mixer);
68
69 #define GST_IMPLEMENT_SUNAUDIO_MIXER_CTRL_METHODS(Type, interface_as_function)  \
70 static gboolean                                                                 \
71 interface_as_function ## _supported (Type *this, GType iface_type)              \
72 {                                                                               \
73   g_assert (iface_type == GST_TYPE_MIXER);                                      \
74                                                                                 \
75   return (this->mixer != NULL);                                                 \
76 }                                                                               \
77                                                                                 \
78 static const GList*                                                             \
79 interface_as_function ## _list_tracks (GstMixer * mixer)                        \
80 {                                                                               \
81   Type *this = (Type*) mixer;                                                   \
82                                                                                 \
83   g_return_val_if_fail (this != NULL, NULL);                                    \
84   g_return_val_if_fail (this->mixer != NULL, NULL);                             \
85                                                                                 \
86   return gst_sunaudiomixer_ctrl_list_tracks (this->mixer);                      \
87 }                                                                               \
88                                                                                 \
89 static void                                                                     \
90 interface_as_function ## _set_volume (GstMixer * mixer, GstMixerTrack * track,  \
91     gint * volumes)                                                             \
92 {                                                                               \
93   Type *this = (Type*) mixer;                                                   \
94                                                                                 \
95   g_return_if_fail (this != NULL);                                              \
96   g_return_if_fail (this->mixer != NULL);                                       \
97                                                                                 \
98   gst_sunaudiomixer_ctrl_set_volume (this->mixer, track, volumes);              \
99 }                                                                               \
100                                                                                 \
101 static void                                                                     \
102 interface_as_function ## _get_volume (GstMixer * mixer, GstMixerTrack * track,  \
103     gint * volumes)                                                             \
104 {                                                                               \
105   Type *this = (Type*) mixer;                                                   \
106                                                                                 \
107   g_return_if_fail (this != NULL);                                              \
108   g_return_if_fail (this->mixer != NULL);                                       \
109                                                                                 \
110   gst_sunaudiomixer_ctrl_get_volume (this->mixer, track, volumes);              \
111 }                                                                               \
112                                                                                 \
113 static void                                                                     \
114 interface_as_function ## _set_record (GstMixer * mixer, GstMixerTrack * track,  \
115     gboolean record)                                                            \
116 {                                                                               \
117   Type *this = (Type*) mixer;                                                   \
118                                                                                 \
119   g_return_if_fail (this != NULL);                                              \
120   g_return_if_fail (this->mixer != NULL);                                       \
121                                                                                 \
122   gst_sunaudiomixer_ctrl_set_record (this->mixer, track, record);               \
123 }                                                                               \
124                                                                                 \
125 static void                                                                     \
126 interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track,    \
127     gboolean mute)                                                              \
128 {                                                                               \
129   Type *this = (Type*) mixer;                                                   \
130                                                                                 \
131   g_return_if_fail (this != NULL);                                              \
132   g_return_if_fail (this->mixer != NULL);                                       \
133                                                                                 \
134   gst_sunaudiomixer_ctrl_set_mute (this->mixer, track, mute);                   \
135 }                                                                               \
136                                                                                 \
137 static const gchar *                                                            \
138 interface_as_function ## _get_option (GstMixer * mixer, GstMixerOptions * opts) \
139 {                                                                               \
140   Type *this = (Type*) mixer;                                                   \
141                                                                                 \
142   g_return_val_if_fail (this != NULL, NULL);                                    \
143   g_return_val_if_fail (this->mixer != NULL, NULL);                             \
144                                                                                 \
145   return gst_sunaudiomixer_ctrl_get_option (this->mixer, opts);                 \
146 }                                                                               \
147 \
148 static void                                                                     \
149 interface_as_function ## _set_option (GstMixer * mixer, GstMixerOptions * opts, \
150     gchar * value)                                                              \
151 {                                                                               \
152   Type *this = (Type*) mixer;                                                   \
153                                                                                 \
154   g_return_if_fail (this != NULL);                                              \
155   g_return_if_fail (this->mixer != NULL);                                       \
156                                                                                 \
157   gst_sunaudiomixer_ctrl_set_option (this->mixer, opts, value);                 \
158 }                                                                               \
159 \
160 static GstMixerFlags                                                            \
161 interface_as_function ## _get_mixer_flags (GstMixer * mixer)                    \
162 {                                                                               \
163   Type *this = (Type*) mixer;                                                   \
164                                                                                 \
165   g_return_val_if_fail (this != NULL, GST_MIXER_FLAG_NONE);                     \
166   g_return_val_if_fail (this->mixer != NULL, GST_MIXER_FLAG_NONE);              \
167                                                                                 \
168   return gst_sunaudiomixer_ctrl_get_mixer_flags (this->mixer);                  \
169 }                                                                               \
170                                                                                 \
171 static void                                                                     \
172 interface_as_function ## _interface_init (GstMixerClass * klass)                \
173 {                                                                               \
174   GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE;                                  \
175                                                                                 \
176   /* set up the interface hooks */                                              \
177   klass->list_tracks = interface_as_function ## _list_tracks;                   \
178   klass->set_volume  = interface_as_function ## _set_volume;                    \
179   klass->get_volume  = interface_as_function ## _get_volume;                    \
180   klass->set_mute    = interface_as_function ## _set_mute;                      \
181   klass->set_record  = interface_as_function ## _set_record;                    \
182   klass->get_option  = interface_as_function ## _get_option;                    \
183   klass->set_option  = interface_as_function ## _set_option;                    \
184   klass->get_mixer_flags   = interface_as_function ## _get_mixer_flags;         \
185 }
186
187 G_END_DECLS
188
189 #endif