sys/oss/gstosssink.c: Some drivers do not support unsetting the non-blocking flag...
[platform/upstream/gstreamer.git] / sys / oss / gstossmixer.h
1 /* GStreamer OSS Mixer implementation
2  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  *
4  * gstossmixer.h: mixer interface implementation for OSS
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22
23 #ifndef __GST_OSS_MIXER_H__
24 #define __GST_OSS_MIXER_H__
25
26
27 #include <gst/gst.h>
28 #include <gst/interfaces/mixer.h>
29
30 #include "gstosshelper.h"
31
32
33 G_BEGIN_DECLS
34
35
36 #define GST_OSS_MIXER(obj)              ((GstOssMixer*)(obj))
37
38
39 typedef enum {
40   GST_OSS_MIXER_CAPTURE = 1<<0,
41   GST_OSS_MIXER_PLAYBACK = 1<<1,
42   GST_OSS_MIXER_ALL = GST_OSS_MIXER_CAPTURE | GST_OSS_MIXER_PLAYBACK
43 } GstOssMixerDirection;
44
45
46 typedef struct _GstOssMixer GstOssMixer;
47
48
49 struct _GstOssMixer {
50   GList *               tracklist;      /* list of available tracks */
51
52   gint                  mixer_fd;
53
54   gchar *               device;
55   gchar *               cardname;
56
57   gint                  recmask;
58   gint                  recdevs;
59   gint                  stereomask;
60   gint                  devmask;
61   gint                  mixcaps;
62
63   GstOssMixerDirection dir;
64 };
65
66
67 GstOssMixer*    gst_ossmixer_new                (const gchar *device,
68                                                  GstOssMixerDirection dir);
69 void            gst_ossmixer_free               (GstOssMixer *mixer);
70
71 const GList*    gst_ossmixer_list_tracks        (GstOssMixer * mixer);
72 void            gst_ossmixer_set_volume         (GstOssMixer * mixer,
73                                                  GstMixerTrack * track,
74                                                  gint * volumes);
75 void            gst_ossmixer_get_volume         (GstOssMixer * mixer,
76                                                  GstMixerTrack * track,
77                                                  gint * volumes);
78 void            gst_ossmixer_set_record         (GstOssMixer * mixer,
79                                                  GstMixerTrack * track,
80                                                  gboolean record);
81 void            gst_ossmixer_set_mute           (GstOssMixer * mixer,
82                                                  GstMixerTrack * track,
83                                                  gboolean mute);
84
85
86 #define GST_IMPLEMENT_OSS_MIXER_METHODS(Type, interface_as_function)            \
87 static gboolean                                                                 \
88 interface_as_function ## _supported (Type *this, GType iface_type)              \
89 {                                                                               \
90   g_assert (iface_type == GST_TYPE_MIXER);                                      \
91                                                                                 \
92   return (this->mixer != NULL);                                                 \
93 }                                                                               \
94                                                                                 \
95 static const GList*                                                             \
96 interface_as_function ## _list_tracks (GstMixer * mixer)                        \
97 {                                                                               \
98   Type *this = (Type*) mixer;                                                   \
99                                                                                 \
100   g_return_val_if_fail (this != NULL, NULL);                                    \
101   g_return_val_if_fail (this->mixer != NULL, NULL);                             \
102                                                                                 \
103   return gst_ossmixer_list_tracks (this->mixer);                                \
104 }                                                                               \
105                                                                                 \
106 static void                                                                     \
107 interface_as_function ## _set_volume (GstMixer * mixer, GstMixerTrack * track,  \
108     gint * volumes)                                                             \
109 {                                                                               \
110   Type *this = (Type*) mixer;                                                   \
111                                                                                 \
112   g_return_if_fail (this != NULL);                                              \
113   g_return_if_fail (this->mixer != NULL);                                       \
114                                                                                 \
115   gst_ossmixer_set_volume (this->mixer, track, volumes);                        \
116 }                                                                               \
117                                                                                 \
118 static void                                                                     \
119 interface_as_function ## _get_volume (GstMixer * mixer, GstMixerTrack * track,  \
120     gint * volumes)                                                             \
121 {                                                                               \
122   Type *this = (Type*) mixer;                                                   \
123                                                                                 \
124   g_return_if_fail (this != NULL);                                              \
125   g_return_if_fail (this->mixer != NULL);                                       \
126                                                                                 \
127   gst_ossmixer_get_volume (this->mixer, track, volumes);                        \
128 }                                                                               \
129                                                                                 \
130 static void                                                                     \
131 interface_as_function ## _set_record (GstMixer * mixer, GstMixerTrack * track,  \
132     gboolean record)                                                            \
133 {                                                                               \
134   Type *this = (Type*) mixer;                                                   \
135                                                                                 \
136   g_return_if_fail (this != NULL);                                              \
137   g_return_if_fail (this->mixer != NULL);                                       \
138                                                                                 \
139   gst_ossmixer_set_record (this->mixer, track, record);                         \
140 }                                                                               \
141                                                                                 \
142 static void                                                                     \
143 interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track,    \
144     gboolean mute)                                                              \
145 {                                                                               \
146   Type *this = (Type*) mixer;                                                   \
147                                                                                 \
148   g_return_if_fail (this != NULL);                                              \
149   g_return_if_fail (this->mixer != NULL);                                       \
150                                                                                 \
151   gst_ossmixer_set_mute (this->mixer, track, mute);                             \
152 }                                                                               \
153                                                                                 \
154 static void                                                                     \
155 interface_as_function ## _interface_init (GstMixerClass * klass)                \
156 {                                                                               \
157   GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE;                                  \
158                                                                                 \
159   /* set up the interface hooks */                                              \
160   klass->list_tracks = interface_as_function ## _list_tracks;                   \
161   klass->set_volume = interface_as_function ## _set_volume;                     \
162   klass->get_volume = interface_as_function ## _get_volume;                     \
163   klass->set_mute = interface_as_function ## _set_mute;                         \
164   klass->set_record = interface_as_function ## _set_record;                     \
165 }
166
167
168 G_END_DECLS
169
170
171 #endif /* __GST_OSS_MIXER_H__ */