source: roaraudio/libroarpulse/introspect.c @ 5849:beb4bacada1d

Last change on this file since 5849:beb4bacada1d was 5823:f9f70dbaa376, checked in by phi, 11 years ago

updated copyright

File size: 13.2 KB
Line 
1//introspect.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2013
5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from libpulse*. They are mostly copyrighted by:
7 *  Lennart Poettering <poettering@users.sourceforge.net> and
8 *  Pierre Ossman <drzeus@drzeus.cx>
9 *
10 *  This file is part of libroarpulse a part of RoarAudio,
11 *  a cross-platform sound system for both, home and professional use.
12 *  See README for details.
13 *
14 *  This file is free software; you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License version 3
16 *  as published by the Free Software Foundation.
17 *
18 *  RoarAudio is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License
24 *  along with this software; see the file COPYING.  If not, write to
25 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26 *  Boston, MA 02110-1301, USA.
27 *
28 *  NOTE for everyone want's to change something and send patches:
29 *  read README and HACKING! There a addition information on
30 *  the license of this document you need to read before you send
31 *  any patches.
32 *
33 *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
34 *  or libpulse*:
35 *  The libs libroaresd, libroararts and libroarpulse link this libroar
36 *  and are therefore GPL. Because of this it may be illigal to use
37 *  them with any software that uses libesd, libartsc or libpulse*.
38 */
39
40#include <libroarpulse/libroarpulse.h>
41
42/** Get information about a sink by its name */
43pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, pa_sink_info_cb_t cb, void *userdata) {
44 struct roar_stream stream;
45 pa_sink_info painfo;
46
47 if ( c == NULL || cb == NULL )
48  return roar_pa_op_new_done();
49
50 memset(&painfo, 0, sizeof(painfo));
51
52 if ( !!strcasecmp(name, ROAR_PA_DEFAULT_SINK) )
53  return roar_pa_op_new_done();
54
55 if ( roar_server_oinfo(roar_pa_context_get_con(c), &stream, ROAR_DIR_PLAY) == -1 )
56  return roar_pa_op_new_done();
57
58 if ( roar_pa_auinfo2sspec(&(painfo.sample_spec), &(stream.info)) == -1 )
59  return roar_pa_op_new_done();
60
61 pa_channel_map_init_auto(&(painfo.channel_map), stream.info.channels, PA_CHANNEL_MAP_DEFAULT);
62// pa_cvolume_init(&(painfo.volume));
63
64 painfo.name                = ROAR_PA_DEFAULT_SINK;
65 painfo.index               = 0; // fixme!
66 painfo.description         = "RoarAudio default mixer";
67 painfo.owner_module        = PA_INVALID_INDEX;
68 painfo.mute                = 0;
69 painfo.monitor_source      = 0;
70 painfo.monitor_source_name = ROAR_PA_DEFAULT_SOURCE;
71 painfo.latency             = 0;
72 painfo.driver              = "Waveform Mixer Core";
73// painfo.pa_sink_flags_t     = 0;
74
75 cb(c, &painfo, 1, userdata);
76
77 return roar_pa_op_new_done();
78}
79
80/** Get information about a sink by its index */
81pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t id, pa_sink_info_cb_t cb, void *userdata);
82
83/** Get the complete sink list */
84pa_operation* pa_context_get_sink_info_list(pa_context *c, pa_sink_info_cb_t cb, void *userdata);
85
86/** Get information about a source by its name */
87pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name, pa_source_info_cb_t cb, void *userdata);
88
89/** Get information about a source by its index */
90pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t id, pa_source_info_cb_t cb, void *userdata);
91
92/** Get the complete source list */
93pa_operation* pa_context_get_source_info_list(pa_context *c, pa_source_info_cb_t cb, void *userdata);
94
95/** Get some information about the server */
96pa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb, void *userdata) {
97 struct roar_stream stream;
98 struct roar_client client;
99 pa_server_info painfo;
100
101 if ( c == NULL || cb == NULL )
102  return roar_pa_op_new_done();
103
104 if ( roar_server_oinfo(roar_pa_context_get_con(c), &stream, ROAR_DIR_PLAY) == -1 )
105  return roar_pa_op_new_done();
106
107 if ( roar_get_client(roar_pa_context_get_con(c), &client, 0) == -1 )
108  return roar_pa_op_new_done();
109
110 memset(&painfo, 0, sizeof(painfo));
111
112 if ( roar_pa_auinfo2sspec(&(painfo.sample_spec), &(stream.info)) == -1 )
113  return roar_pa_op_new_done();
114
115 painfo.user_name           = "(none)";
116 painfo.host_name           = pa_context_get_server(c);
117 painfo.server_version      = pa_get_library_version();
118 painfo.server_name         = "pulseaudio";
119 painfo.default_sink_name   = ROAR_PA_DEFAULT_SINK;
120 painfo.default_source_name = ROAR_PA_DEFAULT_SOURCE;
121 painfo.cookie              = 0x524F4152;
122 painfo.cookie             ^= (client.pid & 0xFF) | (client.uid & 0xFF) << 8 | (client.gid & 0xFF) << 16;
123
124 cb(c, &painfo, userdata);
125
126 return roar_pa_op_new_done();
127}
128
129/** Get some information about a module by its index */
130pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_info_cb_t cb, void *userdata);
131
132/** Get the complete list of currently loaded modules */
133pa_operation* pa_context_get_module_info_list(pa_context *c, pa_module_info_cb_t cb, void *userdata);
134
135/** Get information about a client by its index */
136pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_info_cb_t cb, void *userdata);
137
138/** Get the complete client list */
139pa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t cb, void *userdata);
140
141/** Get some information about a sink input by its index */
142pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sink_input_info_cb_t cb, void *userdata) {
143 pa_sink_input_info pa_info;
144// struct roar_stream_info info;
145 struct roar_stream stream;
146 struct roar_mixer_settings mixer;
147 long long int s;
148 int channels;
149 char buf[256];
150 int i;
151
152 memset(&pa_info, 0, sizeof(pa_info));
153
154 roar_get_stream(roar_pa_context_get_con(c), &stream, idx);
155
156 roar_stream_get_name(roar_pa_context_get_con(c), &stream, buf, sizeof(buf));
157
158 if ( roar_get_vol(roar_pa_context_get_con(c), idx, &mixer, &channels) == -1 ) {
159  channels = 1;
160  mixer.mixer[0] = 65535;
161  mixer.rpg_mul = mixer.rpg_div = 1;
162 }
163
164// roar_stream_get_info(roar_pa_context_get_con(c), &stream, &info);
165
166 pa_info.index  = idx;
167 pa_info.name   = buf;
168 pa_info.owner_module = PA_INVALID_INDEX;
169 pa_info.client = PA_INVALID_INDEX;
170 pa_info.sink   = idx;
171//libroarpulse.c:int roar_pa_auinfo2sspec (pa_sample_spec * ss, const struct roar_audio_info * info) {
172 roar_pa_auinfo2sspec(&(pa_info.sample_spec), &(stream.info));
173 pa_info.volume.channels = channels;
174 for (i = 0; i < channels; i++) {
175  s  = mixer.mixer[i];
176  s *= mixer.rpg_mul;
177  s *= PA_VOLUME_NORM;
178  s /= mixer.rpg_div;
179  s /= 65535;
180  pa_info.volume.values[i] = s;
181 }
182 pa_info.resample_method = "server side";
183 pa_info.driver = "RoarAudio";
184// pa_info.mute = (info.flags & ROAR_FLAG_MUTE) ? 1 : 0;
185
186 cb(c, &pa_info, 1, userdata);
187
188 return roar_pa_operation_new(PA_OPERATION_DONE);
189}
190
191/** Get the complete sink input list */
192pa_operation* pa_context_get_sink_input_info_list(pa_context *c, pa_sink_input_info_cb_t cb, void *userdata);
193
194/** Get information about a source output by its index */
195pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_source_output_info_cb_t cb, void *userdata);
196
197/** Get the complete list of source outputs */
198pa_operation* pa_context_get_source_output_info_list(pa_context *c, pa_source_output_info_cb_t cb, void *userdata);
199
200/** Set the volume of a sink device specified by its index */
201pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
202
203/** Set the volume of a sink device specified by its name */
204pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
205
206/** Set the mute switch of a sink device specified by its index \since 0.8 */
207pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata);
208
209/** Set the mute switch of a sink device specified by its name \since 0.8 */
210pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata);
211
212/** Set the volume of a sink input stream */
213pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
214 struct roar_mixer_settings mixer;
215 long long int s;
216 size_t i;
217
218 mixer.rpg_mul = 1;
219 mixer.rpg_div = 1;
220
221 for (i = 0; i < volume->channels; i++) {
222  s  = volume->values[i];
223  s *= 65535;
224  s /= PA_VOLUME_NORM;
225  mixer.mixer[i] = s;
226 }
227
228 if ( roar_set_vol(roar_pa_context_get_con(c), idx, &mixer, volume->channels, ROAR_SET_VOL_ALL) == -1 ) {
229  cb(c, 0, userdata);
230 } else {
231  cb(c, 1, userdata);
232 }
233
234 return roar_pa_operation_new(PA_OPERATION_DONE);
235}
236
237/** Set the volume of a source device specified by its index \since 0.8 */
238pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
239
240/** Set the volume of a source device specified by its name \since 0.8 */
241pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
242
243/** Set the mute switch of a source device specified by its index \since 0.8 */
244pa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata);
245
246/** Set the mute switch of a source device specified by its name \since 0.8 */
247pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata);
248
249/** Get daemon memory block statistics */
250pa_operation* pa_context_stat(pa_context *c, pa_stat_info_cb_t cb, void *userdata);
251
252/** Get information about a sample by its name */
253pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name, pa_sample_info_cb_t cb, void *userdata);
254
255/** Get information about a sample by its index */
256pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, pa_sample_info_cb_t cb, void *userdata);
257
258/** Get the complete list of samples stored in the daemon. */
259pa_operation* pa_context_get_sample_info_list(pa_context *c, pa_sample_info_cb_t cb, void *userdata);
260
261/** Kill a client. \since 0.5 */
262pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata);
263
264/** Kill a sink input. \since 0.5 */
265pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata);
266
267/** Kill a source output. \since 0.5 */
268pa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata);
269
270/** Load a module. \since 0.5 */
271pa_operation* pa_context_load_module(pa_context *c, const char*name, const char *argument, pa_context_index_cb_t cb, void *userdata);
272
273/** Unload a module. \since 0.5 */
274pa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata);
275
276
277/** Get info about a specific autoload entry. \since 0.6 */
278pa_operation* pa_context_get_autoload_info_by_name(pa_context *c, const char *name, pa_autoload_type_t type, pa_autoload_info_cb_t cb, void *userdata);
279
280/** Get info about a specific autoload entry. \since 0.6 */
281pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, pa_autoload_info_cb_t cb, void *userdata);
282
283/** Get the complete list of autoload entries. \since 0.5 */
284pa_operation* pa_context_get_autoload_info_list(pa_context *c, pa_autoload_info_cb_t cb, void *userdata);
285
286/** Add a new autoload entry. \since 0.5 */
287pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autoload_type_t type, const char *module, const char*argument, pa_context_index_cb_t, void* userdata);
288
289/** Remove an autoload entry. \since 0.6 */
290pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name, pa_autoload_type_t type, pa_context_success_cb_t cb, void* userdata);
291
292/** Remove an autoload entry. \since 0.6 */
293pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void* userdata);
294
295/** Move the specified sink input to a different sink. \since 0.9.5 */
296pa_operation* pa_context_move_sink_input_by_name(pa_context *c, uint32_t idx, ROAR_HAVE_ARG_SINK_NAME_OF_PA_CONTEXT_MOVE_SINK_INPUT_BY_NAME sink_name, pa_context_success_cb_t cb, void* userdata);
297
298/** Move the specified sink input to a different sink. \since 0.9.5 */
299pa_operation* pa_context_move_sink_input_by_index(pa_context *c, uint32_t idx, uint32_t sink_idx, pa_context_success_cb_t cb, void* userdata);
300
301/** Move the specified source output to a different source. \since 0.9.5 */
302pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx, ROAR_HAVE_ARG_SOURCE_NAME_OF_PA_CONTEXT_MOVE_SOURCE_OUTPUT_BY_NAME source_name, pa_context_success_cb_t cb, void* userdata);
303
304/** Move the specified source output to a different source. \since 0.9.5 */
305pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx, uint32_t source_idx, pa_context_success_cb_t cb, void* userdata);
306
307//ll
Note: See TracBrowser for help on using the repository browser.