2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
7 PulseAudio is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 2.1 of the License,
10 or (at your option) any later version.
12 PulseAudio is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with PulseAudio; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 #include <pulse/context.h>
30 #include <pulse/gccmacro.h>
31 #include <pulse/xmalloc.h>
33 #include <pulsecore/macro.h>
34 #include <pulsecore/core-util.h>
35 #include <pulsecore/pstream-util.h>
38 #include "fork-detect.h"
40 #include "introspect.h"
44 static void context_stat_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
45 pa_operation
*o
= userdata
;
46 pa_stat_info i
, *p
= &i
;
50 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
57 if (command
!= PA_COMMAND_REPLY
) {
58 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
62 } else if (pa_tagstruct_getu32(t
, &i
.memblock_total
) < 0 ||
63 pa_tagstruct_getu32(t
, &i
.memblock_total_size
) < 0 ||
64 pa_tagstruct_getu32(t
, &i
.memblock_allocated
) < 0 ||
65 pa_tagstruct_getu32(t
, &i
.memblock_allocated_size
) < 0 ||
66 pa_tagstruct_getu32(t
, &i
.scache_size
) < 0 ||
67 !pa_tagstruct_eof(t
)) {
68 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
73 pa_stat_info_cb_t cb
= (pa_stat_info_cb_t
) o
->callback
;
74 cb(o
->context
, p
, o
->userdata
);
79 pa_operation_unref(o
);
82 pa_operation
* pa_context_stat(pa_context
*c
, pa_stat_info_cb_t cb
, void *userdata
) {
83 return pa_context_send_simple_command(c
, PA_COMMAND_STAT
, context_stat_callback
, (pa_operation_cb_t
) cb
, userdata
);
88 static void context_get_server_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
89 pa_operation
*o
= userdata
;
90 pa_server_info i
, *p
= &i
;
94 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
101 if (command
!= PA_COMMAND_REPLY
) {
102 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
106 } else if (pa_tagstruct_gets(t
, &i
.server_name
) < 0 ||
107 pa_tagstruct_gets(t
, &i
.server_version
) < 0 ||
108 pa_tagstruct_gets(t
, &i
.user_name
) < 0 ||
109 pa_tagstruct_gets(t
, &i
.host_name
) < 0 ||
110 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
111 pa_tagstruct_gets(t
, &i
.default_sink_name
) < 0 ||
112 pa_tagstruct_gets(t
, &i
.default_source_name
) < 0 ||
113 pa_tagstruct_getu32(t
, &i
.cookie
) < 0 ||
114 (o
->context
->version
>= 15 &&
115 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0) ||
116 !pa_tagstruct_eof(t
)) {
118 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
122 if (p
&& o
->context
->version
< 15)
123 pa_channel_map_init_extend(&i
.channel_map
, i
.sample_spec
.channels
, PA_CHANNEL_MAP_DEFAULT
);
126 pa_server_info_cb_t cb
= (pa_server_info_cb_t
) o
->callback
;
127 cb(o
->context
, p
, o
->userdata
);
131 pa_operation_done(o
);
132 pa_operation_unref(o
);
135 pa_operation
* pa_context_get_server_info(pa_context
*c
, pa_server_info_cb_t cb
, void *userdata
) {
136 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SERVER_INFO
, context_get_server_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
141 static void context_get_sink_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
142 pa_operation
*o
= userdata
;
147 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
152 if (command
!= PA_COMMAND_REPLY
) {
153 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
159 while (!pa_tagstruct_eof(t
)) {
165 const char *ap
= NULL
;
168 i
.proplist
= pa_proplist_new();
169 i
.base_volume
= PA_VOLUME_NORM
;
170 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
172 state
= PA_SINK_INVALID_STATE
;
173 i
.card
= PA_INVALID_INDEX
;
175 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
176 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
177 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
178 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
179 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
180 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
181 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
182 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
183 pa_tagstruct_getu32(t
, &i
.monitor_source
) < 0 ||
184 pa_tagstruct_gets(t
, &i
.monitor_source_name
) < 0 ||
185 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
186 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
187 pa_tagstruct_getu32(t
, &flags
) < 0 ||
188 (o
->context
->version
>= 13 &&
189 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
190 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
191 (o
->context
->version
>= 15 &&
192 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
193 pa_tagstruct_getu32(t
, &state
) < 0 ||
194 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
195 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
196 (o
->context
->version
>= 16 &&
197 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
199 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
200 pa_proplist_free(i
.proplist
);
204 if (o
->context
->version
>= 16) {
206 i
.ports
= pa_xnew(pa_sink_port_info
*, i
.n_ports
+1);
207 i
.ports
[0] = pa_xnew(pa_sink_port_info
, i
.n_ports
);
209 for (j
= 0; j
< i
.n_ports
; j
++) {
210 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
211 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
212 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
214 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
215 pa_xfree(i
.ports
[0]);
217 pa_proplist_free(i
.proplist
);
221 i
.ports
[j
] = &i
.ports
[0][j
];
227 if (pa_tagstruct_gets(t
, &ap
) < 0) {
228 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
229 pa_xfree(i
.ports
[0]);
231 pa_proplist_free(i
.proplist
);
236 for (j
= 0; j
< i
.n_ports
; j
++)
237 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
238 i
.active_port
= i
.ports
[j
];
245 i
.flags
= (pa_sink_flags_t
) flags
;
246 i
.state
= (pa_sink_state_t
) state
;
249 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
250 cb(o
->context
, &i
, 0, o
->userdata
);
254 pa_xfree(i
.ports
[0]);
257 pa_proplist_free(i
.proplist
);
262 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
263 cb(o
->context
, NULL
, eol
, o
->userdata
);
267 pa_operation_done(o
);
268 pa_operation_unref(o
);
271 pa_operation
* pa_context_get_sink_info_list(pa_context
*c
, pa_sink_info_cb_t cb
, void *userdata
) {
272 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SINK_INFO_LIST
, context_get_sink_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
275 pa_operation
* pa_context_get_sink_info_by_index(pa_context
*c
, uint32_t idx
, pa_sink_info_cb_t cb
, void *userdata
) {
281 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
284 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
285 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
287 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
289 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
290 pa_tagstruct_putu32(t
, idx
);
291 pa_tagstruct_puts(t
, NULL
);
292 pa_pstream_send_tagstruct(c
->pstream
, t
);
293 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
);
298 pa_operation
* pa_context_get_sink_info_by_name(pa_context
*c
, const char *name
, pa_sink_info_cb_t cb
, void *userdata
) {
304 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
307 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
308 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
309 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
311 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
313 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
314 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
315 pa_tagstruct_puts(t
, name
);
316 pa_pstream_send_tagstruct(c
->pstream
, t
);
317 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
);
322 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
) {
328 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
330 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
331 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
332 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
333 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
335 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
337 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
338 pa_tagstruct_putu32(t
, idx
);
339 pa_tagstruct_puts(t
, NULL
);
340 pa_tagstruct_puts(t
, port
);
341 pa_pstream_send_tagstruct(c
->pstream
, t
);
342 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
);
347 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
) {
353 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
355 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
356 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
357 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
358 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
360 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
362 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
363 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
364 pa_tagstruct_puts(t
, name
);
365 pa_tagstruct_puts(t
, port
);
366 pa_pstream_send_tagstruct(c
->pstream
, t
);
367 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, pa_context_simple_ack_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
372 /*** Source info ***/
374 static void context_get_source_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
375 pa_operation
*o
= userdata
;
380 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
385 if (command
!= PA_COMMAND_REPLY
) {
386 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
392 while (!pa_tagstruct_eof(t
)) {
401 i
.proplist
= pa_proplist_new();
402 i
.base_volume
= PA_VOLUME_NORM
;
403 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
405 state
= PA_SOURCE_INVALID_STATE
;
406 i
.card
= PA_INVALID_INDEX
;
408 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
409 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
410 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
411 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
412 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
413 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
414 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
415 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
416 pa_tagstruct_getu32(t
, &i
.monitor_of_sink
) < 0 ||
417 pa_tagstruct_gets(t
, &i
.monitor_of_sink_name
) < 0 ||
418 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
419 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
420 pa_tagstruct_getu32(t
, &flags
) < 0 ||
421 (o
->context
->version
>= 13 &&
422 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
423 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
424 (o
->context
->version
>= 15 &&
425 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
426 pa_tagstruct_getu32(t
, &state
) < 0 ||
427 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
428 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
429 (o
->context
->version
>= 16 &&
430 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
432 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
433 pa_proplist_free(i
.proplist
);
437 if (o
->context
->version
>= 16) {
439 i
.ports
= pa_xnew(pa_source_port_info
*, i
.n_ports
+1);
440 i
.ports
[0] = pa_xnew(pa_source_port_info
, i
.n_ports
);
442 for (j
= 0; j
< i
.n_ports
; j
++) {
443 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
444 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
445 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
447 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
448 pa_xfree(i
.ports
[0]);
450 pa_proplist_free(i
.proplist
);
454 i
.ports
[j
] = &i
.ports
[0][j
];
460 if (pa_tagstruct_gets(t
, &ap
) < 0) {
461 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
462 pa_xfree(i
.ports
[0]);
464 pa_proplist_free(i
.proplist
);
469 for (j
= 0; j
< i
.n_ports
; j
++)
470 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
471 i
.active_port
= i
.ports
[j
];
478 i
.flags
= (pa_source_flags_t
) flags
;
479 i
.state
= (pa_source_state_t
) state
;
482 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
483 cb(o
->context
, &i
, 0, o
->userdata
);
487 pa_xfree(i
.ports
[0]);
490 pa_proplist_free(i
.proplist
);
495 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
496 cb(o
->context
, NULL
, eol
, o
->userdata
);
500 pa_operation_done(o
);
501 pa_operation_unref(o
);
504 pa_operation
* pa_context_get_source_info_list(pa_context
*c
, pa_source_info_cb_t cb
, void *userdata
) {
505 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SOURCE_INFO_LIST
, context_get_source_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
508 pa_operation
* pa_context_get_source_info_by_index(pa_context
*c
, uint32_t idx
, pa_source_info_cb_t cb
, void *userdata
) {
514 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
517 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
518 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
520 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
522 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
523 pa_tagstruct_putu32(t
, idx
);
524 pa_tagstruct_puts(t
, NULL
);
525 pa_pstream_send_tagstruct(c
->pstream
, t
);
526 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
);
531 pa_operation
* pa_context_get_source_info_by_name(pa_context
*c
, const char *name
, pa_source_info_cb_t cb
, void *userdata
) {
537 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
540 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
541 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
542 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
544 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
546 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
547 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
548 pa_tagstruct_puts(t
, name
);
549 pa_pstream_send_tagstruct(c
->pstream
, t
);
550 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
);
555 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
) {
561 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
563 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
564 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
565 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
566 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
568 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
570 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
571 pa_tagstruct_putu32(t
, idx
);
572 pa_tagstruct_puts(t
, NULL
);
573 pa_tagstruct_puts(t
, port
);
574 pa_pstream_send_tagstruct(c
->pstream
, t
);
575 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
);
580 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
) {
586 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
588 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
589 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
590 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
591 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
593 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
595 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
596 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
597 pa_tagstruct_puts(t
, name
);
598 pa_tagstruct_puts(t
, port
);
599 pa_pstream_send_tagstruct(c
->pstream
, t
);
600 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
);
605 /*** Client info ***/
607 static void context_get_client_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
608 pa_operation
*o
= userdata
;
613 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
618 if (command
!= PA_COMMAND_REPLY
) {
619 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
625 while (!pa_tagstruct_eof(t
)) {
629 i
.proplist
= pa_proplist_new();
631 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
632 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
633 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
634 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
635 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
637 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
638 pa_proplist_free(i
.proplist
);
643 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
644 cb(o
->context
, &i
, 0, o
->userdata
);
647 pa_proplist_free(i
.proplist
);
652 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
653 cb(o
->context
, NULL
, eol
, o
->userdata
);
657 pa_operation_done(o
);
658 pa_operation_unref(o
);
661 pa_operation
* pa_context_get_client_info(pa_context
*c
, uint32_t idx
, pa_client_info_cb_t cb
, void *userdata
) {
667 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
670 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
671 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
672 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
674 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
676 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CLIENT_INFO
, &tag
);
677 pa_tagstruct_putu32(t
, idx
);
678 pa_pstream_send_tagstruct(c
->pstream
, t
);
679 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
);
684 pa_operation
* pa_context_get_client_info_list(pa_context
*c
, pa_client_info_cb_t cb
, void *userdata
) {
685 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CLIENT_INFO_LIST
, context_get_client_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
690 static void context_get_card_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
691 pa_operation
*o
= userdata
;
696 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
701 if (command
!= PA_COMMAND_REPLY
) {
702 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
708 while (!pa_tagstruct_eof(t
)) {
715 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
716 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
717 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
718 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
719 pa_tagstruct_getu32(t
, &i
.n_profiles
) < 0) {
721 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
725 if (i
.n_profiles
> 0) {
726 i
.profiles
= pa_xnew0(pa_card_profile_info
, i
.n_profiles
+1);
728 for (j
= 0; j
< i
.n_profiles
; j
++) {
730 if (pa_tagstruct_gets(t
, &i
.profiles
[j
].name
) < 0 ||
731 pa_tagstruct_gets(t
, &i
.profiles
[j
].description
) < 0 ||
732 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sinks
) < 0 ||
733 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sources
) < 0 ||
734 pa_tagstruct_getu32(t
, &i
.profiles
[j
].priority
) < 0) {
736 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
737 pa_xfree(i
.profiles
);
742 /* Terminate with an extra NULL entry, just to make sure */
743 i
.profiles
[j
].name
= NULL
;
744 i
.profiles
[j
].description
= NULL
;
747 i
.proplist
= pa_proplist_new();
749 if (pa_tagstruct_gets(t
, &ap
) < 0 ||
750 pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) {
752 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
753 pa_xfree(i
.profiles
);
754 pa_proplist_free(i
.proplist
);
759 for (j
= 0; j
< i
.n_profiles
; j
++)
760 if (pa_streq(i
.profiles
[j
].name
, ap
)) {
761 i
.active_profile
= &i
.profiles
[j
];
767 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
768 cb(o
->context
, &i
, 0, o
->userdata
);
771 pa_proplist_free(i
.proplist
);
772 pa_xfree(i
.profiles
);
777 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
778 cb(o
->context
, NULL
, eol
, o
->userdata
);
782 pa_operation_done(o
);
783 pa_operation_unref(o
);
786 pa_operation
* pa_context_get_card_info_by_index(pa_context
*c
, uint32_t idx
, pa_card_info_cb_t cb
, void *userdata
) {
792 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
795 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
796 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
797 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
798 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
800 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
802 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
803 pa_tagstruct_putu32(t
, idx
);
804 pa_tagstruct_puts(t
, NULL
);
805 pa_pstream_send_tagstruct(c
->pstream
, t
);
806 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
);
811 pa_operation
* pa_context_get_card_info_by_name(pa_context
*c
, const char*name
, pa_card_info_cb_t cb
, void *userdata
) {
817 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
820 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
821 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
822 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
823 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
825 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
827 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
828 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
829 pa_tagstruct_puts(t
, name
);
830 pa_pstream_send_tagstruct(c
->pstream
, t
);
831 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
);
836 pa_operation
* pa_context_get_card_info_list(pa_context
*c
, pa_card_info_cb_t cb
, void *userdata
) {
837 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
840 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
) {
846 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
848 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
849 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
850 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
851 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
853 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
855 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
856 pa_tagstruct_putu32(t
, idx
);
857 pa_tagstruct_puts(t
, NULL
);
858 pa_tagstruct_puts(t
, profile
);
859 pa_pstream_send_tagstruct(c
->pstream
, t
);
860 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
);
865 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
) {
871 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
873 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
874 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
875 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
876 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
878 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
880 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
881 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
882 pa_tagstruct_puts(t
, name
);
883 pa_tagstruct_puts(t
, profile
);
884 pa_pstream_send_tagstruct(c
->pstream
, t
);
885 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
);
890 /*** Module info ***/
892 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
893 pa_operation
*o
= userdata
;
898 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
903 if (command
!= PA_COMMAND_REPLY
) {
904 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
910 while (!pa_tagstruct_eof(t
)) {
912 pa_bool_t auto_unload
= FALSE
;
915 i
.proplist
= pa_proplist_new();
917 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
918 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
919 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
920 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
921 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
922 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
923 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
927 i
.auto_unload
= (int) auto_unload
;
930 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
931 cb(o
->context
, &i
, 0, o
->userdata
);
934 pa_proplist_free(i
.proplist
);
939 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
940 cb(o
->context
, NULL
, eol
, o
->userdata
);
944 pa_operation_done(o
);
945 pa_operation_unref(o
);
948 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
954 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
957 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
958 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
959 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
961 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
963 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
964 pa_tagstruct_putu32(t
, idx
);
965 pa_pstream_send_tagstruct(c
->pstream
, t
);
966 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
);
971 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
972 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
975 /*** Sink input info ***/
977 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
978 pa_operation
*o
= userdata
;
983 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
988 if (command
!= PA_COMMAND_REPLY
) {
989 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
995 while (!pa_tagstruct_eof(t
)) {
996 pa_sink_input_info i
;
997 pa_bool_t mute
= FALSE
;
1000 i
.proplist
= pa_proplist_new();
1002 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1003 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1004 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1005 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1006 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
1007 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1008 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1009 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1010 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1011 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1012 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1013 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1014 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1015 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1017 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1018 pa_proplist_free(i
.proplist
);
1022 i
.mute
= (int) mute
;
1025 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1026 cb(o
->context
, &i
, 0, o
->userdata
);
1029 pa_proplist_free(i
.proplist
);
1034 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1035 cb(o
->context
, NULL
, eol
, o
->userdata
);
1039 pa_operation_done(o
);
1040 pa_operation_unref(o
);
1043 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1049 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1052 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1053 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1054 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1056 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1058 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1059 pa_tagstruct_putu32(t
, idx
);
1060 pa_pstream_send_tagstruct(c
->pstream
, t
);
1061 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
);
1066 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
) {
1067 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
);
1070 /*** Source output info ***/
1072 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1073 pa_operation
*o
= userdata
;
1078 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1083 if (command
!= PA_COMMAND_REPLY
) {
1084 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1090 while (!pa_tagstruct_eof(t
)) {
1091 pa_source_output_info i
;
1094 i
.proplist
= pa_proplist_new();
1096 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1097 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1098 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1099 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1100 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1101 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1102 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1103 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1104 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1105 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1106 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1107 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1109 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1110 pa_proplist_free(i
.proplist
);
1115 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1116 cb(o
->context
, &i
, 0, o
->userdata
);
1119 pa_proplist_free(i
.proplist
);
1124 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1125 cb(o
->context
, NULL
, eol
, o
->userdata
);
1129 pa_operation_done(o
);
1130 pa_operation_unref(o
);
1133 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1139 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1142 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1143 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1144 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1146 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1148 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1149 pa_tagstruct_putu32(t
, idx
);
1150 pa_pstream_send_tagstruct(c
->pstream
, t
);
1151 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
);
1156 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1157 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
);
1160 /*** Volume manipulation ***/
1162 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
) {
1168 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1171 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1172 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1173 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1175 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1177 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1178 pa_tagstruct_putu32(t
, idx
);
1179 pa_tagstruct_puts(t
, NULL
);
1180 pa_tagstruct_put_cvolume(t
, volume
);
1181 pa_pstream_send_tagstruct(c
->pstream
, t
);
1182 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
);
1187 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
) {
1193 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1197 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1198 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1199 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1200 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1202 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1204 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1205 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1206 pa_tagstruct_puts(t
, name
);
1207 pa_tagstruct_put_cvolume(t
, volume
);
1208 pa_pstream_send_tagstruct(c
->pstream
, t
);
1209 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
);
1214 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
) {
1220 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1222 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1223 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1225 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1227 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1228 pa_tagstruct_putu32(t
, idx
);
1229 pa_tagstruct_puts(t
, NULL
);
1230 pa_tagstruct_put_boolean(t
, mute
);
1231 pa_pstream_send_tagstruct(c
->pstream
, t
);
1232 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
);
1237 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
) {
1243 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
, !name
|| *name
, PA_ERR_INVALID
);
1250 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1252 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1253 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1254 pa_tagstruct_puts(t
, name
);
1255 pa_tagstruct_put_boolean(t
, mute
);
1256 pa_pstream_send_tagstruct(c
->pstream
, t
);
1257 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
);
1262 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
) {
1268 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
);
1273 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1274 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1276 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1278 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1279 pa_tagstruct_putu32(t
, idx
);
1280 pa_tagstruct_put_cvolume(t
, volume
);
1281 pa_pstream_send_tagstruct(c
->pstream
, t
);
1282 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
);
1287 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1293 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
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1298 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1300 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1302 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1303 pa_tagstruct_putu32(t
, idx
);
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_source_volume_by_index(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
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1324 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1326 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1327 pa_tagstruct_putu32(t
, idx
);
1328 pa_tagstruct_puts(t
, NULL
);
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_source_volume_by_name(pa_context
*c
, const char *name
, const pa_cvolume
*volume
, pa_context_success_cb_t cb
, void *userdata
) {
1342 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1346 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1347 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1348 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1349 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1351 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1353 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1354 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1355 pa_tagstruct_puts(t
, name
);
1356 pa_tagstruct_put_cvolume(t
, volume
);
1357 pa_pstream_send_tagstruct(c
->pstream
, t
);
1358 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
);
1363 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
) {
1369 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1371 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1372 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1374 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1376 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1377 pa_tagstruct_putu32(t
, idx
);
1378 pa_tagstruct_puts(t
, NULL
);
1379 pa_tagstruct_put_boolean(t
, mute
);
1380 pa_pstream_send_tagstruct(c
->pstream
, t
);
1381 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
);
1386 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
) {
1392 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
, !name
|| *name
, PA_ERR_INVALID
);
1399 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1401 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1402 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1403 pa_tagstruct_puts(t
, name
);
1404 pa_tagstruct_put_boolean(t
, mute
);
1405 pa_pstream_send_tagstruct(c
->pstream
, t
);
1406 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
);
1411 /** Sample Cache **/
1413 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1414 pa_operation
*o
= userdata
;
1419 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1424 if (command
!= PA_COMMAND_REPLY
) {
1425 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1431 while (!pa_tagstruct_eof(t
)) {
1433 pa_bool_t lazy
= FALSE
;
1436 i
.proplist
= pa_proplist_new();
1438 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1439 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1440 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1441 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1442 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1443 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1444 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1445 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1446 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1447 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1449 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1453 i
.lazy
= (int) lazy
;
1456 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1457 cb(o
->context
, &i
, 0, o
->userdata
);
1460 pa_proplist_free(i
.proplist
);
1465 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1466 cb(o
->context
, NULL
, eol
, o
->userdata
);
1470 pa_operation_done(o
);
1471 pa_operation_unref(o
);
1474 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1480 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1483 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1484 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1485 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1487 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1489 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1490 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1491 pa_tagstruct_puts(t
, name
);
1492 pa_pstream_send_tagstruct(c
->pstream
, t
);
1493 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
);
1498 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1504 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1507 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1508 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1509 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1511 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1513 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1514 pa_tagstruct_putu32(t
, idx
);
1515 pa_tagstruct_puts(t
, NULL
);
1516 pa_pstream_send_tagstruct(c
->pstream
, t
);
1517 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
);
1522 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1523 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1526 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1532 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1534 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1535 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1536 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1538 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1540 t
= pa_tagstruct_command(c
, command
, &tag
);
1541 pa_tagstruct_putu32(t
, idx
);
1542 pa_pstream_send_tagstruct(c
->pstream
, t
);
1543 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, pa_context_simple_ack_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1548 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1549 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1552 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1553 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1556 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1557 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1560 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1561 pa_operation
*o
= userdata
;
1566 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1571 if (command
!= PA_COMMAND_REPLY
) {
1572 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1575 idx
= PA_INVALID_INDEX
;
1576 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1577 !pa_tagstruct_eof(t
)) {
1578 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1583 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1584 cb(o
->context
, idx
, o
->userdata
);
1589 pa_operation_done(o
);
1590 pa_operation_unref(o
);
1593 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1599 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1601 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1602 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1603 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1605 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1607 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1608 pa_tagstruct_puts(t
, name
);
1609 pa_tagstruct_puts(t
, argument
);
1610 pa_pstream_send_tagstruct(c
->pstream
, t
);
1611 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1616 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1617 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1620 /*** Autoload stuff ***/
1622 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1624 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
) {
1627 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1629 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1632 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1634 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1636 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1638 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1641 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1643 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1645 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1647 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1650 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1652 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
) {
1654 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1656 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1659 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1661 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
) {
1663 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1665 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1668 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1670 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1672 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1674 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1677 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
) {
1683 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1685 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1686 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1687 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1688 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1689 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1691 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1693 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1694 pa_tagstruct_putu32(t
, idx
);
1695 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1696 pa_tagstruct_puts(t
, sink_name
);
1697 pa_pstream_send_tagstruct(c
->pstream
, t
);
1698 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
);
1703 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
) {
1709 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1711 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1712 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1713 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1714 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1715 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1717 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1719 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1720 pa_tagstruct_putu32(t
, idx
);
1721 pa_tagstruct_putu32(t
, sink_idx
);
1722 pa_tagstruct_puts(t
, NULL
);
1723 pa_pstream_send_tagstruct(c
->pstream
, t
);
1724 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
);
1729 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
) {
1735 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1737 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1738 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1739 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1740 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1741 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1743 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1745 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1746 pa_tagstruct_putu32(t
, idx
);
1747 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1748 pa_tagstruct_puts(t
, source_name
);
1749 pa_pstream_send_tagstruct(c
->pstream
, t
);
1750 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
);
1755 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
) {
1761 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1763 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1764 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1765 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1766 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1767 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1769 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1771 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1772 pa_tagstruct_putu32(t
, idx
);
1773 pa_tagstruct_putu32(t
, source_idx
);
1774 pa_tagstruct_puts(t
, NULL
);
1775 pa_pstream_send_tagstruct(c
->pstream
, t
);
1776 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
);
1781 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
) {
1787 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1789 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1790 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1791 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1792 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1794 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1796 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1797 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1798 pa_tagstruct_puts(t
, sink_name
);
1799 pa_tagstruct_put_boolean(t
, suspend
);
1800 pa_pstream_send_tagstruct(c
->pstream
, t
);
1801 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
);
1806 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1812 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1814 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1815 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1816 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1818 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1820 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1821 pa_tagstruct_putu32(t
, idx
);
1822 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1823 pa_tagstruct_put_boolean(t
, suspend
);
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_source_by_name(pa_context
*c
, const char *source_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
, !source_name
|| *source_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_SOURCE
, &tag
);
1846 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1847 pa_tagstruct_puts(t
, source_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_source_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_SOURCE
, &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
);