default: esd is obsolete, hence don't load it anymore by default
[pulseaudio-mirror.git] / src / pulse / introspect.c
blob27a298cfabf582ee16ac2c9fc358cbd88ec26d4e
1 /***
2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
7 PulseAudio is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 2.1 of the License,
10 or (at your option) any later version.
12 PulseAudio is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with PulseAudio; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA.
21 ***/
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
27 #include <pulse/context.h>
28 #include <pulse/xmalloc.h>
29 #include <pulse/fork-detect.h>
31 #include <pulsecore/macro.h>
32 #include <pulsecore/core-util.h>
33 #include <pulsecore/pstream-util.h>
35 #include "internal.h"
36 #include "introspect.h"
38 /*** Statistics ***/
40 static void context_stat_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
41 pa_operation *o = userdata;
42 pa_stat_info i, *p = &i;
44 pa_assert(pd);
45 pa_assert(o);
46 pa_assert(PA_REFCNT_VALUE(o) >= 1);
48 pa_zero(i);
50 if (!o->context)
51 goto finish;
53 if (command != PA_COMMAND_REPLY) {
54 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
55 goto finish;
57 p = NULL;
58 } else if (pa_tagstruct_getu32(t, &i.memblock_total) < 0 ||
59 pa_tagstruct_getu32(t, &i.memblock_total_size) < 0 ||
60 pa_tagstruct_getu32(t, &i.memblock_allocated) < 0 ||
61 pa_tagstruct_getu32(t, &i.memblock_allocated_size) < 0 ||
62 pa_tagstruct_getu32(t, &i.scache_size) < 0 ||
63 !pa_tagstruct_eof(t)) {
64 pa_context_fail(o->context, PA_ERR_PROTOCOL);
65 goto finish;
68 if (o->callback) {
69 pa_stat_info_cb_t cb = (pa_stat_info_cb_t) o->callback;
70 cb(o->context, p, o->userdata);
73 finish:
74 pa_operation_done(o);
75 pa_operation_unref(o);
78 pa_operation* pa_context_stat(pa_context *c, pa_stat_info_cb_t cb, void *userdata) {
79 return pa_context_send_simple_command(c, PA_COMMAND_STAT, context_stat_callback, (pa_operation_cb_t) cb, userdata);
82 /*** Server Info ***/
84 static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
85 pa_operation *o = userdata;
86 pa_server_info i, *p = &i;
88 pa_assert(pd);
89 pa_assert(o);
90 pa_assert(PA_REFCNT_VALUE(o) >= 1);
92 pa_zero(i);
94 if (!o->context)
95 goto finish;
97 if (command != PA_COMMAND_REPLY) {
98 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
99 goto finish;
101 p = NULL;
102 } else if (pa_tagstruct_gets(t, &i.server_name) < 0 ||
103 pa_tagstruct_gets(t, &i.server_version) < 0 ||
104 pa_tagstruct_gets(t, &i.user_name) < 0 ||
105 pa_tagstruct_gets(t, &i.host_name) < 0 ||
106 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
107 pa_tagstruct_gets(t, &i.default_sink_name) < 0 ||
108 pa_tagstruct_gets(t, &i.default_source_name) < 0 ||
109 pa_tagstruct_getu32(t, &i.cookie) < 0 ||
110 (o->context->version >= 15 &&
111 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0) ||
112 !pa_tagstruct_eof(t)) {
114 pa_context_fail(o->context, PA_ERR_PROTOCOL);
115 goto finish;
118 if (p && o->context->version < 15)
119 pa_channel_map_init_extend(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
121 if (o->callback) {
122 pa_server_info_cb_t cb = (pa_server_info_cb_t) o->callback;
123 cb(o->context, p, o->userdata);
126 finish:
127 pa_operation_done(o);
128 pa_operation_unref(o);
131 pa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb, void *userdata) {
132 return pa_context_send_simple_command(c, PA_COMMAND_GET_SERVER_INFO, context_get_server_info_callback, (pa_operation_cb_t) cb, userdata);
135 /*** Sink Info ***/
137 static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
138 pa_operation *o = userdata;
139 int eol = 1;
140 pa_sink_info i;
141 uint32_t j;
143 pa_assert(pd);
144 pa_assert(o);
145 pa_assert(PA_REFCNT_VALUE(o) >= 1);
147 /* For safety incase someone use fail: outside the while loop below */
148 pa_zero(i);
150 if (!o->context)
151 goto finish;
153 if (command != PA_COMMAND_REPLY) {
154 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
155 goto finish;
157 eol = -1;
158 } else {
160 while (!pa_tagstruct_eof(t)) {
161 pa_bool_t mute;
162 uint32_t flags;
163 uint32_t state;
164 const char *ap = NULL;
166 pa_zero(i);
167 i.proplist = pa_proplist_new();
168 i.base_volume = PA_VOLUME_NORM;
169 i.n_volume_steps = PA_VOLUME_NORM+1;
170 mute = FALSE;
171 state = PA_SINK_INVALID_STATE;
172 i.card = PA_INVALID_INDEX;
174 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
175 pa_tagstruct_gets(t, &i.name) < 0 ||
176 pa_tagstruct_gets(t, &i.description) < 0 ||
177 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
178 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
179 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
180 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
181 pa_tagstruct_get_boolean(t, &mute) < 0 ||
182 pa_tagstruct_getu32(t, &i.monitor_source) < 0 ||
183 pa_tagstruct_gets(t, &i.monitor_source_name) < 0 ||
184 pa_tagstruct_get_usec(t, &i.latency) < 0 ||
185 pa_tagstruct_gets(t, &i.driver) < 0 ||
186 pa_tagstruct_getu32(t, &flags) < 0 ||
187 (o->context->version >= 13 &&
188 (pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
189 pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
190 (o->context->version >= 15 &&
191 (pa_tagstruct_get_volume(t, &i.base_volume) < 0 ||
192 pa_tagstruct_getu32(t, &state) < 0 ||
193 pa_tagstruct_getu32(t, &i.n_volume_steps) < 0 ||
194 pa_tagstruct_getu32(t, &i.card) < 0)) ||
195 (o->context->version >= 16 &&
196 (pa_tagstruct_getu32(t, &i.n_ports)))) {
198 goto fail;
201 if (o->context->version >= 16) {
202 if (i.n_ports > 0) {
203 i.ports = pa_xnew(pa_sink_port_info*, i.n_ports+1);
204 i.ports[0] = pa_xnew(pa_sink_port_info, i.n_ports);
206 for (j = 0; j < i.n_ports; j++) {
207 if (pa_tagstruct_gets(t, &i.ports[0][j].name) < 0 ||
208 pa_tagstruct_gets(t, &i.ports[0][j].description) < 0 ||
209 pa_tagstruct_getu32(t, &i.ports[0][j].priority) < 0) {
211 goto fail;
214 i.ports[j] = &i.ports[0][j];
217 i.ports[j] = NULL;
220 if (pa_tagstruct_gets(t, &ap) < 0)
221 goto fail;
223 if (ap) {
224 for (j = 0; j < i.n_ports; j++)
225 if (pa_streq(i.ports[j]->name, ap)) {
226 i.active_port = i.ports[j];
227 break;
232 if (o->context->version >= 21) {
233 uint8_t n_formats;
234 if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1)
235 goto fail;
237 i.formats = pa_xnew0(pa_format_info*, n_formats);
239 for (j = 0; j < n_formats; j++) {
240 i.n_formats++;
241 i.formats[j] = pa_format_info_new();
243 if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0)
244 goto fail;
248 i.mute = (int) mute;
249 i.flags = (pa_sink_flags_t) flags;
250 i.state = (pa_sink_state_t) state;
252 if (o->callback) {
253 pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback;
254 cb(o->context, &i, 0, o->userdata);
257 if (i.formats) {
258 for (j = 0; j < i.n_formats; j++)
259 pa_format_info_free(i.formats[j]);
260 pa_xfree(i.formats);
262 if (i.ports) {
263 pa_xfree(i.ports[0]);
264 pa_xfree(i.ports);
266 pa_proplist_free(i.proplist);
270 if (o->callback) {
271 pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback;
272 cb(o->context, NULL, eol, o->userdata);
275 finish:
276 pa_operation_done(o);
277 pa_operation_unref(o);
278 return;
280 fail:
281 pa_assert(i.proplist);
283 pa_context_fail(o->context, PA_ERR_PROTOCOL);
285 if (i.formats) {
286 for (j = 0; j < i.n_formats; j++)
287 pa_format_info_free(i.formats[j]);
288 pa_xfree(i.formats);
290 if (i.ports) {
291 pa_xfree(i.ports[0]);
292 pa_xfree(i.ports);
294 pa_proplist_free(i.proplist);
296 goto finish;
299 pa_operation* pa_context_get_sink_info_list(pa_context *c, pa_sink_info_cb_t cb, void *userdata) {
300 return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INFO_LIST, context_get_sink_info_callback, (pa_operation_cb_t) cb, userdata);
303 pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_sink_info_cb_t cb, void *userdata) {
304 pa_tagstruct *t;
305 pa_operation *o;
306 uint32_t tag;
308 pa_assert(c);
309 pa_assert(PA_REFCNT_VALUE(c) >= 1);
310 pa_assert(cb);
312 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
313 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
315 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
317 t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag);
318 pa_tagstruct_putu32(t, idx);
319 pa_tagstruct_puts(t, NULL);
320 pa_pstream_send_tagstruct(c->pstream, t);
321 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
323 return o;
326 pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, pa_sink_info_cb_t cb, void *userdata) {
327 pa_tagstruct *t;
328 pa_operation *o;
329 uint32_t tag;
331 pa_assert(c);
332 pa_assert(PA_REFCNT_VALUE(c) >= 1);
333 pa_assert(cb);
335 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
336 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
337 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
339 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
341 t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag);
342 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
343 pa_tagstruct_puts(t, name);
344 pa_pstream_send_tagstruct(c->pstream, t);
345 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
347 return o;
350 pa_operation* pa_context_set_sink_port_by_index(pa_context *c, uint32_t idx, const char*port, pa_context_success_cb_t cb, void *userdata) {
351 pa_operation *o;
352 pa_tagstruct *t;
353 uint32_t tag;
355 pa_assert(c);
356 pa_assert(PA_REFCNT_VALUE(c) >= 1);
358 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
359 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
360 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
361 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
363 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
365 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_PORT, &tag);
366 pa_tagstruct_putu32(t, idx);
367 pa_tagstruct_puts(t, NULL);
368 pa_tagstruct_puts(t, port);
369 pa_pstream_send_tagstruct(c->pstream, t);
370 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
372 return o;
375 pa_operation* pa_context_set_sink_port_by_name(pa_context *c, const char *name, const char*port, pa_context_success_cb_t cb, void *userdata) {
376 pa_operation *o;
377 pa_tagstruct *t;
378 uint32_t tag;
380 pa_assert(c);
381 pa_assert(PA_REFCNT_VALUE(c) >= 1);
383 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
384 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
385 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
386 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
388 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
390 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_PORT, &tag);
391 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
392 pa_tagstruct_puts(t, name);
393 pa_tagstruct_puts(t, port);
394 pa_pstream_send_tagstruct(c->pstream, t);
395 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
397 return o;
400 /*** Source info ***/
402 static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
403 pa_operation *o = userdata;
404 int eol = 1;
405 pa_source_info i;
406 uint32_t j;
408 pa_assert(pd);
409 pa_assert(o);
410 pa_assert(PA_REFCNT_VALUE(o) >= 1);
412 /* For safety incase someone use fail: outside the while loop below */
413 pa_zero(i);
415 if (!o->context)
416 goto finish;
418 if (command != PA_COMMAND_REPLY) {
419 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
420 goto finish;
422 eol = -1;
423 } else {
425 while (!pa_tagstruct_eof(t)) {
426 pa_bool_t mute;
427 uint32_t flags;
428 uint32_t state;
429 const char *ap;
431 pa_zero(i);
432 i.proplist = pa_proplist_new();
433 i.base_volume = PA_VOLUME_NORM;
434 i.n_volume_steps = PA_VOLUME_NORM+1;
435 mute = FALSE;
436 state = PA_SOURCE_INVALID_STATE;
437 i.card = PA_INVALID_INDEX;
439 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
440 pa_tagstruct_gets(t, &i.name) < 0 ||
441 pa_tagstruct_gets(t, &i.description) < 0 ||
442 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
443 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
444 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
445 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
446 pa_tagstruct_get_boolean(t, &mute) < 0 ||
447 pa_tagstruct_getu32(t, &i.monitor_of_sink) < 0 ||
448 pa_tagstruct_gets(t, &i.monitor_of_sink_name) < 0 ||
449 pa_tagstruct_get_usec(t, &i.latency) < 0 ||
450 pa_tagstruct_gets(t, &i.driver) < 0 ||
451 pa_tagstruct_getu32(t, &flags) < 0 ||
452 (o->context->version >= 13 &&
453 (pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
454 pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
455 (o->context->version >= 15 &&
456 (pa_tagstruct_get_volume(t, &i.base_volume) < 0 ||
457 pa_tagstruct_getu32(t, &state) < 0 ||
458 pa_tagstruct_getu32(t, &i.n_volume_steps) < 0 ||
459 pa_tagstruct_getu32(t, &i.card) < 0)) ||
460 (o->context->version >= 16 &&
461 (pa_tagstruct_getu32(t, &i.n_ports)))) {
463 goto fail;
466 if (o->context->version >= 16) {
467 if (i.n_ports > 0) {
468 i.ports = pa_xnew(pa_source_port_info*, i.n_ports+1);
469 i.ports[0] = pa_xnew(pa_source_port_info, i.n_ports);
471 for (j = 0; j < i.n_ports; j++) {
472 if (pa_tagstruct_gets(t, &i.ports[0][j].name) < 0 ||
473 pa_tagstruct_gets(t, &i.ports[0][j].description) < 0 ||
474 pa_tagstruct_getu32(t, &i.ports[0][j].priority) < 0) {
476 goto fail;
479 i.ports[j] = &i.ports[0][j];
482 i.ports[j] = NULL;
485 if (pa_tagstruct_gets(t, &ap) < 0)
486 goto fail;
488 if (ap) {
489 for (j = 0; j < i.n_ports; j++)
490 if (pa_streq(i.ports[j]->name, ap)) {
491 i.active_port = i.ports[j];
492 break;
497 if (o->context->version >= 22) {
498 uint8_t n_formats;
499 if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1)
500 goto fail;
502 i.formats = pa_xnew0(pa_format_info*, n_formats);
504 for (j = 0; j < n_formats; j++) {
505 i.n_formats++;
506 i.formats[j] = pa_format_info_new();
508 if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0)
509 goto fail;
513 i.mute = (int) mute;
514 i.flags = (pa_source_flags_t) flags;
515 i.state = (pa_source_state_t) state;
517 if (o->callback) {
518 pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback;
519 cb(o->context, &i, 0, o->userdata);
522 if (i.formats) {
523 for (j = 0; j < i.n_formats; j++)
524 pa_format_info_free(i.formats[j]);
525 pa_xfree(i.formats);
527 if (i.ports) {
528 pa_xfree(i.ports[0]);
529 pa_xfree(i.ports);
531 pa_proplist_free(i.proplist);
535 if (o->callback) {
536 pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback;
537 cb(o->context, NULL, eol, o->userdata);
540 finish:
541 pa_operation_done(o);
542 pa_operation_unref(o);
543 return;
545 fail:
546 pa_assert(i.proplist);
548 pa_context_fail(o->context, PA_ERR_PROTOCOL);
550 if (i.formats) {
551 for (j = 0; j < i.n_formats; j++)
552 pa_format_info_free(i.formats[j]);
553 pa_xfree(i.formats);
555 if (i.ports) {
556 pa_xfree(i.ports[0]);
557 pa_xfree(i.ports);
559 pa_proplist_free(i.proplist);
561 goto finish;
564 pa_operation* pa_context_get_source_info_list(pa_context *c, pa_source_info_cb_t cb, void *userdata) {
565 return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_INFO_LIST, context_get_source_info_callback, (pa_operation_cb_t) cb, userdata);
568 pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, pa_source_info_cb_t cb, void *userdata) {
569 pa_tagstruct *t;
570 pa_operation *o;
571 uint32_t tag;
573 pa_assert(c);
574 pa_assert(PA_REFCNT_VALUE(c) >= 1);
575 pa_assert(cb);
577 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
578 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
580 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
582 t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag);
583 pa_tagstruct_putu32(t, idx);
584 pa_tagstruct_puts(t, NULL);
585 pa_pstream_send_tagstruct(c->pstream, t);
586 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
588 return o;
591 pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name, pa_source_info_cb_t cb, void *userdata) {
592 pa_tagstruct *t;
593 pa_operation *o;
594 uint32_t tag;
596 pa_assert(c);
597 pa_assert(PA_REFCNT_VALUE(c) >= 1);
598 pa_assert(cb);
600 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
601 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
602 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
604 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
606 t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag);
607 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
608 pa_tagstruct_puts(t, name);
609 pa_pstream_send_tagstruct(c->pstream, t);
610 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
612 return o;
615 pa_operation* pa_context_set_source_port_by_index(pa_context *c, uint32_t idx, const char*port, pa_context_success_cb_t cb, void *userdata) {
616 pa_operation *o;
617 pa_tagstruct *t;
618 uint32_t tag;
620 pa_assert(c);
621 pa_assert(PA_REFCNT_VALUE(c) >= 1);
623 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
624 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
625 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
626 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
628 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
630 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_PORT, &tag);
631 pa_tagstruct_putu32(t, idx);
632 pa_tagstruct_puts(t, NULL);
633 pa_tagstruct_puts(t, port);
634 pa_pstream_send_tagstruct(c->pstream, t);
635 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
637 return o;
640 pa_operation* pa_context_set_source_port_by_name(pa_context *c, const char *name, const char*port, pa_context_success_cb_t cb, void *userdata) {
641 pa_operation *o;
642 pa_tagstruct *t;
643 uint32_t tag;
645 pa_assert(c);
646 pa_assert(PA_REFCNT_VALUE(c) >= 1);
648 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
649 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
650 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
651 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
653 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
655 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_PORT, &tag);
656 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
657 pa_tagstruct_puts(t, name);
658 pa_tagstruct_puts(t, port);
659 pa_pstream_send_tagstruct(c->pstream, t);
660 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
662 return o;
665 /*** Client info ***/
667 static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
668 pa_operation *o = userdata;
669 int eol = 1;
671 pa_assert(pd);
672 pa_assert(o);
673 pa_assert(PA_REFCNT_VALUE(o) >= 1);
675 if (!o->context)
676 goto finish;
678 if (command != PA_COMMAND_REPLY) {
679 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
680 goto finish;
682 eol = -1;
683 } else {
685 while (!pa_tagstruct_eof(t)) {
686 pa_client_info i;
688 pa_zero(i);
689 i.proplist = pa_proplist_new();
691 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
692 pa_tagstruct_gets(t, &i.name) < 0 ||
693 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
694 pa_tagstruct_gets(t, &i.driver) < 0 ||
695 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) {
697 pa_context_fail(o->context, PA_ERR_PROTOCOL);
698 pa_proplist_free(i.proplist);
699 goto finish;
702 if (o->callback) {
703 pa_client_info_cb_t cb = (pa_client_info_cb_t) o->callback;
704 cb(o->context, &i, 0, o->userdata);
707 pa_proplist_free(i.proplist);
711 if (o->callback) {
712 pa_client_info_cb_t cb = (pa_client_info_cb_t) o->callback;
713 cb(o->context, NULL, eol, o->userdata);
716 finish:
717 pa_operation_done(o);
718 pa_operation_unref(o);
721 pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_info_cb_t cb, void *userdata) {
722 pa_tagstruct *t;
723 pa_operation *o;
724 uint32_t tag;
726 pa_assert(c);
727 pa_assert(PA_REFCNT_VALUE(c) >= 1);
728 pa_assert(cb);
730 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
731 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
732 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
734 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
736 t = pa_tagstruct_command(c, PA_COMMAND_GET_CLIENT_INFO, &tag);
737 pa_tagstruct_putu32(t, idx);
738 pa_pstream_send_tagstruct(c->pstream, t);
739 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_client_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
741 return o;
744 pa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t cb, void *userdata) {
745 return pa_context_send_simple_command(c, PA_COMMAND_GET_CLIENT_INFO_LIST, context_get_client_info_callback, (pa_operation_cb_t) cb, userdata);
748 /*** Card info ***/
750 static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
751 pa_operation *o = userdata;
752 int eol = 1;
754 pa_assert(pd);
755 pa_assert(o);
756 pa_assert(PA_REFCNT_VALUE(o) >= 1);
758 if (!o->context)
759 goto finish;
761 if (command != PA_COMMAND_REPLY) {
762 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
763 goto finish;
765 eol = -1;
766 } else {
768 while (!pa_tagstruct_eof(t)) {
769 pa_card_info i;
770 uint32_t j;
771 const char*ap;
773 pa_zero(i);
775 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
776 pa_tagstruct_gets(t, &i.name) < 0 ||
777 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
778 pa_tagstruct_gets(t, &i.driver) < 0 ||
779 pa_tagstruct_getu32(t, &i.n_profiles) < 0) {
781 pa_context_fail(o->context, PA_ERR_PROTOCOL);
782 goto finish;
785 if (i.n_profiles > 0) {
786 i.profiles = pa_xnew0(pa_card_profile_info, i.n_profiles+1);
788 for (j = 0; j < i.n_profiles; j++) {
790 if (pa_tagstruct_gets(t, &i.profiles[j].name) < 0 ||
791 pa_tagstruct_gets(t, &i.profiles[j].description) < 0 ||
792 pa_tagstruct_getu32(t, &i.profiles[j].n_sinks) < 0 ||
793 pa_tagstruct_getu32(t, &i.profiles[j].n_sources) < 0 ||
794 pa_tagstruct_getu32(t, &i.profiles[j].priority) < 0) {
796 pa_context_fail(o->context, PA_ERR_PROTOCOL);
797 pa_xfree(i.profiles);
798 goto finish;
802 /* Terminate with an extra NULL entry, just to make sure */
803 i.profiles[j].name = NULL;
804 i.profiles[j].description = NULL;
807 i.proplist = pa_proplist_new();
809 if (pa_tagstruct_gets(t, &ap) < 0 ||
810 pa_tagstruct_get_proplist(t, i.proplist) < 0) {
812 pa_context_fail(o->context, PA_ERR_PROTOCOL);
813 pa_xfree(i.profiles);
814 pa_proplist_free(i.proplist);
815 goto finish;
818 if (ap) {
819 for (j = 0; j < i.n_profiles; j++)
820 if (pa_streq(i.profiles[j].name, ap)) {
821 i.active_profile = &i.profiles[j];
822 break;
826 if (o->callback) {
827 pa_card_info_cb_t cb = (pa_card_info_cb_t) o->callback;
828 cb(o->context, &i, 0, o->userdata);
831 pa_proplist_free(i.proplist);
832 pa_xfree(i.profiles);
836 if (o->callback) {
837 pa_card_info_cb_t cb = (pa_card_info_cb_t) o->callback;
838 cb(o->context, NULL, eol, o->userdata);
841 finish:
842 pa_operation_done(o);
843 pa_operation_unref(o);
846 pa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_card_info_cb_t cb, void *userdata) {
847 pa_tagstruct *t;
848 pa_operation *o;
849 uint32_t tag;
851 pa_assert(c);
852 pa_assert(PA_REFCNT_VALUE(c) >= 1);
853 pa_assert(cb);
855 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
856 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
857 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
858 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
860 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
862 t = pa_tagstruct_command(c, PA_COMMAND_GET_CARD_INFO, &tag);
863 pa_tagstruct_putu32(t, idx);
864 pa_tagstruct_puts(t, NULL);
865 pa_pstream_send_tagstruct(c->pstream, t);
866 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_card_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
868 return o;
871 pa_operation* pa_context_get_card_info_by_name(pa_context *c, const char*name, pa_card_info_cb_t cb, void *userdata) {
872 pa_tagstruct *t;
873 pa_operation *o;
874 uint32_t tag;
876 pa_assert(c);
877 pa_assert(PA_REFCNT_VALUE(c) >= 1);
878 pa_assert(cb);
880 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
881 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
882 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
883 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
885 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
887 t = pa_tagstruct_command(c, PA_COMMAND_GET_CARD_INFO, &tag);
888 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
889 pa_tagstruct_puts(t, name);
890 pa_pstream_send_tagstruct(c->pstream, t);
891 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_card_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
893 return o;
896 pa_operation* pa_context_get_card_info_list(pa_context *c, pa_card_info_cb_t cb, void *userdata) {
897 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
899 return pa_context_send_simple_command(c, PA_COMMAND_GET_CARD_INFO_LIST, context_get_card_info_callback, (pa_operation_cb_t) cb, userdata);
902 pa_operation* pa_context_set_card_profile_by_index(pa_context *c, uint32_t idx, const char*profile, pa_context_success_cb_t cb, void *userdata) {
903 pa_operation *o;
904 pa_tagstruct *t;
905 uint32_t tag;
907 pa_assert(c);
908 pa_assert(PA_REFCNT_VALUE(c) >= 1);
910 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
911 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
912 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
913 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
915 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
917 t = pa_tagstruct_command(c, PA_COMMAND_SET_CARD_PROFILE, &tag);
918 pa_tagstruct_putu32(t, idx);
919 pa_tagstruct_puts(t, NULL);
920 pa_tagstruct_puts(t, profile);
921 pa_pstream_send_tagstruct(c->pstream, t);
922 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
924 return o;
927 pa_operation* pa_context_set_card_profile_by_name(pa_context *c, const char *name, const char*profile, pa_context_success_cb_t cb, void *userdata) {
928 pa_operation *o;
929 pa_tagstruct *t;
930 uint32_t tag;
932 pa_assert(c);
933 pa_assert(PA_REFCNT_VALUE(c) >= 1);
935 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
936 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
937 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
938 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
940 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
942 t = pa_tagstruct_command(c, PA_COMMAND_SET_CARD_PROFILE, &tag);
943 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
944 pa_tagstruct_puts(t, name);
945 pa_tagstruct_puts(t, profile);
946 pa_pstream_send_tagstruct(c->pstream, t);
947 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
949 return o;
952 /*** Module info ***/
954 static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
955 pa_operation *o = userdata;
956 int eol = 1;
958 pa_assert(pd);
959 pa_assert(o);
960 pa_assert(PA_REFCNT_VALUE(o) >= 1);
962 if (!o->context)
963 goto finish;
965 if (command != PA_COMMAND_REPLY) {
966 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
967 goto finish;
969 eol = -1;
970 } else {
972 while (!pa_tagstruct_eof(t)) {
973 pa_module_info i;
974 pa_bool_t auto_unload = FALSE;
976 pa_zero(i);
977 i.proplist = pa_proplist_new();
979 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
980 pa_tagstruct_gets(t, &i.name) < 0 ||
981 pa_tagstruct_gets(t, &i.argument) < 0 ||
982 pa_tagstruct_getu32(t, &i.n_used) < 0 ||
983 (o->context->version < 15 && pa_tagstruct_get_boolean(t, &auto_unload) < 0) ||
984 (o->context->version >= 15 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) {
985 pa_context_fail(o->context, PA_ERR_PROTOCOL);
986 goto finish;
989 i.auto_unload = (int) auto_unload;
991 if (o->callback) {
992 pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback;
993 cb(o->context, &i, 0, o->userdata);
996 pa_proplist_free(i.proplist);
1000 if (o->callback) {
1001 pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback;
1002 cb(o->context, NULL, eol, o->userdata);
1005 finish:
1006 pa_operation_done(o);
1007 pa_operation_unref(o);
1010 pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_info_cb_t cb, void *userdata) {
1011 pa_tagstruct *t;
1012 pa_operation *o;
1013 uint32_t tag;
1015 pa_assert(c);
1016 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1017 pa_assert(cb);
1019 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1020 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1021 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1023 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1025 t = pa_tagstruct_command(c, PA_COMMAND_GET_MODULE_INFO, &tag);
1026 pa_tagstruct_putu32(t, idx);
1027 pa_pstream_send_tagstruct(c->pstream, t);
1028 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_module_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1030 return o;
1033 pa_operation* pa_context_get_module_info_list(pa_context *c, pa_module_info_cb_t cb, void *userdata) {
1034 return pa_context_send_simple_command(c, PA_COMMAND_GET_MODULE_INFO_LIST, context_get_module_info_callback, (pa_operation_cb_t) cb, userdata);
1037 /*** Sink input info ***/
1039 static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
1040 pa_operation *o = userdata;
1041 int eol = 1;
1043 pa_assert(pd);
1044 pa_assert(o);
1045 pa_assert(PA_REFCNT_VALUE(o) >= 1);
1047 if (!o->context)
1048 goto finish;
1050 if (command != PA_COMMAND_REPLY) {
1051 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
1052 goto finish;
1054 eol = -1;
1055 } else {
1057 while (!pa_tagstruct_eof(t)) {
1058 pa_sink_input_info i;
1059 pa_bool_t mute = FALSE, corked = FALSE, has_volume = FALSE, volume_writable = TRUE;
1061 pa_zero(i);
1062 i.proplist = pa_proplist_new();
1063 i.format = pa_format_info_new();
1065 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
1066 pa_tagstruct_gets(t, &i.name) < 0 ||
1067 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
1068 pa_tagstruct_getu32(t, &i.client) < 0 ||
1069 pa_tagstruct_getu32(t, &i.sink) < 0 ||
1070 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
1071 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
1072 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
1073 pa_tagstruct_get_usec(t, &i.buffer_usec) < 0 ||
1074 pa_tagstruct_get_usec(t, &i.sink_usec) < 0 ||
1075 pa_tagstruct_gets(t, &i.resample_method) < 0 ||
1076 pa_tagstruct_gets(t, &i.driver) < 0 ||
1077 (o->context->version >= 11 && pa_tagstruct_get_boolean(t, &mute) < 0) ||
1078 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) ||
1079 (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0) ||
1080 (o->context->version >= 20 && (pa_tagstruct_get_boolean(t, &has_volume) < 0 ||
1081 pa_tagstruct_get_boolean(t, &volume_writable) < 0)) ||
1082 (o->context->version >= 21 && pa_tagstruct_get_format_info(t, i.format) < 0)) {
1084 pa_context_fail(o->context, PA_ERR_PROTOCOL);
1085 pa_proplist_free(i.proplist);
1086 pa_format_info_free(i.format);
1087 goto finish;
1090 i.mute = (int) mute;
1091 i.corked = (int) corked;
1092 i.has_volume = (int) has_volume;
1093 i.volume_writable = (int) volume_writable;
1095 if (o->callback) {
1096 pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback;
1097 cb(o->context, &i, 0, o->userdata);
1100 pa_proplist_free(i.proplist);
1101 pa_format_info_free(i.format);
1105 if (o->callback) {
1106 pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback;
1107 cb(o->context, NULL, eol, o->userdata);
1110 finish:
1111 pa_operation_done(o);
1112 pa_operation_unref(o);
1115 pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sink_input_info_cb_t cb, void *userdata) {
1116 pa_tagstruct *t;
1117 pa_operation *o;
1118 uint32_t tag;
1120 pa_assert(c);
1121 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1122 pa_assert(cb);
1124 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1125 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1126 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1128 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1130 t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INPUT_INFO, &tag);
1131 pa_tagstruct_putu32(t, idx);
1132 pa_pstream_send_tagstruct(c->pstream, t);
1133 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_input_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1135 return o;
1138 pa_operation* pa_context_get_sink_input_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sink_input_info*i, int is_last, void *userdata), void *userdata) {
1139 return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INPUT_INFO_LIST, context_get_sink_input_info_callback, (pa_operation_cb_t) cb, userdata);
1142 /*** Source output info ***/
1144 static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
1145 pa_operation *o = userdata;
1146 int eol = 1;
1148 pa_assert(pd);
1149 pa_assert(o);
1150 pa_assert(PA_REFCNT_VALUE(o) >= 1);
1152 if (!o->context)
1153 goto finish;
1155 if (command != PA_COMMAND_REPLY) {
1156 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
1157 goto finish;
1159 eol = -1;
1160 } else {
1162 while (!pa_tagstruct_eof(t)) {
1163 pa_source_output_info i;
1164 pa_bool_t mute = FALSE, corked = FALSE, has_volume = FALSE, volume_writable = TRUE;
1166 pa_zero(i);
1167 i.proplist = pa_proplist_new();
1168 i.format = pa_format_info_new();
1170 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
1171 pa_tagstruct_gets(t, &i.name) < 0 ||
1172 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
1173 pa_tagstruct_getu32(t, &i.client) < 0 ||
1174 pa_tagstruct_getu32(t, &i.source) < 0 ||
1175 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
1176 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
1177 pa_tagstruct_get_usec(t, &i.buffer_usec) < 0 ||
1178 pa_tagstruct_get_usec(t, &i.source_usec) < 0 ||
1179 pa_tagstruct_gets(t, &i.resample_method) < 0 ||
1180 pa_tagstruct_gets(t, &i.driver) < 0 ||
1181 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) ||
1182 (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0) ||
1183 (o->context->version >= 22 && (pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
1184 pa_tagstruct_get_boolean(t, &mute) < 0 ||
1185 pa_tagstruct_get_boolean(t, &has_volume) < 0 ||
1186 pa_tagstruct_get_boolean(t, &volume_writable) < 0 ||
1187 pa_tagstruct_get_format_info(t, i.format) < 0))) {
1189 pa_context_fail(o->context, PA_ERR_PROTOCOL);
1190 pa_proplist_free(i.proplist);
1191 pa_format_info_free(i.format);
1192 goto finish;
1195 i.mute = (int) mute;
1196 i.corked = (int) corked;
1197 i.has_volume = (int) has_volume;
1198 i.volume_writable = (int) volume_writable;
1200 if (o->callback) {
1201 pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback;
1202 cb(o->context, &i, 0, o->userdata);
1205 pa_proplist_free(i.proplist);
1206 pa_format_info_free(i.format);
1210 if (o->callback) {
1211 pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback;
1212 cb(o->context, NULL, eol, o->userdata);
1215 finish:
1216 pa_operation_done(o);
1217 pa_operation_unref(o);
1220 pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_source_output_info_cb_t cb, void *userdata) {
1221 pa_tagstruct *t;
1222 pa_operation *o;
1223 uint32_t tag;
1225 pa_assert(c);
1226 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1227 pa_assert(cb);
1229 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1230 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1231 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1233 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1235 t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO, &tag);
1236 pa_tagstruct_putu32(t, idx);
1237 pa_pstream_send_tagstruct(c->pstream, t);
1238 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_output_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1240 return o;
1243 pa_operation* pa_context_get_source_output_info_list(pa_context *c, pa_source_output_info_cb_t cb, void *userdata) {
1244 return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST, context_get_source_output_info_callback, (pa_operation_cb_t) cb, userdata);
1247 /*** Volume manipulation ***/
1249 pa_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) {
1250 pa_operation *o;
1251 pa_tagstruct *t;
1252 uint32_t tag;
1254 pa_assert(c);
1255 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1256 pa_assert(volume);
1258 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1259 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1260 PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
1262 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1264 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag);
1265 pa_tagstruct_putu32(t, idx);
1266 pa_tagstruct_puts(t, NULL);
1267 pa_tagstruct_put_cvolume(t, volume);
1268 pa_pstream_send_tagstruct(c->pstream, t);
1269 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1271 return o;
1274 pa_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) {
1275 pa_operation *o;
1276 pa_tagstruct *t;
1277 uint32_t tag;
1279 pa_assert(c);
1280 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1281 pa_assert(name);
1282 pa_assert(volume);
1284 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1285 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1286 PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
1287 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
1289 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1291 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag);
1292 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1293 pa_tagstruct_puts(t, name);
1294 pa_tagstruct_put_cvolume(t, volume);
1295 pa_pstream_send_tagstruct(c->pstream, t);
1296 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1298 return o;
1301 pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
1302 pa_operation *o;
1303 pa_tagstruct *t;
1304 uint32_t tag;
1306 pa_assert(c);
1307 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1309 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1310 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1312 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1314 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_MUTE, &tag);
1315 pa_tagstruct_putu32(t, idx);
1316 pa_tagstruct_puts(t, NULL);
1317 pa_tagstruct_put_boolean(t, mute);
1318 pa_pstream_send_tagstruct(c->pstream, t);
1319 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1321 return o;
1324 pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata) {
1325 pa_operation *o;
1326 pa_tagstruct *t;
1327 uint32_t tag;
1329 pa_assert(c);
1330 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1331 pa_assert(name);
1333 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1334 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1335 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
1337 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1339 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_MUTE, &tag);
1340 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1341 pa_tagstruct_puts(t, name);
1342 pa_tagstruct_put_boolean(t, mute);
1343 pa_pstream_send_tagstruct(c->pstream, t);
1344 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1346 return o;
1349 pa_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) {
1350 pa_operation *o;
1351 pa_tagstruct *t;
1352 uint32_t tag;
1354 pa_assert(c);
1355 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1356 pa_assert(volume);
1358 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1359 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1360 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1361 PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
1363 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1365 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_VOLUME, &tag);
1366 pa_tagstruct_putu32(t, idx);
1367 pa_tagstruct_put_cvolume(t, volume);
1368 pa_pstream_send_tagstruct(c->pstream, t);
1369 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1371 return o;
1374 pa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
1375 pa_operation *o;
1376 pa_tagstruct *t;
1377 uint32_t tag;
1379 pa_assert(c);
1380 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1382 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1383 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1384 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1385 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
1387 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1389 t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_MUTE, &tag);
1390 pa_tagstruct_putu32(t, idx);
1391 pa_tagstruct_put_boolean(t, mute);
1392 pa_pstream_send_tagstruct(c->pstream, t);
1393 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1395 return o;
1398 pa_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) {
1399 pa_operation *o;
1400 pa_tagstruct *t;
1401 uint32_t tag;
1403 pa_assert(c);
1404 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1405 pa_assert(volume);
1407 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1408 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1409 PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
1411 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1413 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag);
1414 pa_tagstruct_putu32(t, idx);
1415 pa_tagstruct_puts(t, NULL);
1416 pa_tagstruct_put_cvolume(t, volume);
1417 pa_pstream_send_tagstruct(c->pstream, t);
1418 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1420 return o;
1423 pa_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) {
1424 pa_operation *o;
1425 pa_tagstruct *t;
1426 uint32_t tag;
1428 pa_assert(c);
1429 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1430 pa_assert(name);
1431 pa_assert(volume);
1433 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1434 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1435 PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
1436 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
1438 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1440 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag);
1441 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1442 pa_tagstruct_puts(t, name);
1443 pa_tagstruct_put_cvolume(t, volume);
1444 pa_pstream_send_tagstruct(c->pstream, t);
1445 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1447 return o;
1450 pa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
1451 pa_operation *o;
1452 pa_tagstruct *t;
1453 uint32_t tag;
1455 pa_assert(c);
1456 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1458 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1459 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1461 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1463 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_MUTE, &tag);
1464 pa_tagstruct_putu32(t, idx);
1465 pa_tagstruct_puts(t, NULL);
1466 pa_tagstruct_put_boolean(t, mute);
1467 pa_pstream_send_tagstruct(c->pstream, t);
1468 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1470 return o;
1473 pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata) {
1474 pa_operation *o;
1475 pa_tagstruct *t;
1476 uint32_t tag;
1478 pa_assert(c);
1479 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1480 pa_assert(name);
1482 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1483 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1484 PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
1486 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1488 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_MUTE, &tag);
1489 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1490 pa_tagstruct_puts(t, name);
1491 pa_tagstruct_put_boolean(t, mute);
1492 pa_pstream_send_tagstruct(c->pstream, t);
1493 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1495 return o;
1498 pa_operation* pa_context_set_source_output_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
1499 pa_operation *o;
1500 pa_tagstruct *t;
1501 uint32_t tag;
1503 pa_assert(c);
1504 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1505 pa_assert(volume);
1507 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1508 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1509 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1510 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED);
1511 PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
1513 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1515 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_VOLUME, &tag);
1516 pa_tagstruct_putu32(t, idx);
1517 pa_tagstruct_put_cvolume(t, volume);
1518 pa_pstream_send_tagstruct(c->pstream, t);
1519 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1521 return o;
1524 pa_operation* pa_context_set_source_output_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
1525 pa_operation *o;
1526 pa_tagstruct *t;
1527 uint32_t tag;
1529 pa_assert(c);
1530 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1532 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1533 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1534 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1535 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED);
1537 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1539 t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_MUTE, &tag);
1540 pa_tagstruct_putu32(t, idx);
1541 pa_tagstruct_put_boolean(t, mute);
1542 pa_pstream_send_tagstruct(c->pstream, t);
1543 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1545 return o;
1548 /** Sample Cache **/
1550 static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
1551 pa_operation *o = userdata;
1552 int eol = 1;
1554 pa_assert(pd);
1555 pa_assert(o);
1556 pa_assert(PA_REFCNT_VALUE(o) >= 1);
1558 if (!o->context)
1559 goto finish;
1561 if (command != PA_COMMAND_REPLY) {
1562 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
1563 goto finish;
1565 eol = -1;
1566 } else {
1568 while (!pa_tagstruct_eof(t)) {
1569 pa_sample_info i;
1570 pa_bool_t lazy = FALSE;
1572 pa_zero(i);
1573 i.proplist = pa_proplist_new();
1575 if (pa_tagstruct_getu32(t, &i.index) < 0 ||
1576 pa_tagstruct_gets(t, &i.name) < 0 ||
1577 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
1578 pa_tagstruct_get_usec(t, &i.duration) < 0 ||
1579 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
1580 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
1581 pa_tagstruct_getu32(t, &i.bytes) < 0 ||
1582 pa_tagstruct_get_boolean(t, &lazy) < 0 ||
1583 pa_tagstruct_gets(t, &i.filename) < 0 ||
1584 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) {
1586 pa_context_fail(o->context, PA_ERR_PROTOCOL);
1587 goto finish;
1590 i.lazy = (int) lazy;
1592 if (o->callback) {
1593 pa_sample_info_cb_t cb = (pa_sample_info_cb_t) o->callback;
1594 cb(o->context, &i, 0, o->userdata);
1597 pa_proplist_free(i.proplist);
1601 if (o->callback) {
1602 pa_sample_info_cb_t cb = (pa_sample_info_cb_t) o->callback;
1603 cb(o->context, NULL, eol, o->userdata);
1606 finish:
1607 pa_operation_done(o);
1608 pa_operation_unref(o);
1611 pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name, pa_sample_info_cb_t cb, void *userdata) {
1612 pa_tagstruct *t;
1613 pa_operation *o;
1614 uint32_t tag;
1616 pa_assert(c);
1617 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1618 pa_assert(cb);
1620 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1621 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1622 PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
1624 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1626 t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag);
1627 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1628 pa_tagstruct_puts(t, name);
1629 pa_pstream_send_tagstruct(c->pstream, t);
1630 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sample_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1632 return o;
1635 pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, pa_sample_info_cb_t cb, void *userdata) {
1636 pa_tagstruct *t;
1637 pa_operation *o;
1638 uint32_t tag;
1640 pa_assert(c);
1641 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1642 pa_assert(cb);
1644 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1645 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1646 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1648 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1650 t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag);
1651 pa_tagstruct_putu32(t, idx);
1652 pa_tagstruct_puts(t, NULL);
1653 pa_pstream_send_tagstruct(c->pstream, t);
1654 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sample_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1656 return o;
1659 pa_operation* pa_context_get_sample_info_list(pa_context *c, pa_sample_info_cb_t cb, void *userdata) {
1660 return pa_context_send_simple_command(c, PA_COMMAND_GET_SAMPLE_INFO_LIST, context_get_sample_info_callback, (pa_operation_cb_t) cb, userdata);
1663 static pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
1664 pa_operation *o;
1665 pa_tagstruct *t;
1666 uint32_t tag;
1668 pa_assert(c);
1669 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1671 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1672 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1673 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1675 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1677 t = pa_tagstruct_command(c, command, &tag);
1678 pa_tagstruct_putu32(t, idx);
1679 pa_pstream_send_tagstruct(c->pstream, t);
1680 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1682 return o;
1685 pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
1686 return command_kill(c, PA_COMMAND_KILL_CLIENT, idx, cb, userdata);
1689 pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
1690 return command_kill(c, PA_COMMAND_KILL_SINK_INPUT, idx, cb, userdata);
1693 pa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
1694 return command_kill(c, PA_COMMAND_KILL_SOURCE_OUTPUT, idx, cb, userdata);
1697 static void context_index_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
1698 pa_operation *o = userdata;
1699 uint32_t idx;
1701 pa_assert(pd);
1702 pa_assert(o);
1703 pa_assert(PA_REFCNT_VALUE(o) >= 1);
1705 if (!o->context)
1706 goto finish;
1708 if (command != PA_COMMAND_REPLY) {
1709 if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
1710 goto finish;
1712 idx = PA_INVALID_INDEX;
1713 } else if (pa_tagstruct_getu32(t, &idx) ||
1714 !pa_tagstruct_eof(t)) {
1715 pa_context_fail(o->context, PA_ERR_PROTOCOL);
1716 goto finish;
1719 if (o->callback) {
1720 pa_context_index_cb_t cb = (pa_context_index_cb_t) o->callback;
1721 cb(o->context, idx, o->userdata);
1725 finish:
1726 pa_operation_done(o);
1727 pa_operation_unref(o);
1730 pa_operation* pa_context_load_module(pa_context *c, const char*name, const char *argument, pa_context_index_cb_t cb, void *userdata) {
1731 pa_operation *o;
1732 pa_tagstruct *t;
1733 uint32_t tag;
1735 pa_assert(c);
1736 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1738 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1739 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1740 PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
1742 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1744 t = pa_tagstruct_command(c, PA_COMMAND_LOAD_MODULE, &tag);
1745 pa_tagstruct_puts(t, name);
1746 pa_tagstruct_puts(t, argument);
1747 pa_pstream_send_tagstruct(c->pstream, t);
1748 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_index_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1750 return o;
1753 pa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
1754 return command_kill(c, PA_COMMAND_UNLOAD_MODULE, idx, cb, userdata);
1757 /*** Autoload stuff ***/
1759 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name, "Module auto-loading no longer supported.");
1761 pa_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) {
1763 pa_assert(c);
1764 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1766 PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
1769 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index, "Module auto-loading no longer supported.");
1771 pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, pa_autoload_info_cb_t cb, void *userdata) {
1772 pa_assert(c);
1773 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1775 PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
1778 PA_WARN_REFERENCE(pa_context_get_autoload_info_list, "Module auto-loading no longer supported.");
1780 pa_operation* pa_context_get_autoload_info_list(pa_context *c, pa_autoload_info_cb_t cb, void *userdata) {
1781 pa_assert(c);
1782 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1784 PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
1787 PA_WARN_REFERENCE(pa_context_add_autoload, "Module auto-loading no longer supported.");
1789 pa_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 cb, void* userdata) {
1790 pa_assert(c);
1791 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1793 PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
1796 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name, "Module auto-loading no longer supported.");
1798 pa_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) {
1799 pa_assert(c);
1800 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1802 PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
1805 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index, "Module auto-loading no longer supported.");
1807 pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void* userdata) {
1808 pa_assert(c);
1809 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1811 PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
1814 pa_operation* pa_context_move_sink_input_by_name(pa_context *c, uint32_t idx, const char *sink_name, pa_context_success_cb_t cb, void* userdata) {
1815 pa_operation *o;
1816 pa_tagstruct *t;
1817 uint32_t tag;
1819 pa_assert(c);
1820 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1822 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1823 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1824 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
1825 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1826 PA_CHECK_VALIDITY_RETURN_NULL(c, sink_name && *sink_name, PA_ERR_INVALID);
1828 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1830 t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SINK_INPUT, &tag);
1831 pa_tagstruct_putu32(t, idx);
1832 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1833 pa_tagstruct_puts(t, sink_name);
1834 pa_pstream_send_tagstruct(c->pstream, t);
1835 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1837 return o;
1840 pa_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) {
1841 pa_operation *o;
1842 pa_tagstruct *t;
1843 uint32_t tag;
1845 pa_assert(c);
1846 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1848 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1849 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1850 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
1851 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1852 PA_CHECK_VALIDITY_RETURN_NULL(c, sink_idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1854 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1856 t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SINK_INPUT, &tag);
1857 pa_tagstruct_putu32(t, idx);
1858 pa_tagstruct_putu32(t, sink_idx);
1859 pa_tagstruct_puts(t, NULL);
1860 pa_pstream_send_tagstruct(c->pstream, t);
1861 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1863 return o;
1866 pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx, const char *source_name, pa_context_success_cb_t cb, void* userdata) {
1867 pa_operation *o;
1868 pa_tagstruct *t;
1869 uint32_t tag;
1871 pa_assert(c);
1872 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1874 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1875 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1876 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
1877 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1878 PA_CHECK_VALIDITY_RETURN_NULL(c, source_name && *source_name, PA_ERR_INVALID);
1880 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1882 t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SOURCE_OUTPUT, &tag);
1883 pa_tagstruct_putu32(t, idx);
1884 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1885 pa_tagstruct_puts(t, source_name);
1886 pa_pstream_send_tagstruct(c->pstream, t);
1887 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1889 return o;
1892 pa_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) {
1893 pa_operation *o;
1894 pa_tagstruct *t;
1895 uint32_t tag;
1897 pa_assert(c);
1898 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1900 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1901 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1902 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
1903 PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1904 PA_CHECK_VALIDITY_RETURN_NULL(c, source_idx != PA_INVALID_INDEX, PA_ERR_INVALID);
1906 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1908 t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SOURCE_OUTPUT, &tag);
1909 pa_tagstruct_putu32(t, idx);
1910 pa_tagstruct_putu32(t, source_idx);
1911 pa_tagstruct_puts(t, NULL);
1912 pa_pstream_send_tagstruct(c->pstream, t);
1913 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1915 return o;
1918 pa_operation* pa_context_suspend_sink_by_name(pa_context *c, const char *sink_name, int suspend, pa_context_success_cb_t cb, void* userdata) {
1919 pa_operation *o;
1920 pa_tagstruct *t;
1921 uint32_t tag;
1923 pa_assert(c);
1924 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1926 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1927 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1928 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
1929 PA_CHECK_VALIDITY_RETURN_NULL(c, !sink_name || *sink_name, PA_ERR_INVALID);
1931 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1933 t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag);
1934 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1935 pa_tagstruct_puts(t, sink_name);
1936 pa_tagstruct_put_boolean(t, suspend);
1937 pa_pstream_send_tagstruct(c->pstream, t);
1938 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1940 return o;
1943 pa_operation* pa_context_suspend_sink_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) {
1944 pa_operation *o;
1945 pa_tagstruct *t;
1946 uint32_t tag;
1948 pa_assert(c);
1949 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1951 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1952 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1953 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
1955 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1957 t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag);
1958 pa_tagstruct_putu32(t, idx);
1959 pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL);
1960 pa_tagstruct_put_boolean(t, suspend);
1961 pa_pstream_send_tagstruct(c->pstream, t);
1962 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1964 return o;
1967 pa_operation* pa_context_suspend_source_by_name(pa_context *c, const char *source_name, int suspend, pa_context_success_cb_t cb, void* userdata) {
1968 pa_operation *o;
1969 pa_tagstruct *t;
1970 uint32_t tag;
1972 pa_assert(c);
1973 pa_assert(PA_REFCNT_VALUE(c) >= 1);
1975 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
1976 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
1977 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
1978 PA_CHECK_VALIDITY_RETURN_NULL(c, !source_name || *source_name, PA_ERR_INVALID);
1980 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
1982 t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag);
1983 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
1984 pa_tagstruct_puts(t, source_name);
1985 pa_tagstruct_put_boolean(t, suspend);
1986 pa_pstream_send_tagstruct(c->pstream, t);
1987 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
1989 return o;
1992 pa_operation* pa_context_suspend_source_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) {
1993 pa_operation *o;
1994 pa_tagstruct *t;
1995 uint32_t tag;
1997 pa_assert(c);
1998 pa_assert(PA_REFCNT_VALUE(c) >= 1);
2000 PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
2001 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
2002 PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
2004 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
2006 t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag);
2007 pa_tagstruct_putu32(t, idx);
2008 pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL);
2009 pa_tagstruct_put_boolean(t, suspend);
2010 pa_pstream_send_tagstruct(c->pstream, t);
2011 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
2013 return o;