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>
32 #include <pulse/fork-detect.h>
34 #include <pulsecore/macro.h>
35 #include <pulsecore/core-util.h>
36 #include <pulsecore/pstream-util.h>
39 #include "introspect.h"
43 static void context_stat_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
44 pa_operation
*o
= userdata
;
45 pa_stat_info i
, *p
= &i
;
49 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
56 if (command
!= PA_COMMAND_REPLY
) {
57 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
61 } else if (pa_tagstruct_getu32(t
, &i
.memblock_total
) < 0 ||
62 pa_tagstruct_getu32(t
, &i
.memblock_total_size
) < 0 ||
63 pa_tagstruct_getu32(t
, &i
.memblock_allocated
) < 0 ||
64 pa_tagstruct_getu32(t
, &i
.memblock_allocated_size
) < 0 ||
65 pa_tagstruct_getu32(t
, &i
.scache_size
) < 0 ||
66 !pa_tagstruct_eof(t
)) {
67 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
72 pa_stat_info_cb_t cb
= (pa_stat_info_cb_t
) o
->callback
;
73 cb(o
->context
, p
, o
->userdata
);
78 pa_operation_unref(o
);
81 pa_operation
* pa_context_stat(pa_context
*c
, pa_stat_info_cb_t cb
, void *userdata
) {
82 return pa_context_send_simple_command(c
, PA_COMMAND_STAT
, context_stat_callback
, (pa_operation_cb_t
) cb
, userdata
);
87 static void context_get_server_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
88 pa_operation
*o
= userdata
;
89 pa_server_info i
, *p
= &i
;
93 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
100 if (command
!= PA_COMMAND_REPLY
) {
101 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
105 } else if (pa_tagstruct_gets(t
, &i
.server_name
) < 0 ||
106 pa_tagstruct_gets(t
, &i
.server_version
) < 0 ||
107 pa_tagstruct_gets(t
, &i
.user_name
) < 0 ||
108 pa_tagstruct_gets(t
, &i
.host_name
) < 0 ||
109 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
110 pa_tagstruct_gets(t
, &i
.default_sink_name
) < 0 ||
111 pa_tagstruct_gets(t
, &i
.default_source_name
) < 0 ||
112 pa_tagstruct_getu32(t
, &i
.cookie
) < 0 ||
113 (o
->context
->version
>= 15 &&
114 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0) ||
115 !pa_tagstruct_eof(t
)) {
117 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
121 if (p
&& o
->context
->version
< 15)
122 pa_channel_map_init_extend(&i
.channel_map
, i
.sample_spec
.channels
, PA_CHANNEL_MAP_DEFAULT
);
125 pa_server_info_cb_t cb
= (pa_server_info_cb_t
) o
->callback
;
126 cb(o
->context
, p
, o
->userdata
);
130 pa_operation_done(o
);
131 pa_operation_unref(o
);
134 pa_operation
* pa_context_get_server_info(pa_context
*c
, pa_server_info_cb_t cb
, void *userdata
) {
135 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SERVER_INFO
, context_get_server_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
140 static void context_get_sink_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
141 pa_operation
*o
= userdata
;
146 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
151 if (command
!= PA_COMMAND_REPLY
) {
152 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
158 while (!pa_tagstruct_eof(t
)) {
164 const char *ap
= NULL
;
167 i
.proplist
= pa_proplist_new();
168 i
.base_volume
= PA_VOLUME_NORM
;
169 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
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 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
199 pa_proplist_free(i
.proplist
);
203 if (o
->context
->version
>= 16) {
205 i
.ports
= pa_xnew(pa_sink_port_info
*, i
.n_ports
+1);
206 i
.ports
[0] = pa_xnew(pa_sink_port_info
, i
.n_ports
);
208 for (j
= 0; j
< i
.n_ports
; j
++) {
209 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
210 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
211 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
213 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
214 pa_xfree(i
.ports
[0]);
216 pa_proplist_free(i
.proplist
);
220 i
.ports
[j
] = &i
.ports
[0][j
];
226 if (pa_tagstruct_gets(t
, &ap
) < 0) {
227 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
228 pa_xfree(i
.ports
[0]);
230 pa_proplist_free(i
.proplist
);
235 for (j
= 0; j
< i
.n_ports
; j
++)
236 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
237 i
.active_port
= i
.ports
[j
];
244 i
.flags
= (pa_sink_flags_t
) flags
;
245 i
.state
= (pa_sink_state_t
) state
;
248 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
249 cb(o
->context
, &i
, 0, o
->userdata
);
253 pa_xfree(i
.ports
[0]);
256 pa_proplist_free(i
.proplist
);
261 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
262 cb(o
->context
, NULL
, eol
, o
->userdata
);
266 pa_operation_done(o
);
267 pa_operation_unref(o
);
270 pa_operation
* pa_context_get_sink_info_list(pa_context
*c
, pa_sink_info_cb_t cb
, void *userdata
) {
271 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SINK_INFO_LIST
, context_get_sink_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
274 pa_operation
* pa_context_get_sink_info_by_index(pa_context
*c
, uint32_t idx
, pa_sink_info_cb_t cb
, void *userdata
) {
280 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
283 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
284 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
286 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
288 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
289 pa_tagstruct_putu32(t
, idx
);
290 pa_tagstruct_puts(t
, NULL
);
291 pa_pstream_send_tagstruct(c
->pstream
, t
);
292 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
);
297 pa_operation
* pa_context_get_sink_info_by_name(pa_context
*c
, const char *name
, pa_sink_info_cb_t cb
, void *userdata
) {
303 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
306 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
307 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
308 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
310 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
312 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
313 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
314 pa_tagstruct_puts(t
, name
);
315 pa_pstream_send_tagstruct(c
->pstream
, t
);
316 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
);
321 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
) {
327 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
329 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
330 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
331 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
332 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
334 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
336 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
337 pa_tagstruct_putu32(t
, idx
);
338 pa_tagstruct_puts(t
, NULL
);
339 pa_tagstruct_puts(t
, port
);
340 pa_pstream_send_tagstruct(c
->pstream
, t
);
341 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
);
346 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
) {
352 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
354 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
355 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
356 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
357 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
359 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
361 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
362 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
363 pa_tagstruct_puts(t
, name
);
364 pa_tagstruct_puts(t
, port
);
365 pa_pstream_send_tagstruct(c
->pstream
, t
);
366 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
);
371 /*** Source info ***/
373 static void context_get_source_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
374 pa_operation
*o
= userdata
;
379 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
384 if (command
!= PA_COMMAND_REPLY
) {
385 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
391 while (!pa_tagstruct_eof(t
)) {
400 i
.proplist
= pa_proplist_new();
401 i
.base_volume
= PA_VOLUME_NORM
;
402 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
404 state
= PA_SOURCE_INVALID_STATE
;
405 i
.card
= PA_INVALID_INDEX
;
407 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
408 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
409 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
410 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
411 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
412 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
413 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
414 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
415 pa_tagstruct_getu32(t
, &i
.monitor_of_sink
) < 0 ||
416 pa_tagstruct_gets(t
, &i
.monitor_of_sink_name
) < 0 ||
417 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
418 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
419 pa_tagstruct_getu32(t
, &flags
) < 0 ||
420 (o
->context
->version
>= 13 &&
421 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
422 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
423 (o
->context
->version
>= 15 &&
424 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
425 pa_tagstruct_getu32(t
, &state
) < 0 ||
426 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
427 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
428 (o
->context
->version
>= 16 &&
429 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
431 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
432 pa_proplist_free(i
.proplist
);
436 if (o
->context
->version
>= 16) {
438 i
.ports
= pa_xnew(pa_source_port_info
*, i
.n_ports
+1);
439 i
.ports
[0] = pa_xnew(pa_source_port_info
, i
.n_ports
);
441 for (j
= 0; j
< i
.n_ports
; j
++) {
442 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
443 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
444 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
446 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
447 pa_xfree(i
.ports
[0]);
449 pa_proplist_free(i
.proplist
);
453 i
.ports
[j
] = &i
.ports
[0][j
];
459 if (pa_tagstruct_gets(t
, &ap
) < 0) {
460 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
461 pa_xfree(i
.ports
[0]);
463 pa_proplist_free(i
.proplist
);
468 for (j
= 0; j
< i
.n_ports
; j
++)
469 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
470 i
.active_port
= i
.ports
[j
];
477 i
.flags
= (pa_source_flags_t
) flags
;
478 i
.state
= (pa_source_state_t
) state
;
481 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
482 cb(o
->context
, &i
, 0, o
->userdata
);
486 pa_xfree(i
.ports
[0]);
489 pa_proplist_free(i
.proplist
);
494 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
495 cb(o
->context
, NULL
, eol
, o
->userdata
);
499 pa_operation_done(o
);
500 pa_operation_unref(o
);
503 pa_operation
* pa_context_get_source_info_list(pa_context
*c
, pa_source_info_cb_t cb
, void *userdata
) {
504 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SOURCE_INFO_LIST
, context_get_source_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
507 pa_operation
* pa_context_get_source_info_by_index(pa_context
*c
, uint32_t idx
, pa_source_info_cb_t cb
, void *userdata
) {
513 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
516 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
517 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
519 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
521 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
522 pa_tagstruct_putu32(t
, idx
);
523 pa_tagstruct_puts(t
, NULL
);
524 pa_pstream_send_tagstruct(c
->pstream
, t
);
525 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
);
530 pa_operation
* pa_context_get_source_info_by_name(pa_context
*c
, const char *name
, pa_source_info_cb_t cb
, void *userdata
) {
536 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
539 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
540 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
541 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
543 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
545 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
546 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
547 pa_tagstruct_puts(t
, name
);
548 pa_pstream_send_tagstruct(c
->pstream
, t
);
549 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
);
554 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
) {
560 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
562 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
563 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
564 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
565 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
567 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
569 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
570 pa_tagstruct_putu32(t
, idx
);
571 pa_tagstruct_puts(t
, NULL
);
572 pa_tagstruct_puts(t
, port
);
573 pa_pstream_send_tagstruct(c
->pstream
, t
);
574 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
);
579 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
) {
585 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
587 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
588 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
589 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
590 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
592 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
594 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
595 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
596 pa_tagstruct_puts(t
, name
);
597 pa_tagstruct_puts(t
, port
);
598 pa_pstream_send_tagstruct(c
->pstream
, t
);
599 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
);
604 /*** Client info ***/
606 static void context_get_client_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
607 pa_operation
*o
= userdata
;
612 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
617 if (command
!= PA_COMMAND_REPLY
) {
618 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
624 while (!pa_tagstruct_eof(t
)) {
628 i
.proplist
= pa_proplist_new();
630 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
631 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
632 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
633 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
634 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
636 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
637 pa_proplist_free(i
.proplist
);
642 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
643 cb(o
->context
, &i
, 0, o
->userdata
);
646 pa_proplist_free(i
.proplist
);
651 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
652 cb(o
->context
, NULL
, eol
, o
->userdata
);
656 pa_operation_done(o
);
657 pa_operation_unref(o
);
660 pa_operation
* pa_context_get_client_info(pa_context
*c
, uint32_t idx
, pa_client_info_cb_t cb
, void *userdata
) {
666 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
669 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
670 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
671 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
673 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
675 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CLIENT_INFO
, &tag
);
676 pa_tagstruct_putu32(t
, idx
);
677 pa_pstream_send_tagstruct(c
->pstream
, t
);
678 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
);
683 pa_operation
* pa_context_get_client_info_list(pa_context
*c
, pa_client_info_cb_t cb
, void *userdata
) {
684 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CLIENT_INFO_LIST
, context_get_client_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
689 static void context_get_card_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
690 pa_operation
*o
= userdata
;
695 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
700 if (command
!= PA_COMMAND_REPLY
) {
701 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
707 while (!pa_tagstruct_eof(t
)) {
714 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
715 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
716 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
717 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
718 pa_tagstruct_getu32(t
, &i
.n_profiles
) < 0) {
720 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
724 if (i
.n_profiles
> 0) {
725 i
.profiles
= pa_xnew0(pa_card_profile_info
, i
.n_profiles
+1);
727 for (j
= 0; j
< i
.n_profiles
; j
++) {
729 if (pa_tagstruct_gets(t
, &i
.profiles
[j
].name
) < 0 ||
730 pa_tagstruct_gets(t
, &i
.profiles
[j
].description
) < 0 ||
731 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sinks
) < 0 ||
732 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sources
) < 0 ||
733 pa_tagstruct_getu32(t
, &i
.profiles
[j
].priority
) < 0) {
735 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
736 pa_xfree(i
.profiles
);
741 /* Terminate with an extra NULL entry, just to make sure */
742 i
.profiles
[j
].name
= NULL
;
743 i
.profiles
[j
].description
= NULL
;
746 i
.proplist
= pa_proplist_new();
748 if (pa_tagstruct_gets(t
, &ap
) < 0 ||
749 pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) {
751 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
752 pa_xfree(i
.profiles
);
753 pa_proplist_free(i
.proplist
);
758 for (j
= 0; j
< i
.n_profiles
; j
++)
759 if (pa_streq(i
.profiles
[j
].name
, ap
)) {
760 i
.active_profile
= &i
.profiles
[j
];
766 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
767 cb(o
->context
, &i
, 0, o
->userdata
);
770 pa_proplist_free(i
.proplist
);
771 pa_xfree(i
.profiles
);
776 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
777 cb(o
->context
, NULL
, eol
, o
->userdata
);
781 pa_operation_done(o
);
782 pa_operation_unref(o
);
785 pa_operation
* pa_context_get_card_info_by_index(pa_context
*c
, uint32_t idx
, pa_card_info_cb_t cb
, void *userdata
) {
791 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
794 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
795 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
796 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
797 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
799 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
801 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
802 pa_tagstruct_putu32(t
, idx
);
803 pa_tagstruct_puts(t
, NULL
);
804 pa_pstream_send_tagstruct(c
->pstream
, t
);
805 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
);
810 pa_operation
* pa_context_get_card_info_by_name(pa_context
*c
, const char*name
, pa_card_info_cb_t cb
, void *userdata
) {
816 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
819 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
820 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
821 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
822 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
824 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
826 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
827 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
828 pa_tagstruct_puts(t
, name
);
829 pa_pstream_send_tagstruct(c
->pstream
, t
);
830 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
);
835 pa_operation
* pa_context_get_card_info_list(pa_context
*c
, pa_card_info_cb_t cb
, void *userdata
) {
836 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
838 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
841 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
) {
847 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
849 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
850 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
851 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
852 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
854 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
856 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
857 pa_tagstruct_putu32(t
, idx
);
858 pa_tagstruct_puts(t
, NULL
);
859 pa_tagstruct_puts(t
, profile
);
860 pa_pstream_send_tagstruct(c
->pstream
, t
);
861 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
);
866 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
) {
872 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
874 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
875 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
876 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
877 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
879 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
881 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
882 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
883 pa_tagstruct_puts(t
, name
);
884 pa_tagstruct_puts(t
, profile
);
885 pa_pstream_send_tagstruct(c
->pstream
, t
);
886 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
);
891 /*** Module info ***/
893 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
894 pa_operation
*o
= userdata
;
899 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
904 if (command
!= PA_COMMAND_REPLY
) {
905 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
911 while (!pa_tagstruct_eof(t
)) {
913 pa_bool_t auto_unload
= FALSE
;
916 i
.proplist
= pa_proplist_new();
918 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
919 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
920 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
921 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
922 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
923 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
924 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
928 i
.auto_unload
= (int) auto_unload
;
931 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
932 cb(o
->context
, &i
, 0, o
->userdata
);
935 pa_proplist_free(i
.proplist
);
940 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
941 cb(o
->context
, NULL
, eol
, o
->userdata
);
945 pa_operation_done(o
);
946 pa_operation_unref(o
);
949 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
955 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
958 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
959 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
960 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
962 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
964 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
965 pa_tagstruct_putu32(t
, idx
);
966 pa_pstream_send_tagstruct(c
->pstream
, t
);
967 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
);
972 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
973 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
976 /*** Sink input info ***/
978 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
979 pa_operation
*o
= userdata
;
984 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
989 if (command
!= PA_COMMAND_REPLY
) {
990 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
996 while (!pa_tagstruct_eof(t
)) {
997 pa_sink_input_info i
;
998 pa_bool_t mute
= FALSE
, corked
= FALSE
, has_volume
= FALSE
, read_only_volume
= FALSE
;
1001 i
.proplist
= pa_proplist_new();
1003 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1004 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1005 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1006 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1007 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
1008 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1009 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1010 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1011 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1012 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1013 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1014 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1015 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1016 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1017 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0) ||
1018 (o
->context
->version
>= 20 && (pa_tagstruct_get_boolean(t
, &has_volume
) < 0 ||
1019 pa_tagstruct_get_boolean(t
, &read_only_volume
) < 0))) {
1021 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1022 pa_proplist_free(i
.proplist
);
1026 i
.mute
= (int) mute
;
1027 i
.corked
= (int) corked
;
1028 i
.has_volume
= (int) has_volume
;
1029 i
.read_only_volume
= (int) read_only_volume
;
1032 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1033 cb(o
->context
, &i
, 0, o
->userdata
);
1036 pa_proplist_free(i
.proplist
);
1041 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1042 cb(o
->context
, NULL
, eol
, o
->userdata
);
1046 pa_operation_done(o
);
1047 pa_operation_unref(o
);
1050 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1056 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1059 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1060 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1061 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1063 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1065 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1066 pa_tagstruct_putu32(t
, idx
);
1067 pa_pstream_send_tagstruct(c
->pstream
, t
);
1068 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
);
1073 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
) {
1074 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
);
1077 /*** Source output info ***/
1079 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1080 pa_operation
*o
= userdata
;
1085 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1090 if (command
!= PA_COMMAND_REPLY
) {
1091 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1097 while (!pa_tagstruct_eof(t
)) {
1098 pa_source_output_info i
;
1099 pa_bool_t corked
= FALSE
;
1102 i
.proplist
= pa_proplist_new();
1104 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1105 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1106 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1107 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1108 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1109 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1110 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1111 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1112 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1113 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1114 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1115 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1116 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0)) {
1118 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1119 pa_proplist_free(i
.proplist
);
1123 i
.corked
= (int) corked
;
1126 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1127 cb(o
->context
, &i
, 0, o
->userdata
);
1130 pa_proplist_free(i
.proplist
);
1135 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1136 cb(o
->context
, NULL
, eol
, o
->userdata
);
1140 pa_operation_done(o
);
1141 pa_operation_unref(o
);
1144 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1150 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1153 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1154 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1155 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1157 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1159 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1160 pa_tagstruct_putu32(t
, idx
);
1161 pa_pstream_send_tagstruct(c
->pstream
, t
);
1162 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
);
1167 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1168 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
);
1171 /*** Volume manipulation ***/
1173 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
) {
1179 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1182 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1183 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1184 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1186 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1188 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1189 pa_tagstruct_putu32(t
, idx
);
1190 pa_tagstruct_puts(t
, NULL
);
1191 pa_tagstruct_put_cvolume(t
, volume
);
1192 pa_pstream_send_tagstruct(c
->pstream
, t
);
1193 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
);
1198 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
) {
1204 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1208 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1209 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1210 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1211 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1213 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1215 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1216 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1217 pa_tagstruct_puts(t
, name
);
1218 pa_tagstruct_put_cvolume(t
, volume
);
1219 pa_pstream_send_tagstruct(c
->pstream
, t
);
1220 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
);
1225 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
) {
1231 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1233 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1234 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1236 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1238 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1239 pa_tagstruct_putu32(t
, idx
);
1240 pa_tagstruct_puts(t
, NULL
);
1241 pa_tagstruct_put_boolean(t
, mute
);
1242 pa_pstream_send_tagstruct(c
->pstream
, t
);
1243 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
);
1248 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
) {
1254 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1257 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1258 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1259 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1261 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1263 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1264 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1265 pa_tagstruct_puts(t
, name
);
1266 pa_tagstruct_put_boolean(t
, mute
);
1267 pa_pstream_send_tagstruct(c
->pstream
, t
);
1268 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
);
1273 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
) {
1279 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1282 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1283 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1284 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1285 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1287 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1289 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1290 pa_tagstruct_putu32(t
, idx
);
1291 pa_tagstruct_put_cvolume(t
, volume
);
1292 pa_pstream_send_tagstruct(c
->pstream
, t
);
1293 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 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1304 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1306 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1307 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1308 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1309 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1311 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1313 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1314 pa_tagstruct_putu32(t
, idx
);
1315 pa_tagstruct_put_boolean(t
, mute
);
1316 pa_pstream_send_tagstruct(c
->pstream
, t
);
1317 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
);
1322 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
) {
1328 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1331 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1332 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1333 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1335 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1337 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1338 pa_tagstruct_putu32(t
, idx
);
1339 pa_tagstruct_puts(t
, NULL
);
1340 pa_tagstruct_put_cvolume(t
, volume
);
1341 pa_pstream_send_tagstruct(c
->pstream
, t
);
1342 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
);
1347 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
) {
1353 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1357 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1358 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1359 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1360 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1362 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1364 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1365 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1366 pa_tagstruct_puts(t
, name
);
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
);
1374 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
) {
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
);
1385 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1387 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1388 pa_tagstruct_putu32(t
, idx
);
1389 pa_tagstruct_puts(t
, NULL
);
1390 pa_tagstruct_put_boolean(t
, mute
);
1391 pa_pstream_send_tagstruct(c
->pstream
, t
);
1392 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
);
1397 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
) {
1403 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1406 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1407 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1408 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1410 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1412 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1413 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1414 pa_tagstruct_puts(t
, name
);
1415 pa_tagstruct_put_boolean(t
, mute
);
1416 pa_pstream_send_tagstruct(c
->pstream
, t
);
1417 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
);
1422 /** Sample Cache **/
1424 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1425 pa_operation
*o
= userdata
;
1430 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1435 if (command
!= PA_COMMAND_REPLY
) {
1436 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1442 while (!pa_tagstruct_eof(t
)) {
1444 pa_bool_t lazy
= FALSE
;
1447 i
.proplist
= pa_proplist_new();
1449 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1450 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1451 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1452 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1453 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1454 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1455 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1456 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1457 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1458 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1460 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1464 i
.lazy
= (int) lazy
;
1467 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1468 cb(o
->context
, &i
, 0, o
->userdata
);
1471 pa_proplist_free(i
.proplist
);
1476 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1477 cb(o
->context
, NULL
, eol
, o
->userdata
);
1481 pa_operation_done(o
);
1482 pa_operation_unref(o
);
1485 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1491 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1494 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1495 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1496 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1498 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1500 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1501 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1502 pa_tagstruct_puts(t
, name
);
1503 pa_pstream_send_tagstruct(c
->pstream
, t
);
1504 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
);
1509 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1515 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1518 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1519 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1520 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1522 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1524 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1525 pa_tagstruct_putu32(t
, idx
);
1526 pa_tagstruct_puts(t
, NULL
);
1527 pa_pstream_send_tagstruct(c
->pstream
, t
);
1528 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
);
1533 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1534 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1537 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1543 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1545 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1546 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1547 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1549 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1551 t
= pa_tagstruct_command(c
, command
, &tag
);
1552 pa_tagstruct_putu32(t
, idx
);
1553 pa_pstream_send_tagstruct(c
->pstream
, t
);
1554 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
);
1559 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1560 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1563 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1564 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1567 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1568 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1571 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1572 pa_operation
*o
= userdata
;
1577 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1582 if (command
!= PA_COMMAND_REPLY
) {
1583 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1586 idx
= PA_INVALID_INDEX
;
1587 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1588 !pa_tagstruct_eof(t
)) {
1589 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1594 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1595 cb(o
->context
, idx
, o
->userdata
);
1600 pa_operation_done(o
);
1601 pa_operation_unref(o
);
1604 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1610 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1612 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1613 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1614 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1616 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1618 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1619 pa_tagstruct_puts(t
, name
);
1620 pa_tagstruct_puts(t
, argument
);
1621 pa_pstream_send_tagstruct(c
->pstream
, t
);
1622 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1627 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1628 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1631 /*** Autoload stuff ***/
1633 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1635 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
) {
1638 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1640 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1643 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1645 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1647 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1649 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1652 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1654 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1656 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1658 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1661 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1663 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
) {
1665 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1667 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1670 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1672 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
) {
1674 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1676 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1679 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1681 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1683 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1685 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1688 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
) {
1694 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1696 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1697 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1698 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1699 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1700 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1702 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1704 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1705 pa_tagstruct_putu32(t
, idx
);
1706 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1707 pa_tagstruct_puts(t
, sink_name
);
1708 pa_pstream_send_tagstruct(c
->pstream
, t
);
1709 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
);
1714 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
) {
1720 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1722 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1723 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1724 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1725 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1726 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1728 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1730 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1731 pa_tagstruct_putu32(t
, idx
);
1732 pa_tagstruct_putu32(t
, sink_idx
);
1733 pa_tagstruct_puts(t
, NULL
);
1734 pa_pstream_send_tagstruct(c
->pstream
, t
);
1735 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
);
1740 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
) {
1746 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1748 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1749 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1750 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1751 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1752 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1754 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1756 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1757 pa_tagstruct_putu32(t
, idx
);
1758 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1759 pa_tagstruct_puts(t
, source_name
);
1760 pa_pstream_send_tagstruct(c
->pstream
, t
);
1761 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
);
1766 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
) {
1772 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1774 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1775 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1776 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1777 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1778 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1780 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1782 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1783 pa_tagstruct_putu32(t
, idx
);
1784 pa_tagstruct_putu32(t
, source_idx
);
1785 pa_tagstruct_puts(t
, NULL
);
1786 pa_pstream_send_tagstruct(c
->pstream
, t
);
1787 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
);
1792 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
) {
1798 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1800 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1801 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1802 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1803 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1805 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1807 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1808 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1809 pa_tagstruct_puts(t
, sink_name
);
1810 pa_tagstruct_put_boolean(t
, suspend
);
1811 pa_pstream_send_tagstruct(c
->pstream
, t
);
1812 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
);
1817 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1823 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1825 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1826 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1827 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1829 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1831 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1832 pa_tagstruct_putu32(t
, idx
);
1833 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1834 pa_tagstruct_put_boolean(t
, suspend
);
1835 pa_pstream_send_tagstruct(c
->pstream
, t
);
1836 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
);
1841 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
) {
1847 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1849 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1850 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1851 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1852 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1854 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1856 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1857 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1858 pa_tagstruct_puts(t
, source_name
);
1859 pa_tagstruct_put_boolean(t
, suspend
);
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
);
1866 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
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
>= 11, PA_ERR_NOTSUPPORTED
);
1878 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1880 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1881 pa_tagstruct_putu32(t
, idx
);
1882 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1883 pa_tagstruct_put_boolean(t
, suspend
);
1884 pa_pstream_send_tagstruct(c
->pstream
, t
);
1885 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
);