2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
7 PulseAudio is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 2.1 of the License,
10 or (at your option) any later version.
12 PulseAudio is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with PulseAudio; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 #include <pulse/context.h>
30 #include <pulse/gccmacro.h>
31 #include <pulse/xmalloc.h>
32 #include <pulse/fork-detect.h>
34 #include <pulsecore/macro.h>
35 #include <pulsecore/core-util.h>
36 #include <pulsecore/pstream-util.h>
39 #include "introspect.h"
43 static void context_stat_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
44 pa_operation
*o
= userdata
;
45 pa_stat_info i
, *p
= &i
;
49 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
56 if (command
!= PA_COMMAND_REPLY
) {
57 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
61 } else if (pa_tagstruct_getu32(t
, &i
.memblock_total
) < 0 ||
62 pa_tagstruct_getu32(t
, &i
.memblock_total_size
) < 0 ||
63 pa_tagstruct_getu32(t
, &i
.memblock_allocated
) < 0 ||
64 pa_tagstruct_getu32(t
, &i
.memblock_allocated_size
) < 0 ||
65 pa_tagstruct_getu32(t
, &i
.scache_size
) < 0 ||
66 !pa_tagstruct_eof(t
)) {
67 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
72 pa_stat_info_cb_t cb
= (pa_stat_info_cb_t
) o
->callback
;
73 cb(o
->context
, p
, o
->userdata
);
78 pa_operation_unref(o
);
81 pa_operation
* pa_context_stat(pa_context
*c
, pa_stat_info_cb_t cb
, void *userdata
) {
82 return pa_context_send_simple_command(c
, PA_COMMAND_STAT
, context_stat_callback
, (pa_operation_cb_t
) cb
, userdata
);
87 static void context_get_server_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
88 pa_operation
*o
= userdata
;
89 pa_server_info i
, *p
= &i
;
93 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
100 if (command
!= PA_COMMAND_REPLY
) {
101 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
105 } else if (pa_tagstruct_gets(t
, &i
.server_name
) < 0 ||
106 pa_tagstruct_gets(t
, &i
.server_version
) < 0 ||
107 pa_tagstruct_gets(t
, &i
.user_name
) < 0 ||
108 pa_tagstruct_gets(t
, &i
.host_name
) < 0 ||
109 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
110 pa_tagstruct_gets(t
, &i
.default_sink_name
) < 0 ||
111 pa_tagstruct_gets(t
, &i
.default_source_name
) < 0 ||
112 pa_tagstruct_getu32(t
, &i
.cookie
) < 0 ||
113 (o
->context
->version
>= 15 &&
114 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0) ||
115 !pa_tagstruct_eof(t
)) {
117 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
121 if (p
&& o
->context
->version
< 15)
122 pa_channel_map_init_extend(&i
.channel_map
, i
.sample_spec
.channels
, PA_CHANNEL_MAP_DEFAULT
);
125 pa_server_info_cb_t cb
= (pa_server_info_cb_t
) o
->callback
;
126 cb(o
->context
, p
, o
->userdata
);
130 pa_operation_done(o
);
131 pa_operation_unref(o
);
134 pa_operation
* pa_context_get_server_info(pa_context
*c
, pa_server_info_cb_t cb
, void *userdata
) {
135 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SERVER_INFO
, context_get_server_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
140 static void context_get_sink_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
141 pa_operation
*o
= userdata
;
148 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
150 /* For safety incase someone use fail: outside the while loop below */
156 if (command
!= PA_COMMAND_REPLY
) {
157 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
163 while (!pa_tagstruct_eof(t
)) {
167 const char *ap
= NULL
;
170 i
.proplist
= pa_proplist_new();
171 i
.base_volume
= PA_VOLUME_NORM
;
172 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
174 state
= PA_SINK_INVALID_STATE
;
175 i
.card
= PA_INVALID_INDEX
;
177 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
178 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
179 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
180 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
181 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
182 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
183 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
184 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
185 pa_tagstruct_getu32(t
, &i
.monitor_source
) < 0 ||
186 pa_tagstruct_gets(t
, &i
.monitor_source_name
) < 0 ||
187 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
188 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
189 pa_tagstruct_getu32(t
, &flags
) < 0 ||
190 (o
->context
->version
>= 13 &&
191 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
192 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
193 (o
->context
->version
>= 15 &&
194 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
195 pa_tagstruct_getu32(t
, &state
) < 0 ||
196 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
197 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
198 (o
->context
->version
>= 16 &&
199 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
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) {
217 i
.ports
[j
] = &i
.ports
[0][j
];
223 if (pa_tagstruct_gets(t
, &ap
) < 0)
227 for (j
= 0; j
< i
.n_ports
; j
++)
228 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
229 i
.active_port
= i
.ports
[j
];
235 if (o
->context
->version
>= 21) {
237 if (pa_tagstruct_getu8(t
, &n_formats
) < 0 || n_formats
< 1)
240 i
.formats
= pa_xnew0(pa_format_info
*, n_formats
);
242 for (j
= 0; j
< n_formats
; j
++) {
244 i
.formats
[j
] = pa_format_info_new();
246 if (pa_tagstruct_get_format_info(t
, i
.formats
[j
]) < 0)
252 i
.flags
= (pa_sink_flags_t
) flags
;
253 i
.state
= (pa_sink_state_t
) state
;
256 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
257 cb(o
->context
, &i
, 0, o
->userdata
);
261 for (j
= 0; j
< i
.n_formats
; j
++)
262 pa_format_info_free(i
.formats
[j
]);
266 pa_xfree(i
.ports
[0]);
269 pa_proplist_free(i
.proplist
);
274 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
275 cb(o
->context
, NULL
, eol
, o
->userdata
);
279 pa_operation_done(o
);
280 pa_operation_unref(o
);
284 pa_assert(i
.proplist
);
286 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
289 for (j
= 0; j
< i
.n_formats
; j
++)
290 pa_format_info_free(i
.formats
[j
]);
294 pa_xfree(i
.ports
[0]);
297 pa_proplist_free(i
.proplist
);
302 pa_operation
* pa_context_get_sink_info_list(pa_context
*c
, pa_sink_info_cb_t cb
, void *userdata
) {
303 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SINK_INFO_LIST
, context_get_sink_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
306 pa_operation
* pa_context_get_sink_info_by_index(pa_context
*c
, uint32_t idx
, pa_sink_info_cb_t cb
, void *userdata
) {
312 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
315 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
316 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
318 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
320 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
321 pa_tagstruct_putu32(t
, idx
);
322 pa_tagstruct_puts(t
, NULL
);
323 pa_pstream_send_tagstruct(c
->pstream
, t
);
324 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
);
329 pa_operation
* pa_context_get_sink_info_by_name(pa_context
*c
, const char *name
, pa_sink_info_cb_t cb
, void *userdata
) {
335 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
338 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
339 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
340 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
342 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
344 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
345 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
346 pa_tagstruct_puts(t
, name
);
347 pa_pstream_send_tagstruct(c
->pstream
, t
);
348 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
);
353 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
) {
359 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
361 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
362 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
363 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
364 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
366 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
368 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
369 pa_tagstruct_putu32(t
, idx
);
370 pa_tagstruct_puts(t
, NULL
);
371 pa_tagstruct_puts(t
, port
);
372 pa_pstream_send_tagstruct(c
->pstream
, t
);
373 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
);
378 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
) {
384 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
386 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
387 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
388 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
389 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
391 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
393 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
394 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
395 pa_tagstruct_puts(t
, name
);
396 pa_tagstruct_puts(t
, port
);
397 pa_pstream_send_tagstruct(c
->pstream
, t
);
398 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
);
403 /*** Source info ***/
405 static void context_get_source_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
406 pa_operation
*o
= userdata
;
411 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
416 if (command
!= PA_COMMAND_REPLY
) {
417 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
423 while (!pa_tagstruct_eof(t
)) {
432 i
.proplist
= pa_proplist_new();
433 i
.base_volume
= PA_VOLUME_NORM
;
434 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
436 state
= PA_SOURCE_INVALID_STATE
;
437 i
.card
= PA_INVALID_INDEX
;
439 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
440 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
441 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
442 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
443 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
444 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
445 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
446 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
447 pa_tagstruct_getu32(t
, &i
.monitor_of_sink
) < 0 ||
448 pa_tagstruct_gets(t
, &i
.monitor_of_sink_name
) < 0 ||
449 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
450 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
451 pa_tagstruct_getu32(t
, &flags
) < 0 ||
452 (o
->context
->version
>= 13 &&
453 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
454 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
455 (o
->context
->version
>= 15 &&
456 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
457 pa_tagstruct_getu32(t
, &state
) < 0 ||
458 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
459 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
460 (o
->context
->version
>= 16 &&
461 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
463 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
464 pa_proplist_free(i
.proplist
);
468 if (o
->context
->version
>= 16) {
470 i
.ports
= pa_xnew(pa_source_port_info
*, i
.n_ports
+1);
471 i
.ports
[0] = pa_xnew(pa_source_port_info
, i
.n_ports
);
473 for (j
= 0; j
< i
.n_ports
; j
++) {
474 if (pa_tagstruct_gets(t
, &i
.ports
[0][j
].name
) < 0 ||
475 pa_tagstruct_gets(t
, &i
.ports
[0][j
].description
) < 0 ||
476 pa_tagstruct_getu32(t
, &i
.ports
[0][j
].priority
) < 0) {
478 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
479 pa_xfree(i
.ports
[0]);
481 pa_proplist_free(i
.proplist
);
485 i
.ports
[j
] = &i
.ports
[0][j
];
491 if (pa_tagstruct_gets(t
, &ap
) < 0) {
492 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
493 pa_xfree(i
.ports
[0]);
495 pa_proplist_free(i
.proplist
);
500 for (j
= 0; j
< i
.n_ports
; j
++)
501 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
502 i
.active_port
= i
.ports
[j
];
509 i
.flags
= (pa_source_flags_t
) flags
;
510 i
.state
= (pa_source_state_t
) state
;
513 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
514 cb(o
->context
, &i
, 0, o
->userdata
);
518 pa_xfree(i
.ports
[0]);
521 pa_proplist_free(i
.proplist
);
526 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
527 cb(o
->context
, NULL
, eol
, o
->userdata
);
531 pa_operation_done(o
);
532 pa_operation_unref(o
);
535 pa_operation
* pa_context_get_source_info_list(pa_context
*c
, pa_source_info_cb_t cb
, void *userdata
) {
536 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SOURCE_INFO_LIST
, context_get_source_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
539 pa_operation
* pa_context_get_source_info_by_index(pa_context
*c
, uint32_t idx
, pa_source_info_cb_t cb
, void *userdata
) {
545 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
548 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
549 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
551 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
553 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
554 pa_tagstruct_putu32(t
, idx
);
555 pa_tagstruct_puts(t
, NULL
);
556 pa_pstream_send_tagstruct(c
->pstream
, t
);
557 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
);
562 pa_operation
* pa_context_get_source_info_by_name(pa_context
*c
, const char *name
, pa_source_info_cb_t cb
, void *userdata
) {
568 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
571 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
572 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
573 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
575 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
577 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
578 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
579 pa_tagstruct_puts(t
, name
);
580 pa_pstream_send_tagstruct(c
->pstream
, t
);
581 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
);
586 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
) {
592 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
594 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
595 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
596 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
597 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
599 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
601 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
602 pa_tagstruct_putu32(t
, idx
);
603 pa_tagstruct_puts(t
, NULL
);
604 pa_tagstruct_puts(t
, port
);
605 pa_pstream_send_tagstruct(c
->pstream
, t
);
606 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
);
611 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
) {
617 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
619 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
620 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
621 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
622 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
624 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
626 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
627 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
628 pa_tagstruct_puts(t
, name
);
629 pa_tagstruct_puts(t
, port
);
630 pa_pstream_send_tagstruct(c
->pstream
, t
);
631 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
);
636 /*** Client info ***/
638 static void context_get_client_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
639 pa_operation
*o
= userdata
;
644 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
649 if (command
!= PA_COMMAND_REPLY
) {
650 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
656 while (!pa_tagstruct_eof(t
)) {
660 i
.proplist
= pa_proplist_new();
662 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
663 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
664 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
665 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
666 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
668 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
669 pa_proplist_free(i
.proplist
);
674 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
675 cb(o
->context
, &i
, 0, o
->userdata
);
678 pa_proplist_free(i
.proplist
);
683 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
684 cb(o
->context
, NULL
, eol
, o
->userdata
);
688 pa_operation_done(o
);
689 pa_operation_unref(o
);
692 pa_operation
* pa_context_get_client_info(pa_context
*c
, uint32_t idx
, pa_client_info_cb_t cb
, void *userdata
) {
698 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
701 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
702 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
703 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
705 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
707 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CLIENT_INFO
, &tag
);
708 pa_tagstruct_putu32(t
, idx
);
709 pa_pstream_send_tagstruct(c
->pstream
, t
);
710 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
);
715 pa_operation
* pa_context_get_client_info_list(pa_context
*c
, pa_client_info_cb_t cb
, void *userdata
) {
716 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CLIENT_INFO_LIST
, context_get_client_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
721 static void context_get_card_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
722 pa_operation
*o
= userdata
;
727 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
732 if (command
!= PA_COMMAND_REPLY
) {
733 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
739 while (!pa_tagstruct_eof(t
)) {
746 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
747 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
748 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
749 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
750 pa_tagstruct_getu32(t
, &i
.n_profiles
) < 0) {
752 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
756 if (i
.n_profiles
> 0) {
757 i
.profiles
= pa_xnew0(pa_card_profile_info
, i
.n_profiles
+1);
759 for (j
= 0; j
< i
.n_profiles
; j
++) {
761 if (pa_tagstruct_gets(t
, &i
.profiles
[j
].name
) < 0 ||
762 pa_tagstruct_gets(t
, &i
.profiles
[j
].description
) < 0 ||
763 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sinks
) < 0 ||
764 pa_tagstruct_getu32(t
, &i
.profiles
[j
].n_sources
) < 0 ||
765 pa_tagstruct_getu32(t
, &i
.profiles
[j
].priority
) < 0) {
767 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
768 pa_xfree(i
.profiles
);
773 /* Terminate with an extra NULL entry, just to make sure */
774 i
.profiles
[j
].name
= NULL
;
775 i
.profiles
[j
].description
= NULL
;
778 i
.proplist
= pa_proplist_new();
780 if (pa_tagstruct_gets(t
, &ap
) < 0 ||
781 pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) {
783 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
784 pa_xfree(i
.profiles
);
785 pa_proplist_free(i
.proplist
);
790 for (j
= 0; j
< i
.n_profiles
; j
++)
791 if (pa_streq(i
.profiles
[j
].name
, ap
)) {
792 i
.active_profile
= &i
.profiles
[j
];
798 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
799 cb(o
->context
, &i
, 0, o
->userdata
);
802 pa_proplist_free(i
.proplist
);
803 pa_xfree(i
.profiles
);
808 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
809 cb(o
->context
, NULL
, eol
, o
->userdata
);
813 pa_operation_done(o
);
814 pa_operation_unref(o
);
817 pa_operation
* pa_context_get_card_info_by_index(pa_context
*c
, uint32_t idx
, pa_card_info_cb_t cb
, void *userdata
) {
823 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
826 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
827 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
828 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
829 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
831 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
833 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
834 pa_tagstruct_putu32(t
, idx
);
835 pa_tagstruct_puts(t
, NULL
);
836 pa_pstream_send_tagstruct(c
->pstream
, t
);
837 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
);
842 pa_operation
* pa_context_get_card_info_by_name(pa_context
*c
, const char*name
, pa_card_info_cb_t cb
, void *userdata
) {
848 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
851 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
852 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
853 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
854 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
856 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
858 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
859 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
860 pa_tagstruct_puts(t
, name
);
861 pa_pstream_send_tagstruct(c
->pstream
, t
);
862 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
);
867 pa_operation
* pa_context_get_card_info_list(pa_context
*c
, pa_card_info_cb_t cb
, void *userdata
) {
868 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
870 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
873 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
) {
879 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
881 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
882 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
883 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
884 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
886 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
888 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
889 pa_tagstruct_putu32(t
, idx
);
890 pa_tagstruct_puts(t
, NULL
);
891 pa_tagstruct_puts(t
, profile
);
892 pa_pstream_send_tagstruct(c
->pstream
, t
);
893 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
);
898 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
) {
904 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
906 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
907 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
908 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
909 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
911 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
913 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
914 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
915 pa_tagstruct_puts(t
, name
);
916 pa_tagstruct_puts(t
, profile
);
917 pa_pstream_send_tagstruct(c
->pstream
, t
);
918 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
);
923 /*** Module info ***/
925 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
926 pa_operation
*o
= userdata
;
931 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
936 if (command
!= PA_COMMAND_REPLY
) {
937 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
943 while (!pa_tagstruct_eof(t
)) {
945 pa_bool_t auto_unload
= FALSE
;
948 i
.proplist
= pa_proplist_new();
950 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
951 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
952 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
953 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
954 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
955 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
956 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
960 i
.auto_unload
= (int) auto_unload
;
963 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
964 cb(o
->context
, &i
, 0, o
->userdata
);
967 pa_proplist_free(i
.proplist
);
972 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
973 cb(o
->context
, NULL
, eol
, o
->userdata
);
977 pa_operation_done(o
);
978 pa_operation_unref(o
);
981 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
987 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
990 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
991 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
992 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
994 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
996 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
997 pa_tagstruct_putu32(t
, idx
);
998 pa_pstream_send_tagstruct(c
->pstream
, t
);
999 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
);
1004 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
1005 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1008 /*** Sink input info ***/
1010 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1011 pa_operation
*o
= userdata
;
1016 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1021 if (command
!= PA_COMMAND_REPLY
) {
1022 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1028 while (!pa_tagstruct_eof(t
)) {
1029 pa_sink_input_info i
;
1030 pa_bool_t mute
= FALSE
, corked
= FALSE
, has_volume
= FALSE
, volume_writable
= TRUE
;
1033 i
.proplist
= pa_proplist_new();
1034 i
.format
= pa_format_info_new();
1036 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1037 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1038 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1039 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1040 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
1041 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1042 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1043 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1044 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1045 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1046 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1047 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1048 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1049 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1050 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0) ||
1051 (o
->context
->version
>= 20 && (pa_tagstruct_get_boolean(t
, &has_volume
) < 0 ||
1052 pa_tagstruct_get_boolean(t
, &volume_writable
) < 0)) ||
1053 (o
->context
->version
>= 21 && pa_tagstruct_get_format_info(t
, i
.format
) < 0)) {
1055 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1056 pa_proplist_free(i
.proplist
);
1057 pa_format_info_free(i
.format
);
1061 i
.mute
= (int) mute
;
1062 i
.corked
= (int) corked
;
1063 i
.has_volume
= (int) has_volume
;
1064 i
.volume_writable
= (int) volume_writable
;
1067 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1068 cb(o
->context
, &i
, 0, o
->userdata
);
1071 pa_proplist_free(i
.proplist
);
1072 pa_format_info_free(i
.format
);
1077 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1078 cb(o
->context
, NULL
, eol
, o
->userdata
);
1082 pa_operation_done(o
);
1083 pa_operation_unref(o
);
1086 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1092 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1095 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1096 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1097 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1099 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1101 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1102 pa_tagstruct_putu32(t
, idx
);
1103 pa_pstream_send_tagstruct(c
->pstream
, t
);
1104 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
);
1109 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
) {
1110 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
);
1113 /*** Source output info ***/
1115 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1116 pa_operation
*o
= userdata
;
1121 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1126 if (command
!= PA_COMMAND_REPLY
) {
1127 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1133 while (!pa_tagstruct_eof(t
)) {
1134 pa_source_output_info i
;
1135 pa_bool_t corked
= FALSE
;
1138 i
.proplist
= pa_proplist_new();
1140 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1141 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1142 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1143 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1144 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1145 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1146 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1147 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1148 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1149 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1150 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1151 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1152 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0)) {
1154 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1155 pa_proplist_free(i
.proplist
);
1159 i
.corked
= (int) corked
;
1162 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1163 cb(o
->context
, &i
, 0, o
->userdata
);
1166 pa_proplist_free(i
.proplist
);
1171 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1172 cb(o
->context
, NULL
, eol
, o
->userdata
);
1176 pa_operation_done(o
);
1177 pa_operation_unref(o
);
1180 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1186 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1189 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1190 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1191 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1193 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1195 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1196 pa_tagstruct_putu32(t
, idx
);
1197 pa_pstream_send_tagstruct(c
->pstream
, t
);
1198 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
);
1203 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1204 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
);
1207 /*** Volume manipulation ***/
1209 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
) {
1215 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1218 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1219 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1220 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1222 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1224 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1225 pa_tagstruct_putu32(t
, idx
);
1226 pa_tagstruct_puts(t
, NULL
);
1227 pa_tagstruct_put_cvolume(t
, volume
);
1228 pa_pstream_send_tagstruct(c
->pstream
, t
);
1229 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
);
1234 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
) {
1240 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1244 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1245 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1246 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1247 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1249 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1251 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1252 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1253 pa_tagstruct_puts(t
, name
);
1254 pa_tagstruct_put_cvolume(t
, volume
);
1255 pa_pstream_send_tagstruct(c
->pstream
, t
);
1256 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
);
1261 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
) {
1267 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1269 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1270 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1272 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1274 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1275 pa_tagstruct_putu32(t
, idx
);
1276 pa_tagstruct_puts(t
, NULL
);
1277 pa_tagstruct_put_boolean(t
, mute
);
1278 pa_pstream_send_tagstruct(c
->pstream
, t
);
1279 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
);
1284 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
) {
1290 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1293 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1294 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1295 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1297 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1299 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1300 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1301 pa_tagstruct_puts(t
, name
);
1302 pa_tagstruct_put_boolean(t
, mute
);
1303 pa_pstream_send_tagstruct(c
->pstream
, t
);
1304 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
);
1309 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
) {
1315 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1318 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1319 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1320 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1321 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1323 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1325 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1326 pa_tagstruct_putu32(t
, idx
);
1327 pa_tagstruct_put_cvolume(t
, volume
);
1328 pa_pstream_send_tagstruct(c
->pstream
, t
);
1329 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
);
1334 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1340 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1342 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1343 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1344 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1345 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1347 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1349 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1350 pa_tagstruct_putu32(t
, idx
);
1351 pa_tagstruct_put_boolean(t
, mute
);
1352 pa_pstream_send_tagstruct(c
->pstream
, t
);
1353 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
);
1358 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
) {
1364 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1367 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1368 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1369 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1371 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1373 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1374 pa_tagstruct_putu32(t
, idx
);
1375 pa_tagstruct_puts(t
, NULL
);
1376 pa_tagstruct_put_cvolume(t
, volume
);
1377 pa_pstream_send_tagstruct(c
->pstream
, t
);
1378 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
);
1383 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
) {
1389 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1393 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1394 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1395 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1396 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1398 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1400 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1401 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1402 pa_tagstruct_puts(t
, name
);
1403 pa_tagstruct_put_cvolume(t
, volume
);
1404 pa_pstream_send_tagstruct(c
->pstream
, t
);
1405 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
);
1410 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
) {
1416 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1418 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1419 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1421 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1423 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1424 pa_tagstruct_putu32(t
, idx
);
1425 pa_tagstruct_puts(t
, NULL
);
1426 pa_tagstruct_put_boolean(t
, mute
);
1427 pa_pstream_send_tagstruct(c
->pstream
, t
);
1428 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
);
1433 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
) {
1439 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1442 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1443 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1444 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1446 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1448 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1449 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1450 pa_tagstruct_puts(t
, name
);
1451 pa_tagstruct_put_boolean(t
, mute
);
1452 pa_pstream_send_tagstruct(c
->pstream
, t
);
1453 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
);
1458 /** Sample Cache **/
1460 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1461 pa_operation
*o
= userdata
;
1466 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1471 if (command
!= PA_COMMAND_REPLY
) {
1472 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1478 while (!pa_tagstruct_eof(t
)) {
1480 pa_bool_t lazy
= FALSE
;
1483 i
.proplist
= pa_proplist_new();
1485 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1486 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1487 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1488 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1489 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1490 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1491 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1492 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1493 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1494 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1496 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1500 i
.lazy
= (int) lazy
;
1503 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1504 cb(o
->context
, &i
, 0, o
->userdata
);
1507 pa_proplist_free(i
.proplist
);
1512 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1513 cb(o
->context
, NULL
, eol
, o
->userdata
);
1517 pa_operation_done(o
);
1518 pa_operation_unref(o
);
1521 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1527 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1530 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1531 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1532 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1534 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1536 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1537 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1538 pa_tagstruct_puts(t
, name
);
1539 pa_pstream_send_tagstruct(c
->pstream
, t
);
1540 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
);
1545 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1551 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1554 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1555 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1556 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1558 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1560 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1561 pa_tagstruct_putu32(t
, idx
);
1562 pa_tagstruct_puts(t
, NULL
);
1563 pa_pstream_send_tagstruct(c
->pstream
, t
);
1564 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
);
1569 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1570 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1573 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1579 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1581 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1582 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1583 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1585 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1587 t
= pa_tagstruct_command(c
, command
, &tag
);
1588 pa_tagstruct_putu32(t
, idx
);
1589 pa_pstream_send_tagstruct(c
->pstream
, t
);
1590 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
);
1595 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1596 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1599 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1600 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1603 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1604 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1607 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1608 pa_operation
*o
= userdata
;
1613 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1618 if (command
!= PA_COMMAND_REPLY
) {
1619 if (pa_context_handle_error(o
->context
, command
, t
, FALSE
) < 0)
1622 idx
= PA_INVALID_INDEX
;
1623 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1624 !pa_tagstruct_eof(t
)) {
1625 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1630 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1631 cb(o
->context
, idx
, o
->userdata
);
1636 pa_operation_done(o
);
1637 pa_operation_unref(o
);
1640 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_cb_t cb
, void *userdata
) {
1646 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1648 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1649 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1650 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1652 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1654 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1655 pa_tagstruct_puts(t
, name
);
1656 pa_tagstruct_puts(t
, argument
);
1657 pa_pstream_send_tagstruct(c
->pstream
, t
);
1658 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1663 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1664 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1667 /*** Autoload stuff ***/
1669 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1671 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
) {
1674 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1676 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1679 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1681 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1683 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1685 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1688 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1690 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1692 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1694 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1697 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1699 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
) {
1701 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1703 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1706 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1708 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
) {
1710 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1712 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1715 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1717 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1719 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1721 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1724 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
) {
1730 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1732 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1733 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1734 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1735 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1736 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
1738 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1740 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1741 pa_tagstruct_putu32(t
, idx
);
1742 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1743 pa_tagstruct_puts(t
, sink_name
);
1744 pa_pstream_send_tagstruct(c
->pstream
, t
);
1745 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
);
1750 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
) {
1756 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1758 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1759 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1760 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1761 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1762 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1764 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1766 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
1767 pa_tagstruct_putu32(t
, idx
);
1768 pa_tagstruct_putu32(t
, sink_idx
);
1769 pa_tagstruct_puts(t
, NULL
);
1770 pa_pstream_send_tagstruct(c
->pstream
, t
);
1771 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
);
1776 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
) {
1782 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1784 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1785 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1786 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1787 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1788 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
1790 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1792 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1793 pa_tagstruct_putu32(t
, idx
);
1794 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1795 pa_tagstruct_puts(t
, source_name
);
1796 pa_pstream_send_tagstruct(c
->pstream
, t
);
1797 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
);
1802 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
) {
1808 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1810 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1811 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1812 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1813 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1814 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1816 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1818 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
1819 pa_tagstruct_putu32(t
, idx
);
1820 pa_tagstruct_putu32(t
, source_idx
);
1821 pa_tagstruct_puts(t
, NULL
);
1822 pa_pstream_send_tagstruct(c
->pstream
, t
);
1823 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
);
1828 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
) {
1834 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1836 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1837 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1838 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1839 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
1841 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1843 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1844 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1845 pa_tagstruct_puts(t
, sink_name
);
1846 pa_tagstruct_put_boolean(t
, suspend
);
1847 pa_pstream_send_tagstruct(c
->pstream
, t
);
1848 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
);
1853 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1859 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1861 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1862 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1863 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1865 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1867 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
1868 pa_tagstruct_putu32(t
, idx
);
1869 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1870 pa_tagstruct_put_boolean(t
, suspend
);
1871 pa_pstream_send_tagstruct(c
->pstream
, t
);
1872 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
);
1877 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
) {
1883 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1885 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1886 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1887 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1888 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
1890 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1892 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1893 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1894 pa_tagstruct_puts(t
, source_name
);
1895 pa_tagstruct_put_boolean(t
, suspend
);
1896 pa_pstream_send_tagstruct(c
->pstream
, t
);
1897 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
);
1902 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
1908 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1910 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1911 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1912 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1914 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1916 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
1917 pa_tagstruct_putu32(t
, idx
);
1918 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
1919 pa_tagstruct_put_boolean(t
, suspend
);
1920 pa_pstream_send_tagstruct(c
->pstream
, t
);
1921 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
);