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
);
205 i
.ports
= pa_xnew(pa_sink_port_info
*, i
.n_ports
+1);
206 i
.ports
[0] = pa_xnew(pa_sink_port_info
, i
.n_ports
);
208 for (j
= 0; j
< i
.n_ports
; j
++) {
209 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
210 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
211 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
213 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
215 pa_xfree(i
.ports
[0]);
216 pa_proplist_free(i
.proplist
);
220 i
.ports
[j
] = &i
.ports
[0][j
];
226 if (pa_tagstruct_gets(t
, &ap
) < 0) {
227 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
228 pa_xfree(i
.ports
[0]);
230 pa_proplist_free(i
.proplist
);
235 for (j
= 0; j
< i
.n_ports
; j
++)
236 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
237 i
.active_port
= i
.ports
[j
];
243 i
.flags
= (pa_sink_flags_t
) flags
;
244 i
.state
= (pa_sink_state_t
) state
;
247 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
248 cb(o
->context
, &i
, 0, o
->userdata
);
251 pa_proplist_free(i
.proplist
);
256 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
257 cb(o
->context
, NULL
, eol
, o
->userdata
);
261 pa_operation_done(o
);
262 pa_operation_unref(o
);
265 pa_operation
* pa_context_get_sink_info_list(pa_context
*c
, pa_sink_info_cb_t cb
, void *userdata
) {
266 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SINK_INFO_LIST
, context_get_sink_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
269 pa_operation
* pa_context_get_sink_info_by_index(pa_context
*c
, uint32_t idx
, pa_sink_info_cb_t cb
, void *userdata
) {
275 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
278 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
279 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
281 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
283 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
284 pa_tagstruct_putu32(t
, idx
);
285 pa_tagstruct_puts(t
, NULL
);
286 pa_pstream_send_tagstruct(c
->pstream
, t
);
287 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
);
292 pa_operation
* pa_context_get_sink_info_by_name(pa_context
*c
, const char *name
, pa_sink_info_cb_t cb
, void *userdata
) {
298 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
301 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
302 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
303 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
305 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
307 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
308 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
309 pa_tagstruct_puts(t
, name
);
310 pa_pstream_send_tagstruct(c
->pstream
, t
);
311 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
);
316 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
) {
322 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
324 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
325 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
326 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
327 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
329 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
331 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
332 pa_tagstruct_putu32(t
, idx
);
333 pa_tagstruct_puts(t
, NULL
);
334 pa_tagstruct_puts(t
, port
);
335 pa_pstream_send_tagstruct(c
->pstream
, t
);
336 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
);
341 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
) {
347 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
349 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
350 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
351 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
352 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
354 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
356 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
357 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
358 pa_tagstruct_puts(t
, name
);
359 pa_tagstruct_puts(t
, port
);
360 pa_pstream_send_tagstruct(c
->pstream
, t
);
361 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
);
366 /*** Source info ***/
368 static void context_get_source_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
369 pa_operation
*o
= userdata
;
374 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
379 if (command
!= PA_COMMAND_REPLY
) {
380 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
386 while (!pa_tagstruct_eof(t
)) {
395 i
.proplist
= pa_proplist_new();
396 i
.base_volume
= PA_VOLUME_NORM
;
397 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
399 state
= PA_SOURCE_INVALID_STATE
;
400 i
.card
= PA_INVALID_INDEX
;
402 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
403 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
404 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
405 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
406 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
407 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
408 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
409 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
410 pa_tagstruct_getu32(t
, &i
.monitor_of_sink
) < 0 ||
411 pa_tagstruct_gets(t
, &i
.monitor_of_sink_name
) < 0 ||
412 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
413 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
414 pa_tagstruct_getu32(t
, &flags
) < 0 ||
415 (o
->context
->version
>= 13 &&
416 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
417 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
418 (o
->context
->version
>= 15 &&
419 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
420 pa_tagstruct_getu32(t
, &state
) < 0 ||
421 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
422 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
423 (o
->context
->version
>= 16 &&
424 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
426 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
427 pa_proplist_free(i
.proplist
);
432 i
.ports
= pa_xnew(pa_source_port_info
*, i
.n_ports
+1);
433 i
.ports
[0] = pa_xnew(pa_source_port_info
, i
.n_ports
);
435 for (j
= 0; j
< i
.n_ports
; j
++) {
436 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
437 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
438 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
440 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
441 pa_xfree(i
.ports
[0]);
443 pa_proplist_free(i
.proplist
);
447 i
.ports
[j
] = &i
.ports
[0][j
];
453 if (pa_tagstruct_gets(t
, &ap
) < 0) {
454 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
455 pa_xfree(i
.ports
[0]);
457 pa_proplist_free(i
.proplist
);
462 for (j
= 0; j
< i
.n_ports
; j
++)
463 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
464 i
.active_port
= i
.ports
[j
];
470 i
.flags
= (pa_source_flags_t
) flags
;
471 i
.state
= (pa_source_state_t
) state
;
474 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
475 cb(o
->context
, &i
, 0, o
->userdata
);
478 pa_proplist_free(i
.proplist
);
483 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
484 cb(o
->context
, NULL
, eol
, o
->userdata
);
488 pa_operation_done(o
);
489 pa_operation_unref(o
);
492 pa_operation
* pa_context_get_source_info_list(pa_context
*c
, pa_source_info_cb_t cb
, void *userdata
) {
493 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SOURCE_INFO_LIST
, context_get_source_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
496 pa_operation
* pa_context_get_source_info_by_index(pa_context
*c
, uint32_t idx
, pa_source_info_cb_t cb
, void *userdata
) {
502 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
505 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
506 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
508 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
510 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
511 pa_tagstruct_putu32(t
, idx
);
512 pa_tagstruct_puts(t
, NULL
);
513 pa_pstream_send_tagstruct(c
->pstream
, t
);
514 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
);
519 pa_operation
* pa_context_get_source_info_by_name(pa_context
*c
, const char *name
, pa_source_info_cb_t cb
, void *userdata
) {
525 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
528 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
529 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
530 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
532 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
534 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
535 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
536 pa_tagstruct_puts(t
, name
);
537 pa_pstream_send_tagstruct(c
->pstream
, t
);
538 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
);
543 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
) {
549 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
551 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
552 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
553 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
554 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
556 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
558 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
559 pa_tagstruct_putu32(t
, idx
);
560 pa_tagstruct_puts(t
, NULL
);
561 pa_tagstruct_puts(t
, port
);
562 pa_pstream_send_tagstruct(c
->pstream
, t
);
563 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
);
568 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
) {
574 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
576 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
577 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
578 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
579 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
581 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
583 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
584 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
585 pa_tagstruct_puts(t
, name
);
586 pa_tagstruct_puts(t
, port
);
587 pa_pstream_send_tagstruct(c
->pstream
, t
);
588 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
);
593 /*** Client info ***/
595 static void context_get_client_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
596 pa_operation
*o
= userdata
;
601 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
606 if (command
!= PA_COMMAND_REPLY
) {
607 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
613 while (!pa_tagstruct_eof(t
)) {
617 i
.proplist
= pa_proplist_new();
619 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
620 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
621 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
622 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
623 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
625 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
626 pa_proplist_free(i
.proplist
);
631 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
632 cb(o
->context
, &i
, 0, o
->userdata
);
635 pa_proplist_free(i
.proplist
);
640 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
641 cb(o
->context
, NULL
, eol
, o
->userdata
);
645 pa_operation_done(o
);
646 pa_operation_unref(o
);
649 pa_operation
* pa_context_get_client_info(pa_context
*c
, uint32_t idx
, pa_client_info_cb_t cb
, void *userdata
) {
655 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
658 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
659 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
660 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
662 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
664 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CLIENT_INFO
, &tag
);
665 pa_tagstruct_putu32(t
, idx
);
666 pa_pstream_send_tagstruct(c
->pstream
, t
);
667 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
);
672 pa_operation
* pa_context_get_client_info_list(pa_context
*c
, pa_client_info_cb_t cb
, void *userdata
) {
673 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CLIENT_INFO_LIST
, context_get_client_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
678 static void context_get_card_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
679 pa_operation
*o
= userdata
;
684 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
689 if (command
!= PA_COMMAND_REPLY
) {
690 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
696 while (!pa_tagstruct_eof(t
)) {
703 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
704 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
705 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
706 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
707 pa_tagstruct_getu32(t
, &i
.n_profiles
) < 0) {
709 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
713 if (i
.n_profiles
> 0) {
714 i
.profiles
= pa_xnew0(pa_card_profile_info
, i
.n_profiles
+1);
716 for (j
= 0; j
< i
.n_profiles
; j
++) {
718 if (pa_tagstruct_gets(t
, &i
.profiles
[j
].name
) < 0 ||
719 pa_tagstruct_gets(t
, &i
.profiles
[j
].description
) < 0 ||
720 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sinks
) < 0 ||
721 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sources
) < 0 ||
722 pa_tagstruct_getu32(t
, &i
.profiles
[j
].priority
) < 0) {
724 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
725 pa_xfree(i
.profiles
);
730 /* Terminate with an extra NULL entry, just to make sure */
731 i
.profiles
[j
].name
= NULL
;
732 i
.profiles
[j
].description
= NULL
;
735 i
.proplist
= pa_proplist_new();
737 if (pa_tagstruct_gets(t
, &ap
) < 0 ||
738 pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) {
740 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
741 pa_xfree(i
.profiles
);
742 pa_proplist_free(i
.proplist
);
747 for (j
= 0; j
< i
.n_profiles
; j
++)
748 if (pa_streq(i
.profiles
[j
].name
, ap
)) {
749 i
.active_profile
= &i
.profiles
[j
];
755 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
756 cb(o
->context
, &i
, 0, o
->userdata
);
759 pa_proplist_free(i
.proplist
);
760 pa_xfree(i
.profiles
);
765 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
766 cb(o
->context
, NULL
, eol
, o
->userdata
);
770 pa_operation_done(o
);
771 pa_operation_unref(o
);
774 pa_operation
* pa_context_get_card_info_by_index(pa_context
*c
, uint32_t idx
, pa_card_info_cb_t cb
, void *userdata
) {
780 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
783 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
784 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
785 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
786 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
788 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
790 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
791 pa_tagstruct_putu32(t
, idx
);
792 pa_tagstruct_puts(t
, NULL
);
793 pa_pstream_send_tagstruct(c
->pstream
, t
);
794 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
);
799 pa_operation
* pa_context_get_card_info_by_name(pa_context
*c
, const char*name
, pa_card_info_cb_t cb
, void *userdata
) {
805 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
808 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
809 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
810 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
811 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
813 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
815 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
816 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
817 pa_tagstruct_puts(t
, name
);
818 pa_pstream_send_tagstruct(c
->pstream
, t
);
819 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
);
824 pa_operation
* pa_context_get_card_info_list(pa_context
*c
, pa_card_info_cb_t cb
, void *userdata
) {
825 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
828 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
) {
834 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
836 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
837 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
838 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
839 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
841 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
843 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
844 pa_tagstruct_putu32(t
, idx
);
845 pa_tagstruct_puts(t
, NULL
);
846 pa_tagstruct_puts(t
, profile
);
847 pa_pstream_send_tagstruct(c
->pstream
, t
);
848 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
);
853 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
) {
859 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
861 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
862 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
863 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
864 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
866 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
868 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
869 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
870 pa_tagstruct_puts(t
, name
);
871 pa_tagstruct_puts(t
, profile
);
872 pa_pstream_send_tagstruct(c
->pstream
, t
);
873 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
);
878 /*** Module info ***/
880 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
881 pa_operation
*o
= userdata
;
886 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
891 if (command
!= PA_COMMAND_REPLY
) {
892 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
898 while (!pa_tagstruct_eof(t
)) {
900 pa_bool_t auto_unload
= FALSE
;
903 i
.proplist
= pa_proplist_new();
905 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
906 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
907 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
908 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
909 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
910 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
911 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
915 i
.auto_unload
= (int) auto_unload
;
918 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
919 cb(o
->context
, &i
, 0, o
->userdata
);
922 pa_proplist_free(i
.proplist
);
927 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
928 cb(o
->context
, NULL
, eol
, o
->userdata
);
932 pa_operation_done(o
);
933 pa_operation_unref(o
);
936 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
942 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
945 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
946 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
947 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
949 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
951 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
952 pa_tagstruct_putu32(t
, idx
);
953 pa_pstream_send_tagstruct(c
->pstream
, t
);
954 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
);
959 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
960 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
963 /*** Sink input info ***/
965 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
966 pa_operation
*o
= userdata
;
971 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
976 if (command
!= PA_COMMAND_REPLY
) {
977 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
983 while (!pa_tagstruct_eof(t
)) {
984 pa_sink_input_info i
;
985 pa_bool_t mute
= FALSE
;
988 i
.proplist
= pa_proplist_new();
990 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
991 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
992 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
993 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
994 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
995 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
996 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
997 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
998 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
999 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1000 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1001 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1002 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1003 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1005 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1006 pa_proplist_free(i
.proplist
);
1010 i
.mute
= (int) mute
;
1013 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1014 cb(o
->context
, &i
, 0, o
->userdata
);
1017 pa_proplist_free(i
.proplist
);
1022 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1023 cb(o
->context
, NULL
, eol
, o
->userdata
);
1027 pa_operation_done(o
);
1028 pa_operation_unref(o
);
1031 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1037 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1040 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1041 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1042 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1044 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1046 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1047 pa_tagstruct_putu32(t
, idx
);
1048 pa_pstream_send_tagstruct(c
->pstream
, t
);
1049 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
);
1054 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
) {
1055 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
);
1058 /*** Source output info ***/
1060 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1061 pa_operation
*o
= userdata
;
1066 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1071 if (command
!= PA_COMMAND_REPLY
) {
1072 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1078 while (!pa_tagstruct_eof(t
)) {
1079 pa_source_output_info i
;
1082 i
.proplist
= pa_proplist_new();
1084 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1085 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1086 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1087 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1088 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1089 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1090 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1091 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1092 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1093 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1094 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1095 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1097 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1098 pa_proplist_free(i
.proplist
);
1103 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1104 cb(o
->context
, &i
, 0, o
->userdata
);
1107 pa_proplist_free(i
.proplist
);
1112 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1113 cb(o
->context
, NULL
, eol
, o
->userdata
);
1117 pa_operation_done(o
);
1118 pa_operation_unref(o
);
1121 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1127 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1130 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1131 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1132 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1134 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1136 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1137 pa_tagstruct_putu32(t
, idx
);
1138 pa_pstream_send_tagstruct(c
->pstream
, t
);
1139 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
);
1144 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1145 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
);
1148 /*** Volume manipulation ***/
1150 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
) {
1156 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1159 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1160 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1161 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1163 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1165 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1166 pa_tagstruct_putu32(t
, idx
);
1167 pa_tagstruct_puts(t
, NULL
);
1168 pa_tagstruct_put_cvolume(t
, volume
);
1169 pa_pstream_send_tagstruct(c
->pstream
, t
);
1170 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
);
1175 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
) {
1181 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1185 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1186 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1187 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1188 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1190 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1192 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1193 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1194 pa_tagstruct_puts(t
, name
);
1195 pa_tagstruct_put_cvolume(t
, volume
);
1196 pa_pstream_send_tagstruct(c
->pstream
, t
);
1197 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
);
1202 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
) {
1208 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1210 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1211 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1213 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1215 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1216 pa_tagstruct_putu32(t
, idx
);
1217 pa_tagstruct_puts(t
, NULL
);
1218 pa_tagstruct_put_boolean(t
, mute
);
1219 pa_pstream_send_tagstruct(c
->pstream
, t
);
1220 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
);
1225 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
) {
1231 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
);
1236 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1238 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1240 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1241 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1242 pa_tagstruct_puts(t
, name
);
1243 pa_tagstruct_put_boolean(t
, mute
);
1244 pa_pstream_send_tagstruct(c
->pstream
, t
);
1245 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
);
1250 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
) {
1256 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1259 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1260 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1261 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1262 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1264 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1266 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1267 pa_tagstruct_putu32(t
, idx
);
1268 pa_tagstruct_put_cvolume(t
, volume
);
1269 pa_pstream_send_tagstruct(c
->pstream
, t
);
1270 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
);
1275 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1281 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
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1288 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1290 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1291 pa_tagstruct_putu32(t
, idx
);
1292 pa_tagstruct_put_boolean(t
, mute
);
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_source_volume_by_index(pa_context
*c
, uint32_t idx
, const pa_cvolume
*volume
, pa_context_success_cb_t cb
, void *userdata
) {
1305 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1308 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1309 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1310 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1312 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1314 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1315 pa_tagstruct_putu32(t
, idx
);
1316 pa_tagstruct_puts(t
, NULL
);
1317 pa_tagstruct_put_cvolume(t
, volume
);
1318 pa_pstream_send_tagstruct(c
->pstream
, t
);
1319 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
);
1324 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
) {
1330 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1334 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1335 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1336 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1337 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1339 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1341 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1342 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1343 pa_tagstruct_puts(t
, name
);
1344 pa_tagstruct_put_cvolume(t
, volume
);
1345 pa_pstream_send_tagstruct(c
->pstream
, t
);
1346 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
);
1351 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
) {
1357 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1359 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1360 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1362 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1364 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1365 pa_tagstruct_putu32(t
, idx
);
1366 pa_tagstruct_puts(t
, NULL
);
1367 pa_tagstruct_put_boolean(t
, mute
);
1368 pa_pstream_send_tagstruct(c
->pstream
, t
);
1369 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
);
1374 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
) {
1380 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
);
1385 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1387 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1389 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1390 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1391 pa_tagstruct_puts(t
, name
);
1392 pa_tagstruct_put_boolean(t
, mute
);
1393 pa_pstream_send_tagstruct(c
->pstream
, t
);
1394 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
);
1399 /** Sample Cache **/
1401 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1402 pa_operation
*o
= userdata
;
1407 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1412 if (command
!= PA_COMMAND_REPLY
) {
1413 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1419 while (!pa_tagstruct_eof(t
)) {
1421 pa_bool_t lazy
= FALSE
;
1424 i
.proplist
= pa_proplist_new();
1426 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1427 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1428 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1429 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1430 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1431 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1432 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1433 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1434 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1435 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1437 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1441 i
.lazy
= (int) lazy
;
1444 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1445 cb(o
->context
, &i
, 0, o
->userdata
);
1448 pa_proplist_free(i
.proplist
);
1453 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1454 cb(o
->context
, NULL
, eol
, o
->userdata
);
1458 pa_operation_done(o
);
1459 pa_operation_unref(o
);
1462 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1468 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1471 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1472 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1473 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1475 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1477 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1478 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1479 pa_tagstruct_puts(t
, name
);
1480 pa_pstream_send_tagstruct(c
->pstream
, t
);
1481 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
);
1486 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, 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
, idx
!= PA_INVALID_INDEX
, 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
, idx
);
1503 pa_tagstruct_puts(t
, NULL
);
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_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1511 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1514 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1520 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1522 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1523 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1524 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1526 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1528 t
= pa_tagstruct_command(c
, command
, &tag
);
1529 pa_tagstruct_putu32(t
, idx
);
1530 pa_pstream_send_tagstruct(c
->pstream
, t
);
1531 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
);
1536 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1537 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1540 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1541 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1544 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1545 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1548 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1549 pa_operation
*o
= userdata
;
1554 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1559 if (command
!= PA_COMMAND_REPLY
) {
1560 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1563 idx
= PA_INVALID_INDEX
;
1564 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1565 !pa_tagstruct_eof(t
)) {
1566 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1571 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1572 cb(o
->context
, idx
, o
->userdata
);
1577 pa_operation_done(o
);
1578 pa_operation_unref(o
);
1581 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1587 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1589 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1590 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1591 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1593 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1595 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1596 pa_tagstruct_puts(t
, name
);
1597 pa_tagstruct_puts(t
, argument
);
1598 pa_pstream_send_tagstruct(c
->pstream
, t
);
1599 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1604 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1605 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1608 /*** Autoload stuff ***/
1610 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1612 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
) {
1615 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1617 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1620 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1622 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1624 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1626 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1629 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1631 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1633 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1635 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1638 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1640 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
) {
1642 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1644 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1647 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1649 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
) {
1651 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1653 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1656 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1658 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1660 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1662 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1665 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
) {
1671 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1673 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1674 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1675 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1676 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1677 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1679 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1681 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1682 pa_tagstruct_putu32(t
, idx
);
1683 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1684 pa_tagstruct_puts(t
, sink_name
);
1685 pa_pstream_send_tagstruct(c
->pstream
, t
);
1686 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
);
1691 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
) {
1697 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1699 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1700 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1701 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1702 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1703 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1705 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1707 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1708 pa_tagstruct_putu32(t
, idx
);
1709 pa_tagstruct_putu32(t
, sink_idx
);
1710 pa_tagstruct_puts(t
, NULL
);
1711 pa_pstream_send_tagstruct(c
->pstream
, t
);
1712 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
);
1717 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
) {
1723 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1725 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1726 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1727 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1728 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1729 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1731 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1733 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1734 pa_tagstruct_putu32(t
, idx
);
1735 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1736 pa_tagstruct_puts(t
, source_name
);
1737 pa_pstream_send_tagstruct(c
->pstream
, t
);
1738 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
);
1743 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
) {
1749 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1751 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1752 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1753 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1754 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1755 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1757 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1759 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1760 pa_tagstruct_putu32(t
, idx
);
1761 pa_tagstruct_putu32(t
, source_idx
);
1762 pa_tagstruct_puts(t
, NULL
);
1763 pa_pstream_send_tagstruct(c
->pstream
, t
);
1764 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
);
1769 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
) {
1775 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1777 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1778 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1779 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1780 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1782 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1784 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1785 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1786 pa_tagstruct_puts(t
, sink_name
);
1787 pa_tagstruct_put_boolean(t
, suspend
);
1788 pa_pstream_send_tagstruct(c
->pstream
, t
);
1789 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
);
1794 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1800 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1802 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1803 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1804 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
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
, idx
);
1810 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
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_source_by_name(pa_context
*c
, const char *source_name
, 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
);
1829 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1831 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1833 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1834 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1835 pa_tagstruct_puts(t
, source_name
);
1836 pa_tagstruct_put_boolean(t
, suspend
);
1837 pa_pstream_send_tagstruct(c
->pstream
, t
);
1838 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
);
1843 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1849 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1851 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1852 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1853 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
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
, idx
);
1859 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
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
);