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
29 #include <pulse/context.h>
30 #include <pulse/gccmacro.h>
31 #include <pulse/xmalloc.h>
33 #include <pulsecore/macro.h>
34 #include <pulsecore/core-util.h>
35 #include <pulsecore/pstream-util.h>
38 #include "fork-detect.h"
40 #include "introspect.h"
44 static void context_stat_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
45 pa_operation
*o
= userdata
;
46 pa_stat_info i
, *p
= &i
;
50 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
57 if (command
!= PA_COMMAND_REPLY
) {
58 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
62 } else if (pa_tagstruct_getu32(t
, &i
.memblock_total
) < 0 ||
63 pa_tagstruct_getu32(t
, &i
.memblock_total_size
) < 0 ||
64 pa_tagstruct_getu32(t
, &i
.memblock_allocated
) < 0 ||
65 pa_tagstruct_getu32(t
, &i
.memblock_allocated_size
) < 0 ||
66 pa_tagstruct_getu32(t
, &i
.scache_size
) < 0 ||
67 !pa_tagstruct_eof(t
)) {
68 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
73 pa_stat_info_cb_t cb
= (pa_stat_info_cb_t
) o
->callback
;
74 cb(o
->context
, p
, o
->userdata
);
79 pa_operation_unref(o
);
82 pa_operation
* pa_context_stat(pa_context
*c
, pa_stat_info_cb_t cb
, void *userdata
) {
83 return pa_context_send_simple_command(c
, PA_COMMAND_STAT
, context_stat_callback
, (pa_operation_cb_t
) cb
, userdata
);
88 static void context_get_server_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
89 pa_operation
*o
= userdata
;
90 pa_server_info i
, *p
= &i
;
94 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
101 if (command
!= PA_COMMAND_REPLY
) {
102 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
106 } else if (pa_tagstruct_gets(t
, &i
.server_name
) < 0 ||
107 pa_tagstruct_gets(t
, &i
.server_version
) < 0 ||
108 pa_tagstruct_gets(t
, &i
.user_name
) < 0 ||
109 pa_tagstruct_gets(t
, &i
.host_name
) < 0 ||
110 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
111 pa_tagstruct_gets(t
, &i
.default_sink_name
) < 0 ||
112 pa_tagstruct_gets(t
, &i
.default_source_name
) < 0 ||
113 pa_tagstruct_getu32(t
, &i
.cookie
) < 0 ||
114 (o
->context
->version
>= 15 &&
115 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0) ||
116 !pa_tagstruct_eof(t
)) {
118 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
122 if (p
&& o
->context
->version
< 15)
123 pa_channel_map_init_extend(&i
.channel_map
, i
.sample_spec
.channels
, PA_CHANNEL_MAP_DEFAULT
);
126 pa_server_info_cb_t cb
= (pa_server_info_cb_t
) o
->callback
;
127 cb(o
->context
, p
, o
->userdata
);
131 pa_operation_done(o
);
132 pa_operation_unref(o
);
135 pa_operation
* pa_context_get_server_info(pa_context
*c
, pa_server_info_cb_t cb
, void *userdata
) {
136 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SERVER_INFO
, context_get_server_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
141 static void context_get_sink_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
142 pa_operation
*o
= userdata
;
147 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
152 if (command
!= PA_COMMAND_REPLY
) {
153 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
159 while (!pa_tagstruct_eof(t
)) {
165 const char *ap
= NULL
;
168 i
.proplist
= pa_proplist_new();
169 i
.base_volume
= PA_VOLUME_NORM
;
170 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
172 state
= PA_SINK_INVALID_STATE
;
173 i
.card
= PA_INVALID_INDEX
;
175 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
176 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
177 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
178 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
179 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
180 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
181 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
182 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
183 pa_tagstruct_getu32(t
, &i
.monitor_source
) < 0 ||
184 pa_tagstruct_gets(t
, &i
.monitor_source_name
) < 0 ||
185 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
186 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
187 pa_tagstruct_getu32(t
, &flags
) < 0 ||
188 (o
->context
->version
>= 13 &&
189 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
190 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
191 (o
->context
->version
>= 15 &&
192 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
193 pa_tagstruct_getu32(t
, &state
) < 0 ||
194 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
195 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
196 (o
->context
->version
>= 16 &&
197 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
199 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
200 pa_proplist_free(i
.proplist
);
204 if (o
->context
->version
>= 16) {
206 i
.ports
= pa_xnew(pa_sink_port_info
*, i
.n_ports
+1);
207 i
.ports
[0] = pa_xnew(pa_sink_port_info
, i
.n_ports
);
209 for (j
= 0; j
< i
.n_ports
; j
++) {
210 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
211 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
212 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
214 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
216 pa_xfree(i
.ports
[0]);
217 pa_proplist_free(i
.proplist
);
221 i
.ports
[j
] = &i
.ports
[0][j
];
227 if (pa_tagstruct_gets(t
, &ap
) < 0) {
228 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
229 pa_xfree(i
.ports
[0]);
231 pa_proplist_free(i
.proplist
);
236 for (j
= 0; j
< i
.n_ports
; j
++)
237 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
238 i
.active_port
= i
.ports
[j
];
245 i
.flags
= (pa_sink_flags_t
) flags
;
246 i
.state
= (pa_sink_state_t
) state
;
249 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
250 cb(o
->context
, &i
, 0, o
->userdata
);
253 pa_proplist_free(i
.proplist
);
258 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
259 cb(o
->context
, NULL
, eol
, o
->userdata
);
263 pa_operation_done(o
);
264 pa_operation_unref(o
);
267 pa_operation
* pa_context_get_sink_info_list(pa_context
*c
, pa_sink_info_cb_t cb
, void *userdata
) {
268 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SINK_INFO_LIST
, context_get_sink_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
271 pa_operation
* pa_context_get_sink_info_by_index(pa_context
*c
, uint32_t idx
, pa_sink_info_cb_t cb
, void *userdata
) {
277 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
280 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
281 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
283 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
285 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
286 pa_tagstruct_putu32(t
, idx
);
287 pa_tagstruct_puts(t
, NULL
);
288 pa_pstream_send_tagstruct(c
->pstream
, t
);
289 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
);
294 pa_operation
* pa_context_get_sink_info_by_name(pa_context
*c
, const char *name
, pa_sink_info_cb_t cb
, void *userdata
) {
300 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
303 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
304 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
305 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
307 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
309 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
310 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
311 pa_tagstruct_puts(t
, name
);
312 pa_pstream_send_tagstruct(c
->pstream
, t
);
313 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
);
318 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
) {
324 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
326 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
327 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
328 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
329 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
331 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
333 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
334 pa_tagstruct_putu32(t
, idx
);
335 pa_tagstruct_puts(t
, NULL
);
336 pa_tagstruct_puts(t
, port
);
337 pa_pstream_send_tagstruct(c
->pstream
, t
);
338 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
);
343 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
) {
349 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
351 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
352 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
353 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
354 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
356 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
358 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
359 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
360 pa_tagstruct_puts(t
, name
);
361 pa_tagstruct_puts(t
, port
);
362 pa_pstream_send_tagstruct(c
->pstream
, t
);
363 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
);
368 /*** Source info ***/
370 static void context_get_source_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
371 pa_operation
*o
= userdata
;
376 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
381 if (command
!= PA_COMMAND_REPLY
) {
382 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
388 while (!pa_tagstruct_eof(t
)) {
397 i
.proplist
= pa_proplist_new();
398 i
.base_volume
= PA_VOLUME_NORM
;
399 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
401 state
= PA_SOURCE_INVALID_STATE
;
402 i
.card
= PA_INVALID_INDEX
;
404 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
405 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
406 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
407 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
408 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
409 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
410 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
411 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
412 pa_tagstruct_getu32(t
, &i
.monitor_of_sink
) < 0 ||
413 pa_tagstruct_gets(t
, &i
.monitor_of_sink_name
) < 0 ||
414 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
415 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
416 pa_tagstruct_getu32(t
, &flags
) < 0 ||
417 (o
->context
->version
>= 13 &&
418 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
419 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
420 (o
->context
->version
>= 15 &&
421 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
422 pa_tagstruct_getu32(t
, &state
) < 0 ||
423 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
424 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
425 (o
->context
->version
>= 16 &&
426 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
428 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
429 pa_proplist_free(i
.proplist
);
433 if (o
->context
->version
>= 16) {
435 i
.ports
= pa_xnew(pa_source_port_info
*, i
.n_ports
+1);
436 i
.ports
[0] = pa_xnew(pa_source_port_info
, i
.n_ports
);
438 for (j
= 0; j
< i
.n_ports
; j
++) {
439 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
440 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
441 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
443 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
444 pa_xfree(i
.ports
[0]);
446 pa_proplist_free(i
.proplist
);
450 i
.ports
[j
] = &i
.ports
[0][j
];
456 if (pa_tagstruct_gets(t
, &ap
) < 0) {
457 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
458 pa_xfree(i
.ports
[0]);
460 pa_proplist_free(i
.proplist
);
465 for (j
= 0; j
< i
.n_ports
; j
++)
466 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
467 i
.active_port
= i
.ports
[j
];
474 i
.flags
= (pa_source_flags_t
) flags
;
475 i
.state
= (pa_source_state_t
) state
;
478 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
479 cb(o
->context
, &i
, 0, o
->userdata
);
482 pa_proplist_free(i
.proplist
);
487 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
488 cb(o
->context
, NULL
, eol
, o
->userdata
);
492 pa_operation_done(o
);
493 pa_operation_unref(o
);
496 pa_operation
* pa_context_get_source_info_list(pa_context
*c
, pa_source_info_cb_t cb
, void *userdata
) {
497 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SOURCE_INFO_LIST
, context_get_source_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
500 pa_operation
* pa_context_get_source_info_by_index(pa_context
*c
, uint32_t idx
, pa_source_info_cb_t cb
, void *userdata
) {
506 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
509 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
510 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
512 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
514 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
515 pa_tagstruct_putu32(t
, idx
);
516 pa_tagstruct_puts(t
, NULL
);
517 pa_pstream_send_tagstruct(c
->pstream
, t
);
518 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
);
523 pa_operation
* pa_context_get_source_info_by_name(pa_context
*c
, const char *name
, pa_source_info_cb_t cb
, void *userdata
) {
529 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
532 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
533 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
534 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
536 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
538 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
539 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
540 pa_tagstruct_puts(t
, name
);
541 pa_pstream_send_tagstruct(c
->pstream
, t
);
542 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
);
547 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
) {
553 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
555 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
556 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
557 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
558 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
560 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
562 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
563 pa_tagstruct_putu32(t
, idx
);
564 pa_tagstruct_puts(t
, NULL
);
565 pa_tagstruct_puts(t
, port
);
566 pa_pstream_send_tagstruct(c
->pstream
, t
);
567 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
);
572 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
) {
578 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
580 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
581 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
582 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
583 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
585 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
587 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
588 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
589 pa_tagstruct_puts(t
, name
);
590 pa_tagstruct_puts(t
, port
);
591 pa_pstream_send_tagstruct(c
->pstream
, t
);
592 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
);
597 /*** Client info ***/
599 static void context_get_client_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
600 pa_operation
*o
= userdata
;
605 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
610 if (command
!= PA_COMMAND_REPLY
) {
611 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
617 while (!pa_tagstruct_eof(t
)) {
621 i
.proplist
= pa_proplist_new();
623 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
624 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
625 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
626 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
627 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
629 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
630 pa_proplist_free(i
.proplist
);
635 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
636 cb(o
->context
, &i
, 0, o
->userdata
);
639 pa_proplist_free(i
.proplist
);
644 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
645 cb(o
->context
, NULL
, eol
, o
->userdata
);
649 pa_operation_done(o
);
650 pa_operation_unref(o
);
653 pa_operation
* pa_context_get_client_info(pa_context
*c
, uint32_t idx
, pa_client_info_cb_t cb
, void *userdata
) {
659 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
662 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
663 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
664 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
666 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
668 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CLIENT_INFO
, &tag
);
669 pa_tagstruct_putu32(t
, idx
);
670 pa_pstream_send_tagstruct(c
->pstream
, t
);
671 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
);
676 pa_operation
* pa_context_get_client_info_list(pa_context
*c
, pa_client_info_cb_t cb
, void *userdata
) {
677 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CLIENT_INFO_LIST
, context_get_client_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
682 static void context_get_card_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
683 pa_operation
*o
= userdata
;
688 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
693 if (command
!= PA_COMMAND_REPLY
) {
694 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
700 while (!pa_tagstruct_eof(t
)) {
707 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
708 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
709 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
710 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
711 pa_tagstruct_getu32(t
, &i
.n_profiles
) < 0) {
713 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
717 if (i
.n_profiles
> 0) {
718 i
.profiles
= pa_xnew0(pa_card_profile_info
, i
.n_profiles
+1);
720 for (j
= 0; j
< i
.n_profiles
; j
++) {
722 if (pa_tagstruct_gets(t
, &i
.profiles
[j
].name
) < 0 ||
723 pa_tagstruct_gets(t
, &i
.profiles
[j
].description
) < 0 ||
724 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sinks
) < 0 ||
725 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sources
) < 0 ||
726 pa_tagstruct_getu32(t
, &i
.profiles
[j
].priority
) < 0) {
728 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
729 pa_xfree(i
.profiles
);
734 /* Terminate with an extra NULL entry, just to make sure */
735 i
.profiles
[j
].name
= NULL
;
736 i
.profiles
[j
].description
= NULL
;
739 i
.proplist
= pa_proplist_new();
741 if (pa_tagstruct_gets(t
, &ap
) < 0 ||
742 pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) {
744 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
745 pa_xfree(i
.profiles
);
746 pa_proplist_free(i
.proplist
);
751 for (j
= 0; j
< i
.n_profiles
; j
++)
752 if (pa_streq(i
.profiles
[j
].name
, ap
)) {
753 i
.active_profile
= &i
.profiles
[j
];
759 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
760 cb(o
->context
, &i
, 0, o
->userdata
);
763 pa_proplist_free(i
.proplist
);
764 pa_xfree(i
.profiles
);
769 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
770 cb(o
->context
, NULL
, eol
, o
->userdata
);
774 pa_operation_done(o
);
775 pa_operation_unref(o
);
778 pa_operation
* pa_context_get_card_info_by_index(pa_context
*c
, uint32_t idx
, pa_card_info_cb_t cb
, void *userdata
) {
784 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
787 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
788 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
789 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
790 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
792 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
794 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
795 pa_tagstruct_putu32(t
, idx
);
796 pa_tagstruct_puts(t
, NULL
);
797 pa_pstream_send_tagstruct(c
->pstream
, t
);
798 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
);
803 pa_operation
* pa_context_get_card_info_by_name(pa_context
*c
, const char*name
, pa_card_info_cb_t cb
, void *userdata
) {
809 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
812 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
813 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
814 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
815 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
817 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
819 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
820 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
821 pa_tagstruct_puts(t
, name
);
822 pa_pstream_send_tagstruct(c
->pstream
, t
);
823 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
);
828 pa_operation
* pa_context_get_card_info_list(pa_context
*c
, pa_card_info_cb_t cb
, void *userdata
) {
829 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
832 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
) {
838 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
840 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
841 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
842 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
843 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
845 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
847 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
848 pa_tagstruct_putu32(t
, idx
);
849 pa_tagstruct_puts(t
, NULL
);
850 pa_tagstruct_puts(t
, profile
);
851 pa_pstream_send_tagstruct(c
->pstream
, t
);
852 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
);
857 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
) {
863 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
865 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
866 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
867 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
868 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
870 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
872 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
873 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
874 pa_tagstruct_puts(t
, name
);
875 pa_tagstruct_puts(t
, profile
);
876 pa_pstream_send_tagstruct(c
->pstream
, t
);
877 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
);
882 /*** Module info ***/
884 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
885 pa_operation
*o
= userdata
;
890 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
895 if (command
!= PA_COMMAND_REPLY
) {
896 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
902 while (!pa_tagstruct_eof(t
)) {
904 pa_bool_t auto_unload
= FALSE
;
907 i
.proplist
= pa_proplist_new();
909 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
910 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
911 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
912 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
913 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
914 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
915 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
919 i
.auto_unload
= (int) auto_unload
;
922 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
923 cb(o
->context
, &i
, 0, o
->userdata
);
926 pa_proplist_free(i
.proplist
);
931 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
932 cb(o
->context
, NULL
, eol
, o
->userdata
);
936 pa_operation_done(o
);
937 pa_operation_unref(o
);
940 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
946 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
949 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
950 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
951 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
953 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
955 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
956 pa_tagstruct_putu32(t
, idx
);
957 pa_pstream_send_tagstruct(c
->pstream
, t
);
958 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
);
963 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
964 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
967 /*** Sink input info ***/
969 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
970 pa_operation
*o
= userdata
;
975 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
980 if (command
!= PA_COMMAND_REPLY
) {
981 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
987 while (!pa_tagstruct_eof(t
)) {
988 pa_sink_input_info i
;
989 pa_bool_t mute
= FALSE
;
992 i
.proplist
= pa_proplist_new();
994 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
995 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
996 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
997 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
998 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
999 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1000 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1001 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1002 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1003 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1004 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1005 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1006 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1007 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1009 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1010 pa_proplist_free(i
.proplist
);
1014 i
.mute
= (int) mute
;
1017 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1018 cb(o
->context
, &i
, 0, o
->userdata
);
1021 pa_proplist_free(i
.proplist
);
1026 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1027 cb(o
->context
, NULL
, eol
, o
->userdata
);
1031 pa_operation_done(o
);
1032 pa_operation_unref(o
);
1035 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1041 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1044 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1045 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1046 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1048 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1050 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1051 pa_tagstruct_putu32(t
, idx
);
1052 pa_pstream_send_tagstruct(c
->pstream
, t
);
1053 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
);
1058 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
) {
1059 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
);
1062 /*** Source output info ***/
1064 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1065 pa_operation
*o
= userdata
;
1070 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1075 if (command
!= PA_COMMAND_REPLY
) {
1076 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1082 while (!pa_tagstruct_eof(t
)) {
1083 pa_source_output_info i
;
1086 i
.proplist
= pa_proplist_new();
1088 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1089 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1090 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1091 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1092 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1093 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1094 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1095 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1096 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1097 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1098 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1099 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1101 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1102 pa_proplist_free(i
.proplist
);
1107 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1108 cb(o
->context
, &i
, 0, o
->userdata
);
1111 pa_proplist_free(i
.proplist
);
1116 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1117 cb(o
->context
, NULL
, eol
, o
->userdata
);
1121 pa_operation_done(o
);
1122 pa_operation_unref(o
);
1125 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1131 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1134 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1135 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1136 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1138 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1140 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1141 pa_tagstruct_putu32(t
, idx
);
1142 pa_pstream_send_tagstruct(c
->pstream
, t
);
1143 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
);
1148 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1149 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
);
1152 /*** Volume manipulation ***/
1154 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
) {
1160 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1163 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1164 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1165 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1167 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1169 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1170 pa_tagstruct_putu32(t
, idx
);
1171 pa_tagstruct_puts(t
, NULL
);
1172 pa_tagstruct_put_cvolume(t
, volume
);
1173 pa_pstream_send_tagstruct(c
->pstream
, t
);
1174 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
);
1179 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
) {
1185 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1189 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1190 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1191 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1192 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1194 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1196 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1197 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1198 pa_tagstruct_puts(t
, name
);
1199 pa_tagstruct_put_cvolume(t
, volume
);
1200 pa_pstream_send_tagstruct(c
->pstream
, t
);
1201 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
);
1206 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
) {
1212 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1214 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1215 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1217 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1219 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1220 pa_tagstruct_putu32(t
, idx
);
1221 pa_tagstruct_puts(t
, NULL
);
1222 pa_tagstruct_put_boolean(t
, mute
);
1223 pa_pstream_send_tagstruct(c
->pstream
, t
);
1224 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
);
1229 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
) {
1235 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1238 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1239 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1240 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1242 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1244 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1245 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1246 pa_tagstruct_puts(t
, name
);
1247 pa_tagstruct_put_boolean(t
, mute
);
1248 pa_pstream_send_tagstruct(c
->pstream
, t
);
1249 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
);
1254 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
) {
1260 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1263 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1264 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1265 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1266 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1268 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1270 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1271 pa_tagstruct_putu32(t
, idx
);
1272 pa_tagstruct_put_cvolume(t
, volume
);
1273 pa_pstream_send_tagstruct(c
->pstream
, t
);
1274 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
);
1279 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1285 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1287 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1288 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1289 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1290 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1292 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1294 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1295 pa_tagstruct_putu32(t
, idx
);
1296 pa_tagstruct_put_boolean(t
, mute
);
1297 pa_pstream_send_tagstruct(c
->pstream
, t
);
1298 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
);
1303 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
) {
1309 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1312 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1313 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1314 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1316 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1318 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1319 pa_tagstruct_putu32(t
, idx
);
1320 pa_tagstruct_puts(t
, NULL
);
1321 pa_tagstruct_put_cvolume(t
, volume
);
1322 pa_pstream_send_tagstruct(c
->pstream
, t
);
1323 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
);
1328 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
) {
1334 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1338 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1339 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1340 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1341 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1343 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1345 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1346 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1347 pa_tagstruct_puts(t
, name
);
1348 pa_tagstruct_put_cvolume(t
, volume
);
1349 pa_pstream_send_tagstruct(c
->pstream
, t
);
1350 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
);
1355 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
) {
1361 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1363 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1364 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1366 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1368 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1369 pa_tagstruct_putu32(t
, idx
);
1370 pa_tagstruct_puts(t
, NULL
);
1371 pa_tagstruct_put_boolean(t
, mute
);
1372 pa_pstream_send_tagstruct(c
->pstream
, t
);
1373 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
);
1378 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
) {
1384 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1387 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1388 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1389 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1391 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1393 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1394 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1395 pa_tagstruct_puts(t
, name
);
1396 pa_tagstruct_put_boolean(t
, mute
);
1397 pa_pstream_send_tagstruct(c
->pstream
, t
);
1398 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
);
1403 /** Sample Cache **/
1405 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1406 pa_operation
*o
= userdata
;
1411 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1416 if (command
!= PA_COMMAND_REPLY
) {
1417 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1423 while (!pa_tagstruct_eof(t
)) {
1425 pa_bool_t lazy
= FALSE
;
1428 i
.proplist
= pa_proplist_new();
1430 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1431 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1432 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1433 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1434 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1435 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1436 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1437 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1438 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1439 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1441 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1445 i
.lazy
= (int) lazy
;
1448 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1449 cb(o
->context
, &i
, 0, o
->userdata
);
1452 pa_proplist_free(i
.proplist
);
1457 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1458 cb(o
->context
, NULL
, eol
, o
->userdata
);
1462 pa_operation_done(o
);
1463 pa_operation_unref(o
);
1466 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1472 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1475 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1476 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1477 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1479 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1481 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1482 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1483 pa_tagstruct_puts(t
, name
);
1484 pa_pstream_send_tagstruct(c
->pstream
, t
);
1485 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
);
1490 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1496 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1499 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1500 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1501 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1503 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1505 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1506 pa_tagstruct_putu32(t
, idx
);
1507 pa_tagstruct_puts(t
, NULL
);
1508 pa_pstream_send_tagstruct(c
->pstream
, t
);
1509 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
);
1514 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1515 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1518 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1524 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1526 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1527 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1528 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1530 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1532 t
= pa_tagstruct_command(c
, command
, &tag
);
1533 pa_tagstruct_putu32(t
, idx
);
1534 pa_pstream_send_tagstruct(c
->pstream
, t
);
1535 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
);
1540 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1541 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1544 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1545 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1548 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1549 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1552 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1553 pa_operation
*o
= userdata
;
1558 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1563 if (command
!= PA_COMMAND_REPLY
) {
1564 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1567 idx
= PA_INVALID_INDEX
;
1568 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1569 !pa_tagstruct_eof(t
)) {
1570 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1575 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1576 cb(o
->context
, idx
, o
->userdata
);
1581 pa_operation_done(o
);
1582 pa_operation_unref(o
);
1585 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1591 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1593 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1594 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1595 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1597 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1599 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1600 pa_tagstruct_puts(t
, name
);
1601 pa_tagstruct_puts(t
, argument
);
1602 pa_pstream_send_tagstruct(c
->pstream
, t
);
1603 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1608 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1609 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1612 /*** Autoload stuff ***/
1614 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1616 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
) {
1619 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1621 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1624 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1626 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1628 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1630 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1633 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1635 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1637 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1639 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1642 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1644 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
) {
1646 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1648 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1651 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1653 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
) {
1655 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1657 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1660 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1662 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1664 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1666 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1669 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
) {
1675 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1677 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1678 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1679 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1680 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1681 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1683 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1685 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1686 pa_tagstruct_putu32(t
, idx
);
1687 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1688 pa_tagstruct_puts(t
, sink_name
);
1689 pa_pstream_send_tagstruct(c
->pstream
, t
);
1690 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
);
1695 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
) {
1701 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1703 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1704 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1705 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1706 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1707 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1709 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1711 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1712 pa_tagstruct_putu32(t
, idx
);
1713 pa_tagstruct_putu32(t
, sink_idx
);
1714 pa_tagstruct_puts(t
, NULL
);
1715 pa_pstream_send_tagstruct(c
->pstream
, t
);
1716 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
);
1721 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
) {
1727 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1729 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1730 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1731 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1732 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1733 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1735 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1737 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1738 pa_tagstruct_putu32(t
, idx
);
1739 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1740 pa_tagstruct_puts(t
, source_name
);
1741 pa_pstream_send_tagstruct(c
->pstream
, t
);
1742 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
);
1747 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
) {
1753 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1755 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1756 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1757 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1758 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1759 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1761 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1763 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1764 pa_tagstruct_putu32(t
, idx
);
1765 pa_tagstruct_putu32(t
, source_idx
);
1766 pa_tagstruct_puts(t
, NULL
);
1767 pa_pstream_send_tagstruct(c
->pstream
, t
);
1768 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
);
1773 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
) {
1779 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1781 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1782 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1783 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1784 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1786 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1788 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1789 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1790 pa_tagstruct_puts(t
, sink_name
);
1791 pa_tagstruct_put_boolean(t
, suspend
);
1792 pa_pstream_send_tagstruct(c
->pstream
, t
);
1793 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
);
1798 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1804 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1806 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1807 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1808 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1810 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1812 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1813 pa_tagstruct_putu32(t
, idx
);
1814 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1815 pa_tagstruct_put_boolean(t
, suspend
);
1816 pa_pstream_send_tagstruct(c
->pstream
, t
);
1817 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
);
1822 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
) {
1828 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1830 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1831 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1832 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1833 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1835 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1837 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1838 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1839 pa_tagstruct_puts(t
, source_name
);
1840 pa_tagstruct_put_boolean(t
, suspend
);
1841 pa_pstream_send_tagstruct(c
->pstream
, t
);
1842 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
);
1847 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1853 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1855 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1856 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1857 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1859 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1861 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1862 pa_tagstruct_putu32(t
, idx
);
1863 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1864 pa_tagstruct_put_boolean(t
, suspend
);
1865 pa_pstream_send_tagstruct(c
->pstream
, t
);
1866 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
);