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
];
243 if (o
->context
->version
>= 21) {
246 if (pa_tagstruct_getu8(t
, &i
.n_formats
)) {
247 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
248 pa_proplist_free(i
.proplist
);
252 pa_assert(i
.n_formats
> 0);
253 i
.formats
= pa_xnew0(pa_format_info
*, i
.n_formats
);
255 for (j
= 0; j
< i
.n_formats
; j
++) {
256 i
.formats
[j
] = pa_format_info_new();
257 if (pa_tagstruct_get_format_info(t
, i
.formats
[j
]) < 0) {
259 pa_format_info_free(i
.formats
[j
]);
263 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
264 pa_proplist_free(i
.proplist
);
271 i
.flags
= (pa_sink_flags_t
) flags
;
272 i
.state
= (pa_sink_state_t
) state
;
275 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
276 cb(o
->context
, &i
, 0, o
->userdata
);
280 pa_xfree(i
.ports
[0]);
285 for (j
= 0; j
< i
.n_formats
; j
++)
286 pa_format_info_free(i
.formats
[j
]);
290 pa_proplist_free(i
.proplist
);
295 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
296 cb(o
->context
, NULL
, eol
, o
->userdata
);
300 pa_operation_done(o
);
301 pa_operation_unref(o
);
304 pa_operation
* pa_context_get_sink_info_list(pa_context
*c
, pa_sink_info_cb_t cb
, void *userdata
) {
305 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SINK_INFO_LIST
, context_get_sink_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
308 pa_operation
* pa_context_get_sink_info_by_index(pa_context
*c
, uint32_t idx
, pa_sink_info_cb_t cb
, void *userdata
) {
314 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
317 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
318 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
320 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
322 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
323 pa_tagstruct_putu32(t
, idx
);
324 pa_tagstruct_puts(t
, NULL
);
325 pa_pstream_send_tagstruct(c
->pstream
, t
);
326 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
);
331 pa_operation
* pa_context_get_sink_info_by_name(pa_context
*c
, const char *name
, pa_sink_info_cb_t cb
, void *userdata
) {
337 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
340 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
341 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
342 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
344 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
346 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
347 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
348 pa_tagstruct_puts(t
, name
);
349 pa_pstream_send_tagstruct(c
->pstream
, t
);
350 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
);
355 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
) {
361 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
363 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
364 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
365 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
366 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
368 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
370 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
371 pa_tagstruct_putu32(t
, idx
);
372 pa_tagstruct_puts(t
, NULL
);
373 pa_tagstruct_puts(t
, port
);
374 pa_pstream_send_tagstruct(c
->pstream
, t
);
375 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
);
380 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
) {
386 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
388 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
389 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
390 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
391 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
393 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
395 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
396 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
397 pa_tagstruct_puts(t
, name
);
398 pa_tagstruct_puts(t
, port
);
399 pa_pstream_send_tagstruct(c
->pstream
, t
);
400 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
);
405 /*** Source info ***/
407 static void context_get_source_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
408 pa_operation
*o
= userdata
;
413 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
418 if (command
!= PA_COMMAND_REPLY
) {
419 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
425 while (!pa_tagstruct_eof(t
)) {
434 i
.proplist
= pa_proplist_new();
435 i
.base_volume
= PA_VOLUME_NORM
;
436 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
438 state
= PA_SOURCE_INVALID_STATE
;
439 i
.card
= PA_INVALID_INDEX
;
441 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
442 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
443 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
444 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
445 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
446 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
447 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
448 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
449 pa_tagstruct_getu32(t
, &i
.monitor_of_sink
) < 0 ||
450 pa_tagstruct_gets(t
, &i
.monitor_of_sink_name
) < 0 ||
451 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
452 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
453 pa_tagstruct_getu32(t
, &flags
) < 0 ||
454 (o
->context
->version
>= 13 &&
455 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
456 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
457 (o
->context
->version
>= 15 &&
458 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
459 pa_tagstruct_getu32(t
, &state
) < 0 ||
460 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
461 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
462 (o
->context
->version
>= 16 &&
463 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
465 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
466 pa_proplist_free(i
.proplist
);
470 if (o
->context
->version
>= 16) {
472 i
.ports
= pa_xnew(pa_source_port_info
*, i
.n_ports
+1);
473 i
.ports
[0] = pa_xnew(pa_source_port_info
, i
.n_ports
);
475 for (j
= 0; j
< i
.n_ports
; j
++) {
476 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
477 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
478 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
480 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
481 pa_xfree(i
.ports
[0]);
483 pa_proplist_free(i
.proplist
);
487 i
.ports
[j
] = &i
.ports
[0][j
];
493 if (pa_tagstruct_gets(t
, &ap
) < 0) {
494 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
495 pa_xfree(i
.ports
[0]);
497 pa_proplist_free(i
.proplist
);
502 for (j
= 0; j
< i
.n_ports
; j
++)
503 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
504 i
.active_port
= i
.ports
[j
];
511 i
.flags
= (pa_source_flags_t
) flags
;
512 i
.state
= (pa_source_state_t
) state
;
515 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
516 cb(o
->context
, &i
, 0, o
->userdata
);
520 pa_xfree(i
.ports
[0]);
523 pa_proplist_free(i
.proplist
);
528 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
529 cb(o
->context
, NULL
, eol
, o
->userdata
);
533 pa_operation_done(o
);
534 pa_operation_unref(o
);
537 pa_operation
* pa_context_get_source_info_list(pa_context
*c
, pa_source_info_cb_t cb
, void *userdata
) {
538 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SOURCE_INFO_LIST
, context_get_source_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
541 pa_operation
* pa_context_get_source_info_by_index(pa_context
*c
, uint32_t idx
, pa_source_info_cb_t cb
, void *userdata
) {
547 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
550 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
551 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
553 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
555 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
556 pa_tagstruct_putu32(t
, idx
);
557 pa_tagstruct_puts(t
, NULL
);
558 pa_pstream_send_tagstruct(c
->pstream
, t
);
559 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
);
564 pa_operation
* pa_context_get_source_info_by_name(pa_context
*c
, const char *name
, pa_source_info_cb_t cb
, void *userdata
) {
570 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
573 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
574 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
575 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
577 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
579 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
580 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
581 pa_tagstruct_puts(t
, name
);
582 pa_pstream_send_tagstruct(c
->pstream
, t
);
583 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_get_source_info_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
588 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
) {
594 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
596 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
597 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
598 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
599 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
601 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
603 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
604 pa_tagstruct_putu32(t
, idx
);
605 pa_tagstruct_puts(t
, NULL
);
606 pa_tagstruct_puts(t
, port
);
607 pa_pstream_send_tagstruct(c
->pstream
, t
);
608 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
);
613 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
) {
619 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
621 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
622 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
623 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
624 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
626 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
628 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
629 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
630 pa_tagstruct_puts(t
, name
);
631 pa_tagstruct_puts(t
, port
);
632 pa_pstream_send_tagstruct(c
->pstream
, t
);
633 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
);
638 /*** Client info ***/
640 static void context_get_client_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
641 pa_operation
*o
= userdata
;
646 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
651 if (command
!= PA_COMMAND_REPLY
) {
652 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
658 while (!pa_tagstruct_eof(t
)) {
662 i
.proplist
= pa_proplist_new();
664 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
665 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
666 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
667 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
668 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
670 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
671 pa_proplist_free(i
.proplist
);
676 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
677 cb(o
->context
, &i
, 0, o
->userdata
);
680 pa_proplist_free(i
.proplist
);
685 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
686 cb(o
->context
, NULL
, eol
, o
->userdata
);
690 pa_operation_done(o
);
691 pa_operation_unref(o
);
694 pa_operation
* pa_context_get_client_info(pa_context
*c
, uint32_t idx
, pa_client_info_cb_t cb
, void *userdata
) {
700 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
703 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
704 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
705 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
707 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
709 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CLIENT_INFO
, &tag
);
710 pa_tagstruct_putu32(t
, idx
);
711 pa_pstream_send_tagstruct(c
->pstream
, t
);
712 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
);
717 pa_operation
* pa_context_get_client_info_list(pa_context
*c
, pa_client_info_cb_t cb
, void *userdata
) {
718 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CLIENT_INFO_LIST
, context_get_client_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
723 static void context_get_card_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
724 pa_operation
*o
= userdata
;
729 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
734 if (command
!= PA_COMMAND_REPLY
) {
735 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
741 while (!pa_tagstruct_eof(t
)) {
748 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
749 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
750 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
751 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
752 pa_tagstruct_getu32(t
, &i
.n_profiles
) < 0) {
754 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
758 if (i
.n_profiles
> 0) {
759 i
.profiles
= pa_xnew0(pa_card_profile_info
, i
.n_profiles
+1);
761 for (j
= 0; j
< i
.n_profiles
; j
++) {
763 if (pa_tagstruct_gets(t
, &i
.profiles
[j
].name
) < 0 ||
764 pa_tagstruct_gets(t
, &i
.profiles
[j
].description
) < 0 ||
765 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sinks
) < 0 ||
766 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sources
) < 0 ||
767 pa_tagstruct_getu32(t
, &i
.profiles
[j
].priority
) < 0) {
769 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
770 pa_xfree(i
.profiles
);
775 /* Terminate with an extra NULL entry, just to make sure */
776 i
.profiles
[j
].name
= NULL
;
777 i
.profiles
[j
].description
= NULL
;
780 i
.proplist
= pa_proplist_new();
782 if (pa_tagstruct_gets(t
, &ap
) < 0 ||
783 pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) {
785 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
786 pa_xfree(i
.profiles
);
787 pa_proplist_free(i
.proplist
);
792 for (j
= 0; j
< i
.n_profiles
; j
++)
793 if (pa_streq(i
.profiles
[j
].name
, ap
)) {
794 i
.active_profile
= &i
.profiles
[j
];
800 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
801 cb(o
->context
, &i
, 0, o
->userdata
);
804 pa_proplist_free(i
.proplist
);
805 pa_xfree(i
.profiles
);
810 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
811 cb(o
->context
, NULL
, eol
, o
->userdata
);
815 pa_operation_done(o
);
816 pa_operation_unref(o
);
819 pa_operation
* pa_context_get_card_info_by_index(pa_context
*c
, uint32_t idx
, pa_card_info_cb_t cb
, void *userdata
) {
825 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
828 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
829 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
830 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
831 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
833 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
835 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
836 pa_tagstruct_putu32(t
, idx
);
837 pa_tagstruct_puts(t
, NULL
);
838 pa_pstream_send_tagstruct(c
->pstream
, t
);
839 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
);
844 pa_operation
* pa_context_get_card_info_by_name(pa_context
*c
, const char*name
, pa_card_info_cb_t cb
, void *userdata
) {
850 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
853 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
854 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
855 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
856 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
858 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
860 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
861 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
862 pa_tagstruct_puts(t
, name
);
863 pa_pstream_send_tagstruct(c
->pstream
, t
);
864 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
);
869 pa_operation
* pa_context_get_card_info_list(pa_context
*c
, pa_card_info_cb_t cb
, void *userdata
) {
870 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
872 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
875 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
) {
881 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
883 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
884 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
885 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
886 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
888 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
890 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
891 pa_tagstruct_putu32(t
, idx
);
892 pa_tagstruct_puts(t
, NULL
);
893 pa_tagstruct_puts(t
, profile
);
894 pa_pstream_send_tagstruct(c
->pstream
, t
);
895 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
);
900 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
) {
906 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
908 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
909 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
910 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
911 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
913 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
915 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
916 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
917 pa_tagstruct_puts(t
, name
);
918 pa_tagstruct_puts(t
, profile
);
919 pa_pstream_send_tagstruct(c
->pstream
, t
);
920 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
);
925 /*** Module info ***/
927 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
928 pa_operation
*o
= userdata
;
933 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
938 if (command
!= PA_COMMAND_REPLY
) {
939 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
945 while (!pa_tagstruct_eof(t
)) {
947 pa_bool_t auto_unload
= FALSE
;
950 i
.proplist
= pa_proplist_new();
952 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
953 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
954 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
955 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
956 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
957 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
958 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
962 i
.auto_unload
= (int) auto_unload
;
965 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
966 cb(o
->context
, &i
, 0, o
->userdata
);
969 pa_proplist_free(i
.proplist
);
974 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
975 cb(o
->context
, NULL
, eol
, o
->userdata
);
979 pa_operation_done(o
);
980 pa_operation_unref(o
);
983 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
989 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
992 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
993 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
994 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
996 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
998 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
999 pa_tagstruct_putu32(t
, idx
);
1000 pa_pstream_send_tagstruct(c
->pstream
, t
);
1001 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
);
1006 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
1007 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1010 /*** Sink input info ***/
1012 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1013 pa_operation
*o
= userdata
;
1018 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1023 if (command
!= PA_COMMAND_REPLY
) {
1024 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1030 while (!pa_tagstruct_eof(t
)) {
1031 pa_sink_input_info i
;
1032 pa_bool_t mute
= FALSE
, corked
= FALSE
, has_volume
= FALSE
, volume_writable
= TRUE
;
1035 i
.proplist
= pa_proplist_new();
1036 i
.format
= pa_format_info_new();
1038 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1039 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1040 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1041 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1042 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
1043 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1044 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1045 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1046 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1047 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1048 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1049 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1050 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1051 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1052 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0) ||
1053 (o
->context
->version
>= 20 && (pa_tagstruct_get_boolean(t
, &has_volume
) < 0 ||
1054 pa_tagstruct_get_boolean(t
, &volume_writable
) < 0)) ||
1055 (o
->context
->version
>= 21 && pa_tagstruct_get_format_info(t
, i
.format
) < 0)) {
1057 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1058 pa_proplist_free(i
.proplist
);
1059 pa_format_info_free(i
.format
);
1063 i
.mute
= (int) mute
;
1064 i
.corked
= (int) corked
;
1065 i
.has_volume
= (int) has_volume
;
1066 i
.volume_writable
= (int) volume_writable
;
1069 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1070 cb(o
->context
, &i
, 0, o
->userdata
);
1073 pa_proplist_free(i
.proplist
);
1074 pa_format_info_free(i
.format
);
1079 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1080 cb(o
->context
, NULL
, eol
, o
->userdata
);
1084 pa_operation_done(o
);
1085 pa_operation_unref(o
);
1088 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1094 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1097 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1098 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1099 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1101 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1103 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1104 pa_tagstruct_putu32(t
, idx
);
1105 pa_pstream_send_tagstruct(c
->pstream
, t
);
1106 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
);
1111 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
) {
1112 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
);
1115 /*** Source output info ***/
1117 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1118 pa_operation
*o
= userdata
;
1123 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1128 if (command
!= PA_COMMAND_REPLY
) {
1129 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1135 while (!pa_tagstruct_eof(t
)) {
1136 pa_source_output_info i
;
1137 pa_bool_t corked
= FALSE
;
1140 i
.proplist
= pa_proplist_new();
1142 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1143 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1144 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1145 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1146 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1147 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1148 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1149 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1150 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1151 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1152 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1153 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1154 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0)) {
1156 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1157 pa_proplist_free(i
.proplist
);
1161 i
.corked
= (int) corked
;
1164 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1165 cb(o
->context
, &i
, 0, o
->userdata
);
1168 pa_proplist_free(i
.proplist
);
1173 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1174 cb(o
->context
, NULL
, eol
, o
->userdata
);
1178 pa_operation_done(o
);
1179 pa_operation_unref(o
);
1182 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1188 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1191 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1192 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1193 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1195 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1197 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1198 pa_tagstruct_putu32(t
, idx
);
1199 pa_pstream_send_tagstruct(c
->pstream
, t
);
1200 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
);
1205 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1206 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
);
1209 /*** Volume manipulation ***/
1211 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
) {
1217 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1220 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1221 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1222 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1224 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1226 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1227 pa_tagstruct_putu32(t
, idx
);
1228 pa_tagstruct_puts(t
, NULL
);
1229 pa_tagstruct_put_cvolume(t
, volume
);
1230 pa_pstream_send_tagstruct(c
->pstream
, t
);
1231 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
);
1236 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
) {
1242 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1246 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1247 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1248 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1249 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1251 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1253 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1254 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1255 pa_tagstruct_puts(t
, name
);
1256 pa_tagstruct_put_cvolume(t
, volume
);
1257 pa_pstream_send_tagstruct(c
->pstream
, t
);
1258 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
);
1263 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
) {
1269 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1271 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1272 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1274 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1276 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1277 pa_tagstruct_putu32(t
, idx
);
1278 pa_tagstruct_puts(t
, NULL
);
1279 pa_tagstruct_put_boolean(t
, mute
);
1280 pa_pstream_send_tagstruct(c
->pstream
, t
);
1281 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
);
1286 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
) {
1292 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1295 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1296 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1297 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1299 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1301 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1302 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1303 pa_tagstruct_puts(t
, name
);
1304 pa_tagstruct_put_boolean(t
, mute
);
1305 pa_pstream_send_tagstruct(c
->pstream
, t
);
1306 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
);
1311 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
) {
1317 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1320 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1321 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1322 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1323 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1325 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1327 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1328 pa_tagstruct_putu32(t
, idx
);
1329 pa_tagstruct_put_cvolume(t
, volume
);
1330 pa_pstream_send_tagstruct(c
->pstream
, t
);
1331 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
);
1336 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1342 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1344 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1345 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1346 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1347 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1349 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1351 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1352 pa_tagstruct_putu32(t
, idx
);
1353 pa_tagstruct_put_boolean(t
, mute
);
1354 pa_pstream_send_tagstruct(c
->pstream
, t
);
1355 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
);
1360 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
) {
1366 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1369 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1370 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1371 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1373 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1375 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1376 pa_tagstruct_putu32(t
, idx
);
1377 pa_tagstruct_puts(t
, NULL
);
1378 pa_tagstruct_put_cvolume(t
, volume
);
1379 pa_pstream_send_tagstruct(c
->pstream
, t
);
1380 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
);
1385 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
) {
1391 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1395 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1396 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1397 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1398 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1400 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1402 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1403 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1404 pa_tagstruct_puts(t
, name
);
1405 pa_tagstruct_put_cvolume(t
, volume
);
1406 pa_pstream_send_tagstruct(c
->pstream
, t
);
1407 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
);
1412 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
) {
1418 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1420 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1421 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1423 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1425 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1426 pa_tagstruct_putu32(t
, idx
);
1427 pa_tagstruct_puts(t
, NULL
);
1428 pa_tagstruct_put_boolean(t
, mute
);
1429 pa_pstream_send_tagstruct(c
->pstream
, t
);
1430 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
);
1435 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
) {
1441 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1444 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1445 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1446 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1448 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1450 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1451 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1452 pa_tagstruct_puts(t
, name
);
1453 pa_tagstruct_put_boolean(t
, mute
);
1454 pa_pstream_send_tagstruct(c
->pstream
, t
);
1455 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
);
1460 /** Sample Cache **/
1462 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1463 pa_operation
*o
= userdata
;
1468 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1473 if (command
!= PA_COMMAND_REPLY
) {
1474 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1480 while (!pa_tagstruct_eof(t
)) {
1482 pa_bool_t lazy
= FALSE
;
1485 i
.proplist
= pa_proplist_new();
1487 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1488 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1489 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1490 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1491 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1492 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1493 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1494 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1495 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1496 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1498 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1502 i
.lazy
= (int) lazy
;
1505 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1506 cb(o
->context
, &i
, 0, o
->userdata
);
1509 pa_proplist_free(i
.proplist
);
1514 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1515 cb(o
->context
, NULL
, eol
, o
->userdata
);
1519 pa_operation_done(o
);
1520 pa_operation_unref(o
);
1523 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1529 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1532 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1533 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1534 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1536 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1538 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1539 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1540 pa_tagstruct_puts(t
, name
);
1541 pa_pstream_send_tagstruct(c
->pstream
, t
);
1542 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
);
1547 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1553 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1556 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1557 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1558 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1560 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1562 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1563 pa_tagstruct_putu32(t
, idx
);
1564 pa_tagstruct_puts(t
, NULL
);
1565 pa_pstream_send_tagstruct(c
->pstream
, t
);
1566 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
);
1571 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1572 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1575 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1581 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1583 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1584 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1585 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1587 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1589 t
= pa_tagstruct_command(c
, command
, &tag
);
1590 pa_tagstruct_putu32(t
, idx
);
1591 pa_pstream_send_tagstruct(c
->pstream
, t
);
1592 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
);
1597 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1598 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1601 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1602 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1605 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1606 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1609 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1610 pa_operation
*o
= userdata
;
1615 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1620 if (command
!= PA_COMMAND_REPLY
) {
1621 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1624 idx
= PA_INVALID_INDEX
;
1625 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1626 !pa_tagstruct_eof(t
)) {
1627 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1632 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1633 cb(o
->context
, idx
, o
->userdata
);
1638 pa_operation_done(o
);
1639 pa_operation_unref(o
);
1642 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1648 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1650 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1651 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1652 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1654 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1656 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1657 pa_tagstruct_puts(t
, name
);
1658 pa_tagstruct_puts(t
, argument
);
1659 pa_pstream_send_tagstruct(c
->pstream
, t
);
1660 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1665 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1666 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1669 /*** Autoload stuff ***/
1671 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1673 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
) {
1676 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1678 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1681 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1683 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1685 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1687 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1690 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1692 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1694 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1696 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1699 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1701 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
) {
1703 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1705 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1708 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1710 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
) {
1712 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1714 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1717 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1719 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1721 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1723 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1726 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
) {
1732 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1734 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1735 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1736 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1737 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1738 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1740 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1742 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1743 pa_tagstruct_putu32(t
, idx
);
1744 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1745 pa_tagstruct_puts(t
, sink_name
);
1746 pa_pstream_send_tagstruct(c
->pstream
, t
);
1747 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
);
1752 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
) {
1758 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1760 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1761 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1762 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1763 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1764 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1766 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1768 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1769 pa_tagstruct_putu32(t
, idx
);
1770 pa_tagstruct_putu32(t
, sink_idx
);
1771 pa_tagstruct_puts(t
, NULL
);
1772 pa_pstream_send_tagstruct(c
->pstream
, t
);
1773 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
);
1778 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
) {
1784 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1786 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1787 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1788 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1789 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1790 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1792 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1794 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1795 pa_tagstruct_putu32(t
, idx
);
1796 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1797 pa_tagstruct_puts(t
, source_name
);
1798 pa_pstream_send_tagstruct(c
->pstream
, t
);
1799 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
);
1804 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
) {
1810 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1812 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1813 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1814 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1815 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1816 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1818 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1820 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1821 pa_tagstruct_putu32(t
, idx
);
1822 pa_tagstruct_putu32(t
, source_idx
);
1823 pa_tagstruct_puts(t
, NULL
);
1824 pa_pstream_send_tagstruct(c
->pstream
, t
);
1825 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
);
1830 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
) {
1836 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1838 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1839 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1840 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1841 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1843 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1845 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1846 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1847 pa_tagstruct_puts(t
, sink_name
);
1848 pa_tagstruct_put_boolean(t
, suspend
);
1849 pa_pstream_send_tagstruct(c
->pstream
, t
);
1850 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
);
1855 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1861 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1863 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1864 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1865 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1867 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1869 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1870 pa_tagstruct_putu32(t
, idx
);
1871 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1872 pa_tagstruct_put_boolean(t
, suspend
);
1873 pa_pstream_send_tagstruct(c
->pstream
, t
);
1874 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
);
1879 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
) {
1885 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1887 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1888 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1889 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1890 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1892 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1894 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1895 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1896 pa_tagstruct_puts(t
, source_name
);
1897 pa_tagstruct_put_boolean(t
, suspend
);
1898 pa_pstream_send_tagstruct(c
->pstream
, t
);
1899 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
);
1904 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1910 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1912 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1913 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1914 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1916 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1918 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1919 pa_tagstruct_putu32(t
, idx
);
1920 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1921 pa_tagstruct_put_boolean(t
, suspend
);
1922 pa_pstream_send_tagstruct(c
->pstream
, t
);
1923 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
);