Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / ext / pulse / pulsemixerctrl.h
1 /*-*- Mode: C; c-basic-offset: 2 -*-*/
2
3 /*
4  *  GStreamer pulseaudio plugin
5  *
6  *  Copyright (c) 2004-2008 Lennart Poettering
7  *
8  *  gst-pulse is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU Lesser General Public License as
10  *  published by the Free Software Foundation; either version 2.1 of the
11  *  License, or (at your option) any later version.
12  *
13  *  gst-pulse is distributed in the hope that it will be useful, but
14  *  WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  *  Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Lesser General Public
19  *  License along with gst-pulse; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21  *  USA.
22  */
23
24 #ifndef __GST_PULSEMIXERCTRL_H__
25 #define __GST_PULSEMIXERCTRL_H__
26
27 #include <gst/gst.h>
28 #include <gst/interfaces/mixer.h>
29
30 #include <pulse/pulseaudio.h>
31 #include <pulse/thread-mainloop.h>
32
33 G_BEGIN_DECLS
34
35 #define GST_PULSEMIXER_CTRL(obj) ((GstPulseMixerCtrl*)(obj))
36 typedef struct _GstPulseMixerCtrl GstPulseMixerCtrl;
37
38 typedef enum
39 {
40   GST_PULSEMIXER_UNKNOWN,
41   GST_PULSEMIXER_SINK,
42   GST_PULSEMIXER_SOURCE
43 } GstPulseMixerType;
44
45 struct _GstPulseMixerCtrl
46 {
47   GObject *object;
48
49   GList *tracklist;
50
51   gchar *server, *device;
52
53   pa_threaded_mainloop *mainloop;
54   pa_context *context;
55
56   gchar *name, *description;
57   pa_channel_map channel_map;
58
59   pa_cvolume volume;
60   gboolean muted:1;
61
62   gboolean update_volume:1;
63   gboolean update_mute:1;
64
65   gboolean operation_success:1;
66
67   guint32 index;
68   GstPulseMixerType type;
69
70   GstMixerTrack *track;
71
72   pa_time_event *time_event;
73
74   int outstandig_queries;
75   int ignore_queries;
76
77 };
78
79 GstPulseMixerCtrl *gst_pulsemixer_ctrl_new (GObject *object, const gchar * server,
80     const gchar * device, GstPulseMixerType type);
81 void gst_pulsemixer_ctrl_free (GstPulseMixerCtrl * mixer);
82
83 const GList *gst_pulsemixer_ctrl_list_tracks (GstPulseMixerCtrl * mixer);
84
85 void gst_pulsemixer_ctrl_set_volume (GstPulseMixerCtrl * mixer,
86     GstMixerTrack * track, gint * volumes);
87 void gst_pulsemixer_ctrl_get_volume (GstPulseMixerCtrl * mixer,
88     GstMixerTrack * track, gint * volumes);
89 void gst_pulsemixer_ctrl_set_mute (GstPulseMixerCtrl * mixer,
90     GstMixerTrack * track, gboolean mute);
91 void gst_pulsemixer_ctrl_set_record (GstPulseMixerCtrl * mixer,
92     GstMixerTrack * track, gboolean record);
93 GstMixerFlags gst_pulsemixer_ctrl_get_mixer_flags (GstPulseMixerCtrl * mixer);
94
95 #define GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS(Type, interface_as_function)     \
96 static const GList*                                                             \
97 interface_as_function ## _list_tracks (GstMixer * mixer)                        \
98 {                                                                               \
99   Type *this = (Type*) mixer;                                                   \
100                                                                                 \
101   g_return_val_if_fail (this != NULL, NULL);                                    \
102   g_return_val_if_fail (this->mixer != NULL, NULL);                             \
103                                                                                 \
104   return gst_pulsemixer_ctrl_list_tracks (this->mixer);                         \
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_pulsemixer_ctrl_set_volume (this->mixer, track, volumes);                 \
116 }                                                                               \
117 static void                                                                     \
118 interface_as_function ## _get_volume (GstMixer * mixer, GstMixerTrack * track,  \
119     gint * volumes)                                                             \
120 {                                                                               \
121   Type *this = (Type*) mixer;                                                   \
122                                                                                 \
123   g_return_if_fail (this != NULL);                                              \
124   g_return_if_fail (this->mixer != NULL);                                       \
125                                                                                 \
126   gst_pulsemixer_ctrl_get_volume (this->mixer, track, volumes);                 \
127 }                                                                               \
128 static void                                                                     \
129 interface_as_function ## _set_record (GstMixer * mixer, GstMixerTrack * track,  \
130     gboolean record)                                                            \
131 {                                                                               \
132   Type *this = (Type*) mixer;                                                   \
133                                                                                 \
134   g_return_if_fail (this != NULL);                                              \
135   g_return_if_fail (this->mixer != NULL);                                       \
136                                                                                 \
137   gst_pulsemixer_ctrl_set_record (this->mixer, track, record);                  \
138 }                                                                               \
139 static void                                                                     \
140 interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track,    \
141     gboolean mute)                                                              \
142 {                                                                               \
143   Type *this = (Type*) mixer;                                                   \
144                                                                                 \
145   g_return_if_fail (this != NULL);                                              \
146   g_return_if_fail (this->mixer != NULL);                                       \
147                                                                                 \
148   gst_pulsemixer_ctrl_set_mute (this->mixer, track, mute);                      \
149 }                                                                               \
150 static GstMixerFlags                                                            \
151 interface_as_function ## _get_mixer_flags (GstMixer * mixer)                    \
152 {                                                                               \
153   Type *this = (Type*) mixer;                                                   \
154                                                                                 \
155   g_return_val_if_fail (this != NULL, GST_MIXER_FLAG_NONE);                     \
156   g_return_val_if_fail (this->mixer != NULL, GST_MIXER_FLAG_NONE);              \
157                                                                                 \
158   return gst_pulsemixer_ctrl_get_mixer_flags (this->mixer);                          \
159 } \
160 static void                                                                     \
161 interface_as_function ## _mixer_interface_init (GstMixerClass * klass)          \
162 {                                                                               \
163   GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE;                                  \
164                                                                                 \
165   klass->list_tracks = interface_as_function ## _list_tracks;                   \
166   klass->set_volume  = interface_as_function ## _set_volume;                    \
167   klass->get_volume  = interface_as_function ## _get_volume;                    \
168   klass->set_mute    = interface_as_function ## _set_mute;                      \
169   klass->set_record  = interface_as_function ## _set_record;                    \
170   klass->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
171 }
172
173 G_END_DECLS
174
175 #endif