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();
1037 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1038 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1039 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1040 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1041 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
1042 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1043 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1044 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1045 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1046 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1047 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1048 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1049 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1050 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1051 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0) ||
1052 (o
->context
->version
>= 20 && (pa_tagstruct_get_boolean(t
, &has_volume
) < 0 ||
1053 pa_tagstruct_get_boolean(t
, &volume_writable
) < 0))) {
1055 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1056 pa_proplist_free(i
.proplist
);
1060 i
.mute
= (int) mute
;
1061 i
.corked
= (int) corked
;
1062 i
.has_volume
= (int) has_volume
;
1063 i
.volume_writable
= (int) volume_writable
;
1066 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1067 cb(o
->context
, &i
, 0, o
->userdata
);
1070 pa_proplist_free(i
.proplist
);
1075 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1076 cb(o
->context
, NULL
, eol
, o
->userdata
);
1080 pa_operation_done(o
);
1081 pa_operation_unref(o
);
1084 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1090 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1093 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1094 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1095 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1097 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1099 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1100 pa_tagstruct_putu32(t
, idx
);
1101 pa_pstream_send_tagstruct(c
->pstream
, t
);
1102 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
);
1107 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
) {
1108 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
);
1111 /*** Source output info ***/
1113 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1114 pa_operation
*o
= userdata
;
1119 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1124 if (command
!= PA_COMMAND_REPLY
) {
1125 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1131 while (!pa_tagstruct_eof(t
)) {
1132 pa_source_output_info i
;
1133 pa_bool_t corked
= FALSE
;
1136 i
.proplist
= pa_proplist_new();
1138 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1139 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1140 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1141 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1142 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1143 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1144 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1145 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1146 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1147 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1148 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1149 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1150 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0)) {
1152 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1153 pa_proplist_free(i
.proplist
);
1157 i
.corked
= (int) corked
;
1160 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1161 cb(o
->context
, &i
, 0, o
->userdata
);
1164 pa_proplist_free(i
.proplist
);
1169 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1170 cb(o
->context
, NULL
, eol
, o
->userdata
);
1174 pa_operation_done(o
);
1175 pa_operation_unref(o
);
1178 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1184 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1187 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1188 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1189 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1191 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1193 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1194 pa_tagstruct_putu32(t
, idx
);
1195 pa_pstream_send_tagstruct(c
->pstream
, t
);
1196 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
);
1201 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1202 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
);
1205 /*** Volume manipulation ***/
1207 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
) {
1213 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1216 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1217 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1218 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1220 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1222 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1223 pa_tagstruct_putu32(t
, idx
);
1224 pa_tagstruct_puts(t
, NULL
);
1225 pa_tagstruct_put_cvolume(t
, volume
);
1226 pa_pstream_send_tagstruct(c
->pstream
, t
);
1227 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
);
1232 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
) {
1238 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1242 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1243 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1244 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1245 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1247 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1249 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1250 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1251 pa_tagstruct_puts(t
, name
);
1252 pa_tagstruct_put_cvolume(t
, volume
);
1253 pa_pstream_send_tagstruct(c
->pstream
, t
);
1254 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
);
1259 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
) {
1265 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1267 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1268 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1270 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1272 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1273 pa_tagstruct_putu32(t
, idx
);
1274 pa_tagstruct_puts(t
, NULL
);
1275 pa_tagstruct_put_boolean(t
, mute
);
1276 pa_pstream_send_tagstruct(c
->pstream
, t
);
1277 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
);
1282 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
) {
1288 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1291 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1292 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1293 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1295 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1297 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1298 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1299 pa_tagstruct_puts(t
, name
);
1300 pa_tagstruct_put_boolean(t
, mute
);
1301 pa_pstream_send_tagstruct(c
->pstream
, t
);
1302 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
);
1307 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
) {
1313 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1316 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1317 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1318 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1319 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1321 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1323 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1324 pa_tagstruct_putu32(t
, idx
);
1325 pa_tagstruct_put_cvolume(t
, volume
);
1326 pa_pstream_send_tagstruct(c
->pstream
, t
);
1327 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
);
1332 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1338 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1340 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1341 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1342 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1343 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1345 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1347 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1348 pa_tagstruct_putu32(t
, idx
);
1349 pa_tagstruct_put_boolean(t
, mute
);
1350 pa_pstream_send_tagstruct(c
->pstream
, t
);
1351 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
);
1356 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
) {
1362 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1365 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1366 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1367 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1369 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1371 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1372 pa_tagstruct_putu32(t
, idx
);
1373 pa_tagstruct_puts(t
, NULL
);
1374 pa_tagstruct_put_cvolume(t
, volume
);
1375 pa_pstream_send_tagstruct(c
->pstream
, t
);
1376 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
);
1381 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
) {
1387 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1391 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1392 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1393 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1394 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1396 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1398 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1399 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1400 pa_tagstruct_puts(t
, name
);
1401 pa_tagstruct_put_cvolume(t
, volume
);
1402 pa_pstream_send_tagstruct(c
->pstream
, t
);
1403 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
);
1408 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
) {
1414 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1416 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1417 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1419 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1421 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1422 pa_tagstruct_putu32(t
, idx
);
1423 pa_tagstruct_puts(t
, NULL
);
1424 pa_tagstruct_put_boolean(t
, mute
);
1425 pa_pstream_send_tagstruct(c
->pstream
, t
);
1426 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
);
1431 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
) {
1437 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1440 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1441 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1442 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1444 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1446 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1447 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1448 pa_tagstruct_puts(t
, name
);
1449 pa_tagstruct_put_boolean(t
, mute
);
1450 pa_pstream_send_tagstruct(c
->pstream
, t
);
1451 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
);
1456 /** Sample Cache **/
1458 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1459 pa_operation
*o
= userdata
;
1464 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1469 if (command
!= PA_COMMAND_REPLY
) {
1470 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1476 while (!pa_tagstruct_eof(t
)) {
1478 pa_bool_t lazy
= FALSE
;
1481 i
.proplist
= pa_proplist_new();
1483 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1484 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1485 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1486 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1487 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1488 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1489 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1490 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1491 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1492 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1494 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1498 i
.lazy
= (int) lazy
;
1501 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1502 cb(o
->context
, &i
, 0, o
->userdata
);
1505 pa_proplist_free(i
.proplist
);
1510 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1511 cb(o
->context
, NULL
, eol
, o
->userdata
);
1515 pa_operation_done(o
);
1516 pa_operation_unref(o
);
1519 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1525 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1528 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1529 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1530 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1532 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1534 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1535 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1536 pa_tagstruct_puts(t
, name
);
1537 pa_pstream_send_tagstruct(c
->pstream
, t
);
1538 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
);
1543 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1549 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1552 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1553 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1554 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1556 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1558 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1559 pa_tagstruct_putu32(t
, idx
);
1560 pa_tagstruct_puts(t
, NULL
);
1561 pa_pstream_send_tagstruct(c
->pstream
, t
);
1562 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
);
1567 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1568 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1571 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1577 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1579 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1580 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1581 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1583 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1585 t
= pa_tagstruct_command(c
, command
, &tag
);
1586 pa_tagstruct_putu32(t
, idx
);
1587 pa_pstream_send_tagstruct(c
->pstream
, t
);
1588 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
);
1593 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1594 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1597 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1598 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1601 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1602 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1605 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1606 pa_operation
*o
= userdata
;
1611 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1616 if (command
!= PA_COMMAND_REPLY
) {
1617 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1620 idx
= PA_INVALID_INDEX
;
1621 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1622 !pa_tagstruct_eof(t
)) {
1623 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1628 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1629 cb(o
->context
, idx
, o
->userdata
);
1634 pa_operation_done(o
);
1635 pa_operation_unref(o
);
1638 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1644 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1646 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1647 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1648 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1650 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1652 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1653 pa_tagstruct_puts(t
, name
);
1654 pa_tagstruct_puts(t
, argument
);
1655 pa_pstream_send_tagstruct(c
->pstream
, t
);
1656 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1661 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1662 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1665 /*** Autoload stuff ***/
1667 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1669 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
) {
1672 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1674 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1677 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1679 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1681 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1683 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1686 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1688 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1690 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1692 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1695 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1697 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
) {
1699 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1701 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1704 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1706 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
) {
1708 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1710 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1713 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1715 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1717 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1719 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1722 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
) {
1728 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1730 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1731 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1732 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1733 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1734 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1736 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1738 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1739 pa_tagstruct_putu32(t
, idx
);
1740 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1741 pa_tagstruct_puts(t
, sink_name
);
1742 pa_pstream_send_tagstruct(c
->pstream
, t
);
1743 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
);
1748 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
) {
1754 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1756 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1757 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1758 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1759 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1760 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1762 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1764 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1765 pa_tagstruct_putu32(t
, idx
);
1766 pa_tagstruct_putu32(t
, sink_idx
);
1767 pa_tagstruct_puts(t
, NULL
);
1768 pa_pstream_send_tagstruct(c
->pstream
, t
);
1769 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
);
1774 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
) {
1780 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1782 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1783 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1784 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1785 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1786 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1788 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1790 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1791 pa_tagstruct_putu32(t
, idx
);
1792 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1793 pa_tagstruct_puts(t
, source_name
);
1794 pa_pstream_send_tagstruct(c
->pstream
, t
);
1795 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
);
1800 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
) {
1806 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1808 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1809 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1810 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1811 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1812 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1814 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1816 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1817 pa_tagstruct_putu32(t
, idx
);
1818 pa_tagstruct_putu32(t
, source_idx
);
1819 pa_tagstruct_puts(t
, NULL
);
1820 pa_pstream_send_tagstruct(c
->pstream
, t
);
1821 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
);
1826 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
) {
1832 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1834 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1835 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1836 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1837 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1839 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1841 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1842 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1843 pa_tagstruct_puts(t
, sink_name
);
1844 pa_tagstruct_put_boolean(t
, suspend
);
1845 pa_pstream_send_tagstruct(c
->pstream
, t
);
1846 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
);
1851 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1857 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1859 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1860 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1861 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1863 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1865 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1866 pa_tagstruct_putu32(t
, idx
);
1867 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1868 pa_tagstruct_put_boolean(t
, suspend
);
1869 pa_pstream_send_tagstruct(c
->pstream
, t
);
1870 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
);
1875 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
) {
1881 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1883 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1884 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1885 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1886 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1888 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1890 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1891 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1892 pa_tagstruct_puts(t
, source_name
);
1893 pa_tagstruct_put_boolean(t
, suspend
);
1894 pa_pstream_send_tagstruct(c
->pstream
, t
);
1895 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
);
1900 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1906 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1908 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1909 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1910 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1912 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1914 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1915 pa_tagstruct_putu32(t
, idx
);
1916 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1917 pa_tagstruct_put_boolean(t
, suspend
);
1918 pa_pstream_send_tagstruct(c
->pstream
, t
);
1919 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
);