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 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
839 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
842 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
) {
848 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
850 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
851 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
852 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
853 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
855 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
857 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
858 pa_tagstruct_putu32(t
, idx
);
859 pa_tagstruct_puts(t
, NULL
);
860 pa_tagstruct_puts(t
, profile
);
861 pa_pstream_send_tagstruct(c
->pstream
, t
);
862 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
);
867 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
) {
873 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
875 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
876 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
877 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
878 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
880 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
882 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
883 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
884 pa_tagstruct_puts(t
, name
);
885 pa_tagstruct_puts(t
, profile
);
886 pa_pstream_send_tagstruct(c
->pstream
, t
);
887 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
);
892 /*** Module info ***/
894 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
895 pa_operation
*o
= userdata
;
900 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
905 if (command
!= PA_COMMAND_REPLY
) {
906 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
912 while (!pa_tagstruct_eof(t
)) {
914 pa_bool_t auto_unload
= FALSE
;
917 i
.proplist
= pa_proplist_new();
919 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
920 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
921 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
922 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
923 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
924 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
925 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
929 i
.auto_unload
= (int) auto_unload
;
932 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
933 cb(o
->context
, &i
, 0, o
->userdata
);
936 pa_proplist_free(i
.proplist
);
941 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
942 cb(o
->context
, NULL
, eol
, o
->userdata
);
946 pa_operation_done(o
);
947 pa_operation_unref(o
);
950 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
956 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
959 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
960 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
961 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
963 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
965 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
966 pa_tagstruct_putu32(t
, idx
);
967 pa_pstream_send_tagstruct(c
->pstream
, t
);
968 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
);
973 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
974 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
977 /*** Sink input info ***/
979 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
980 pa_operation
*o
= userdata
;
985 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
990 if (command
!= PA_COMMAND_REPLY
) {
991 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
997 while (!pa_tagstruct_eof(t
)) {
998 pa_sink_input_info i
;
999 pa_bool_t mute
= FALSE
, corked
= FALSE
, has_volume
= FALSE
, read_only_volume
= FALSE
;
1002 i
.proplist
= pa_proplist_new();
1004 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1005 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1006 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1007 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1008 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
1009 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1010 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1011 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1012 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1013 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1014 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1015 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1016 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1017 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1018 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0) ||
1019 (o
->context
->version
>= 20 && (pa_tagstruct_get_boolean(t
, &has_volume
) < 0 ||
1020 pa_tagstruct_get_boolean(t
, &read_only_volume
) < 0))) {
1022 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1023 pa_proplist_free(i
.proplist
);
1027 i
.mute
= (int) mute
;
1028 i
.corked
= (int) corked
;
1029 i
.has_volume
= (int) has_volume
;
1030 i
.read_only_volume
= (int) read_only_volume
;
1033 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1034 cb(o
->context
, &i
, 0, o
->userdata
);
1037 pa_proplist_free(i
.proplist
);
1042 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1043 cb(o
->context
, NULL
, eol
, o
->userdata
);
1047 pa_operation_done(o
);
1048 pa_operation_unref(o
);
1051 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1057 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1060 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1061 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1062 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1064 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1066 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1067 pa_tagstruct_putu32(t
, idx
);
1068 pa_pstream_send_tagstruct(c
->pstream
, t
);
1069 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
);
1074 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
) {
1075 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
);
1078 /*** Source output info ***/
1080 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1081 pa_operation
*o
= userdata
;
1086 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1091 if (command
!= PA_COMMAND_REPLY
) {
1092 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1098 while (!pa_tagstruct_eof(t
)) {
1099 pa_source_output_info i
;
1100 pa_bool_t corked
= FALSE
;
1103 i
.proplist
= pa_proplist_new();
1105 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1106 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1107 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1108 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1109 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1110 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1111 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1112 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1113 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1114 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1115 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1116 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1117 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0)) {
1119 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1120 pa_proplist_free(i
.proplist
);
1124 i
.corked
= (int) corked
;
1127 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1128 cb(o
->context
, &i
, 0, o
->userdata
);
1131 pa_proplist_free(i
.proplist
);
1136 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1137 cb(o
->context
, NULL
, eol
, o
->userdata
);
1141 pa_operation_done(o
);
1142 pa_operation_unref(o
);
1145 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1151 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1154 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1155 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1156 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1158 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1160 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1161 pa_tagstruct_putu32(t
, idx
);
1162 pa_pstream_send_tagstruct(c
->pstream
, t
);
1163 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
);
1168 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1169 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
);
1172 /*** Volume manipulation ***/
1174 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
) {
1180 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1183 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1184 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1185 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1187 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1189 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1190 pa_tagstruct_putu32(t
, idx
);
1191 pa_tagstruct_puts(t
, NULL
);
1192 pa_tagstruct_put_cvolume(t
, volume
);
1193 pa_pstream_send_tagstruct(c
->pstream
, t
);
1194 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
);
1199 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
) {
1205 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1209 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1210 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1211 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1212 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1214 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1216 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1217 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1218 pa_tagstruct_puts(t
, name
);
1219 pa_tagstruct_put_cvolume(t
, volume
);
1220 pa_pstream_send_tagstruct(c
->pstream
, t
);
1221 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
);
1226 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
) {
1232 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1234 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1235 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1237 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1239 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1240 pa_tagstruct_putu32(t
, idx
);
1241 pa_tagstruct_puts(t
, NULL
);
1242 pa_tagstruct_put_boolean(t
, mute
);
1243 pa_pstream_send_tagstruct(c
->pstream
, t
);
1244 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
);
1249 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
) {
1255 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1258 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1259 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1260 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1262 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1264 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1265 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1266 pa_tagstruct_puts(t
, name
);
1267 pa_tagstruct_put_boolean(t
, mute
);
1268 pa_pstream_send_tagstruct(c
->pstream
, t
);
1269 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
);
1274 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
) {
1280 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1283 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1284 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1285 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1286 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1288 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1290 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1291 pa_tagstruct_putu32(t
, idx
);
1292 pa_tagstruct_put_cvolume(t
, volume
);
1293 pa_pstream_send_tagstruct(c
->pstream
, t
);
1294 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
);
1299 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1305 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1307 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1308 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1309 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1310 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1312 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1314 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1315 pa_tagstruct_putu32(t
, idx
);
1316 pa_tagstruct_put_boolean(t
, mute
);
1317 pa_pstream_send_tagstruct(c
->pstream
, t
);
1318 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
);
1323 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
) {
1329 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1332 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1333 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1334 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1336 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1338 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1339 pa_tagstruct_putu32(t
, idx
);
1340 pa_tagstruct_puts(t
, NULL
);
1341 pa_tagstruct_put_cvolume(t
, volume
);
1342 pa_pstream_send_tagstruct(c
->pstream
, t
);
1343 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
);
1348 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
) {
1354 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1358 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1359 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1360 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1361 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1363 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1365 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1366 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1367 pa_tagstruct_puts(t
, name
);
1368 pa_tagstruct_put_cvolume(t
, volume
);
1369 pa_pstream_send_tagstruct(c
->pstream
, t
);
1370 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
);
1375 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
) {
1381 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1383 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1384 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1386 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1388 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1389 pa_tagstruct_putu32(t
, idx
);
1390 pa_tagstruct_puts(t
, NULL
);
1391 pa_tagstruct_put_boolean(t
, mute
);
1392 pa_pstream_send_tagstruct(c
->pstream
, t
);
1393 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
);
1398 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
) {
1404 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1407 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1408 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1409 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1411 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1413 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1414 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1415 pa_tagstruct_puts(t
, name
);
1416 pa_tagstruct_put_boolean(t
, mute
);
1417 pa_pstream_send_tagstruct(c
->pstream
, t
);
1418 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
);
1423 /** Sample Cache **/
1425 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1426 pa_operation
*o
= userdata
;
1431 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1436 if (command
!= PA_COMMAND_REPLY
) {
1437 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1443 while (!pa_tagstruct_eof(t
)) {
1445 pa_bool_t lazy
= FALSE
;
1448 i
.proplist
= pa_proplist_new();
1450 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1451 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1452 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1453 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1454 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1455 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1456 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1457 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1458 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1459 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1461 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1465 i
.lazy
= (int) lazy
;
1468 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1469 cb(o
->context
, &i
, 0, o
->userdata
);
1472 pa_proplist_free(i
.proplist
);
1477 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1478 cb(o
->context
, NULL
, eol
, o
->userdata
);
1482 pa_operation_done(o
);
1483 pa_operation_unref(o
);
1486 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1492 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1495 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1496 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1497 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1499 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1501 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1502 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1503 pa_tagstruct_puts(t
, name
);
1504 pa_pstream_send_tagstruct(c
->pstream
, t
);
1505 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
);
1510 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1516 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1519 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1520 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1521 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1523 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1525 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1526 pa_tagstruct_putu32(t
, idx
);
1527 pa_tagstruct_puts(t
, NULL
);
1528 pa_pstream_send_tagstruct(c
->pstream
, t
);
1529 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
);
1534 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1535 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1538 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1544 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1546 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1547 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1548 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1550 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1552 t
= pa_tagstruct_command(c
, command
, &tag
);
1553 pa_tagstruct_putu32(t
, idx
);
1554 pa_pstream_send_tagstruct(c
->pstream
, t
);
1555 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
);
1560 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1561 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1564 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1565 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1568 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1569 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1572 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1573 pa_operation
*o
= userdata
;
1578 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1583 if (command
!= PA_COMMAND_REPLY
) {
1584 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1587 idx
= PA_INVALID_INDEX
;
1588 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1589 !pa_tagstruct_eof(t
)) {
1590 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1595 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1596 cb(o
->context
, idx
, o
->userdata
);
1601 pa_operation_done(o
);
1602 pa_operation_unref(o
);
1605 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1611 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1613 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1614 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1615 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1617 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1619 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1620 pa_tagstruct_puts(t
, name
);
1621 pa_tagstruct_puts(t
, argument
);
1622 pa_pstream_send_tagstruct(c
->pstream
, t
);
1623 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1628 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1629 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1632 /*** Autoload stuff ***/
1634 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1636 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
) {
1639 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1641 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1644 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1646 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1648 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1650 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1653 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1655 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1657 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1659 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1662 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1664 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
) {
1666 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1668 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1671 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1673 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
) {
1675 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1677 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1680 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1682 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1684 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1686 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1689 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
) {
1695 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1697 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1698 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1699 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1700 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1701 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1703 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1705 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1706 pa_tagstruct_putu32(t
, idx
);
1707 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1708 pa_tagstruct_puts(t
, sink_name
);
1709 pa_pstream_send_tagstruct(c
->pstream
, t
);
1710 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
);
1715 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
) {
1721 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1723 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1724 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1725 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1726 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1727 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1729 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1731 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1732 pa_tagstruct_putu32(t
, idx
);
1733 pa_tagstruct_putu32(t
, sink_idx
);
1734 pa_tagstruct_puts(t
, NULL
);
1735 pa_pstream_send_tagstruct(c
->pstream
, t
);
1736 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
);
1741 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
) {
1747 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1749 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1750 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1751 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1752 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1753 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1755 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1757 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1758 pa_tagstruct_putu32(t
, idx
);
1759 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1760 pa_tagstruct_puts(t
, source_name
);
1761 pa_pstream_send_tagstruct(c
->pstream
, t
);
1762 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
);
1767 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
) {
1773 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1775 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1776 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1777 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1778 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1779 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1781 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1783 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1784 pa_tagstruct_putu32(t
, idx
);
1785 pa_tagstruct_putu32(t
, source_idx
);
1786 pa_tagstruct_puts(t
, NULL
);
1787 pa_pstream_send_tagstruct(c
->pstream
, t
);
1788 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
);
1793 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
) {
1799 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1801 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1802 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1803 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1804 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1806 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1808 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1809 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1810 pa_tagstruct_puts(t
, sink_name
);
1811 pa_tagstruct_put_boolean(t
, suspend
);
1812 pa_pstream_send_tagstruct(c
->pstream
, t
);
1813 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
);
1818 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1824 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1826 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1827 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1828 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1830 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1832 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1833 pa_tagstruct_putu32(t
, idx
);
1834 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1835 pa_tagstruct_put_boolean(t
, suspend
);
1836 pa_pstream_send_tagstruct(c
->pstream
, t
);
1837 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
);
1842 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
) {
1848 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1850 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1851 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1852 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1853 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1855 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1857 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1858 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1859 pa_tagstruct_puts(t
, source_name
);
1860 pa_tagstruct_put_boolean(t
, suspend
);
1861 pa_pstream_send_tagstruct(c
->pstream
, t
);
1862 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
);
1867 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1873 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1875 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1876 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1877 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1879 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1881 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1882 pa_tagstruct_putu32(t
, idx
);
1883 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1884 pa_tagstruct_put_boolean(t
, suspend
);
1885 pa_pstream_send_tagstruct(c
->pstream
, t
);
1886 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
);