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
;
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)) {
1020 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1021 pa_proplist_free(i
.proplist
);
1025 i
.mute
= (int) mute
;
1026 i
.corked
= (int) corked
;
1029 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1030 cb(o
->context
, &i
, 0, o
->userdata
);
1033 pa_proplist_free(i
.proplist
);
1038 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1039 cb(o
->context
, NULL
, eol
, o
->userdata
);
1043 pa_operation_done(o
);
1044 pa_operation_unref(o
);
1047 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1053 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1056 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1057 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1058 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1060 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1062 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1063 pa_tagstruct_putu32(t
, idx
);
1064 pa_pstream_send_tagstruct(c
->pstream
, t
);
1065 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
);
1070 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
) {
1071 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
);
1074 /*** Source output info ***/
1076 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1077 pa_operation
*o
= userdata
;
1082 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1087 if (command
!= PA_COMMAND_REPLY
) {
1088 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1094 while (!pa_tagstruct_eof(t
)) {
1095 pa_source_output_info i
;
1096 pa_bool_t corked
= FALSE
;
1099 i
.proplist
= pa_proplist_new();
1101 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1102 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1103 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1104 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1105 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1106 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1107 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1108 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1109 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1110 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1111 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1112 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1113 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0)) {
1115 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1116 pa_proplist_free(i
.proplist
);
1120 i
.corked
= (int) corked
;
1123 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1124 cb(o
->context
, &i
, 0, o
->userdata
);
1127 pa_proplist_free(i
.proplist
);
1132 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1133 cb(o
->context
, NULL
, eol
, o
->userdata
);
1137 pa_operation_done(o
);
1138 pa_operation_unref(o
);
1141 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1147 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1150 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1151 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1152 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1154 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1156 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1157 pa_tagstruct_putu32(t
, idx
);
1158 pa_pstream_send_tagstruct(c
->pstream
, t
);
1159 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
);
1164 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1165 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
);
1168 /*** Volume manipulation ***/
1170 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
) {
1176 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1179 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1180 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1181 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1183 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1185 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1186 pa_tagstruct_putu32(t
, idx
);
1187 pa_tagstruct_puts(t
, NULL
);
1188 pa_tagstruct_put_cvolume(t
, volume
);
1189 pa_pstream_send_tagstruct(c
->pstream
, t
);
1190 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
);
1195 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
) {
1201 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1205 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1206 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1207 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1208 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1210 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1212 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1213 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1214 pa_tagstruct_puts(t
, name
);
1215 pa_tagstruct_put_cvolume(t
, volume
);
1216 pa_pstream_send_tagstruct(c
->pstream
, t
);
1217 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
);
1222 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
) {
1228 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1230 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1231 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1233 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1235 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1236 pa_tagstruct_putu32(t
, idx
);
1237 pa_tagstruct_puts(t
, NULL
);
1238 pa_tagstruct_put_boolean(t
, mute
);
1239 pa_pstream_send_tagstruct(c
->pstream
, t
);
1240 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
);
1245 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
) {
1251 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1254 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1255 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1256 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1258 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1260 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1261 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1262 pa_tagstruct_puts(t
, name
);
1263 pa_tagstruct_put_boolean(t
, mute
);
1264 pa_pstream_send_tagstruct(c
->pstream
, t
);
1265 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
);
1270 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
) {
1276 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1279 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1280 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1281 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1282 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1284 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1286 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1287 pa_tagstruct_putu32(t
, idx
);
1288 pa_tagstruct_put_cvolume(t
, volume
);
1289 pa_pstream_send_tagstruct(c
->pstream
, t
);
1290 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
);
1295 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1301 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1303 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1304 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1305 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1306 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1308 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1310 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1311 pa_tagstruct_putu32(t
, idx
);
1312 pa_tagstruct_put_boolean(t
, mute
);
1313 pa_pstream_send_tagstruct(c
->pstream
, t
);
1314 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
);
1319 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
) {
1325 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1328 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1329 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1330 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1332 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1334 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1335 pa_tagstruct_putu32(t
, idx
);
1336 pa_tagstruct_puts(t
, NULL
);
1337 pa_tagstruct_put_cvolume(t
, volume
);
1338 pa_pstream_send_tagstruct(c
->pstream
, t
);
1339 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
);
1344 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
) {
1350 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1354 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1355 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1356 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1357 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1359 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1361 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1362 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1363 pa_tagstruct_puts(t
, name
);
1364 pa_tagstruct_put_cvolume(t
, volume
);
1365 pa_pstream_send_tagstruct(c
->pstream
, t
);
1366 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
);
1371 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
) {
1377 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1379 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1380 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1382 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1384 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1385 pa_tagstruct_putu32(t
, idx
);
1386 pa_tagstruct_puts(t
, NULL
);
1387 pa_tagstruct_put_boolean(t
, mute
);
1388 pa_pstream_send_tagstruct(c
->pstream
, t
);
1389 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
);
1394 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
) {
1400 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1403 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1404 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1405 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1407 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1409 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1410 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1411 pa_tagstruct_puts(t
, name
);
1412 pa_tagstruct_put_boolean(t
, mute
);
1413 pa_pstream_send_tagstruct(c
->pstream
, t
);
1414 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
);
1419 /** Sample Cache **/
1421 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1422 pa_operation
*o
= userdata
;
1427 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1432 if (command
!= PA_COMMAND_REPLY
) {
1433 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1439 while (!pa_tagstruct_eof(t
)) {
1441 pa_bool_t lazy
= FALSE
;
1444 i
.proplist
= pa_proplist_new();
1446 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1447 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1448 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1449 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1450 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1451 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1452 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1453 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1454 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1455 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1457 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1461 i
.lazy
= (int) lazy
;
1464 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1465 cb(o
->context
, &i
, 0, o
->userdata
);
1468 pa_proplist_free(i
.proplist
);
1473 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1474 cb(o
->context
, NULL
, eol
, o
->userdata
);
1478 pa_operation_done(o
);
1479 pa_operation_unref(o
);
1482 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1488 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1491 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1492 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1493 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1495 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1497 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1498 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1499 pa_tagstruct_puts(t
, name
);
1500 pa_pstream_send_tagstruct(c
->pstream
, t
);
1501 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
);
1506 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1512 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1515 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1516 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1517 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1519 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1521 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1522 pa_tagstruct_putu32(t
, idx
);
1523 pa_tagstruct_puts(t
, NULL
);
1524 pa_pstream_send_tagstruct(c
->pstream
, t
);
1525 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
);
1530 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1531 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1534 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1540 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1542 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1543 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1544 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1546 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1548 t
= pa_tagstruct_command(c
, command
, &tag
);
1549 pa_tagstruct_putu32(t
, idx
);
1550 pa_pstream_send_tagstruct(c
->pstream
, t
);
1551 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
);
1556 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1557 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1560 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1561 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1564 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1565 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1568 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1569 pa_operation
*o
= userdata
;
1574 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1579 if (command
!= PA_COMMAND_REPLY
) {
1580 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1583 idx
= PA_INVALID_INDEX
;
1584 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1585 !pa_tagstruct_eof(t
)) {
1586 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1591 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1592 cb(o
->context
, idx
, o
->userdata
);
1597 pa_operation_done(o
);
1598 pa_operation_unref(o
);
1601 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1607 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1609 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1610 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1611 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1613 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1615 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1616 pa_tagstruct_puts(t
, name
);
1617 pa_tagstruct_puts(t
, argument
);
1618 pa_pstream_send_tagstruct(c
->pstream
, t
);
1619 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1624 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1625 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1628 /*** Autoload stuff ***/
1630 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1632 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
) {
1635 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1637 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1640 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1642 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1644 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1646 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1649 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1651 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1653 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1655 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1658 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1660 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
) {
1662 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1664 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1667 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1669 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
) {
1671 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1673 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1676 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1678 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1680 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1682 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1685 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
) {
1691 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1693 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1694 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1695 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1696 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1697 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1699 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1701 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1702 pa_tagstruct_putu32(t
, idx
);
1703 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1704 pa_tagstruct_puts(t
, sink_name
);
1705 pa_pstream_send_tagstruct(c
->pstream
, t
);
1706 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
);
1711 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
) {
1717 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1719 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1720 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1721 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1722 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1723 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1725 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1727 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1728 pa_tagstruct_putu32(t
, idx
);
1729 pa_tagstruct_putu32(t
, sink_idx
);
1730 pa_tagstruct_puts(t
, NULL
);
1731 pa_pstream_send_tagstruct(c
->pstream
, t
);
1732 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
);
1737 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
) {
1743 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1745 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1746 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1747 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1748 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1749 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1751 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1753 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1754 pa_tagstruct_putu32(t
, idx
);
1755 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1756 pa_tagstruct_puts(t
, source_name
);
1757 pa_pstream_send_tagstruct(c
->pstream
, t
);
1758 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
);
1763 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
) {
1769 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1771 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1772 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1773 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1774 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1775 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1777 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1779 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1780 pa_tagstruct_putu32(t
, idx
);
1781 pa_tagstruct_putu32(t
, source_idx
);
1782 pa_tagstruct_puts(t
, NULL
);
1783 pa_pstream_send_tagstruct(c
->pstream
, t
);
1784 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
);
1789 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
) {
1795 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1797 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1798 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1799 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1800 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1802 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1804 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1805 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1806 pa_tagstruct_puts(t
, sink_name
);
1807 pa_tagstruct_put_boolean(t
, suspend
);
1808 pa_pstream_send_tagstruct(c
->pstream
, t
);
1809 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
);
1814 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1820 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1822 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1823 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1824 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1826 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1828 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1829 pa_tagstruct_putu32(t
, idx
);
1830 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1831 pa_tagstruct_put_boolean(t
, suspend
);
1832 pa_pstream_send_tagstruct(c
->pstream
, t
);
1833 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
);
1838 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
) {
1844 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1846 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1847 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1848 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1849 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1851 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1853 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1854 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1855 pa_tagstruct_puts(t
, source_name
);
1856 pa_tagstruct_put_boolean(t
, suspend
);
1857 pa_pstream_send_tagstruct(c
->pstream
, t
);
1858 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
);
1863 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1869 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1871 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1872 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1873 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1875 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1877 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1878 pa_tagstruct_putu32(t
, idx
);
1879 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1880 pa_tagstruct_put_boolean(t
, suspend
);
1881 pa_pstream_send_tagstruct(c
->pstream
, t
);
1882 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
);