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
27 #include <pulse/context.h>
28 #include <pulse/direction.h>
29 #include <pulse/xmalloc.h>
30 #include <pulse/fork-detect.h>
32 #include <pulsecore/macro.h>
33 #include <pulsecore/core-util.h>
34 #include <pulsecore/pstream-util.h>
37 #include "introspect.h"
41 static void context_stat_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
42 pa_operation
*o
= userdata
;
43 pa_stat_info i
, *p
= &i
;
47 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
54 if (command
!= PA_COMMAND_REPLY
) {
55 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
59 } else if (pa_tagstruct_getu32(t
, &i
.memblock_total
) < 0 ||
60 pa_tagstruct_getu32(t
, &i
.memblock_total_size
) < 0 ||
61 pa_tagstruct_getu32(t
, &i
.memblock_allocated
) < 0 ||
62 pa_tagstruct_getu32(t
, &i
.memblock_allocated_size
) < 0 ||
63 pa_tagstruct_getu32(t
, &i
.scache_size
) < 0 ||
64 !pa_tagstruct_eof(t
)) {
65 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
70 pa_stat_info_cb_t cb
= (pa_stat_info_cb_t
) o
->callback
;
71 cb(o
->context
, p
, o
->userdata
);
76 pa_operation_unref(o
);
79 pa_operation
* pa_context_stat(pa_context
*c
, pa_stat_info_cb_t cb
, void *userdata
) {
80 return pa_context_send_simple_command(c
, PA_COMMAND_STAT
, context_stat_callback
, (pa_operation_cb_t
) cb
, userdata
);
85 static void context_get_server_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
86 pa_operation
*o
= userdata
;
87 pa_server_info i
, *p
= &i
;
91 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
98 if (command
!= PA_COMMAND_REPLY
) {
99 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
103 } else if (pa_tagstruct_gets(t
, &i
.server_name
) < 0 ||
104 pa_tagstruct_gets(t
, &i
.server_version
) < 0 ||
105 pa_tagstruct_gets(t
, &i
.user_name
) < 0 ||
106 pa_tagstruct_gets(t
, &i
.host_name
) < 0 ||
107 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
108 pa_tagstruct_gets(t
, &i
.default_sink_name
) < 0 ||
109 pa_tagstruct_gets(t
, &i
.default_source_name
) < 0 ||
110 pa_tagstruct_getu32(t
, &i
.cookie
) < 0 ||
111 (o
->context
->version
>= 15 &&
112 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0) ||
113 !pa_tagstruct_eof(t
)) {
115 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
119 if (p
&& o
->context
->version
< 15)
120 pa_channel_map_init_extend(&i
.channel_map
, i
.sample_spec
.channels
, PA_CHANNEL_MAP_DEFAULT
);
123 pa_server_info_cb_t cb
= (pa_server_info_cb_t
) o
->callback
;
124 cb(o
->context
, p
, o
->userdata
);
128 pa_operation_done(o
);
129 pa_operation_unref(o
);
132 pa_operation
* pa_context_get_server_info(pa_context
*c
, pa_server_info_cb_t cb
, void *userdata
) {
133 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SERVER_INFO
, context_get_server_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
138 static void context_get_sink_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
139 pa_operation
*o
= userdata
;
146 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
148 /* For safety in case someone use fail: outside the while loop below */
154 if (command
!= PA_COMMAND_REPLY
) {
155 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
161 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
)))) {
202 if (o
->context
->version
>= 16) {
204 i
.ports
= pa_xnew(pa_sink_port_info
*, i
.n_ports
+1);
205 i
.ports
[0] = pa_xnew(pa_sink_port_info
, i
.n_ports
);
207 for (j
= 0; j
< i
.n_ports
; j
++) {
208 i
.ports
[j
] = &i
.ports
[0][j
];
210 if (pa_tagstruct_gets(t
, &i
.ports
[j
]->name
) < 0 ||
211 pa_tagstruct_gets(t
, &i
.ports
[j
]->description
) < 0 ||
212 pa_tagstruct_getu32(t
, &i
.ports
[j
]->priority
) < 0) {
217 i
.ports
[j
]->available
= PA_PORT_AVAILABLE_UNKNOWN
;
218 if (o
->context
->version
>= 24) {
220 if (pa_tagstruct_getu32(t
, &av
) < 0 || av
> PA_PORT_AVAILABLE_YES
)
222 i
.ports
[j
]->available
= av
;
229 if (pa_tagstruct_gets(t
, &ap
) < 0)
233 for (j
= 0; j
< i
.n_ports
; j
++)
234 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
235 i
.active_port
= i
.ports
[j
];
241 if (o
->context
->version
>= 21) {
243 if (pa_tagstruct_getu8(t
, &n_formats
) < 0 || n_formats
< 1)
246 i
.formats
= pa_xnew0(pa_format_info
*, n_formats
);
248 for (j
= 0; j
< n_formats
; j
++) {
250 i
.formats
[j
] = pa_format_info_new();
252 if (pa_tagstruct_get_format_info(t
, i
.formats
[j
]) < 0)
258 i
.flags
= (pa_sink_flags_t
) flags
;
259 i
.state
= (pa_sink_state_t
) state
;
262 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
263 cb(o
->context
, &i
, 0, o
->userdata
);
267 for (j
= 0; j
< i
.n_formats
; j
++)
268 pa_format_info_free(i
.formats
[j
]);
272 pa_xfree(i
.ports
[0]);
275 pa_proplist_free(i
.proplist
);
280 pa_sink_info_cb_t cb
= (pa_sink_info_cb_t
) o
->callback
;
281 cb(o
->context
, NULL
, eol
, o
->userdata
);
285 pa_operation_done(o
);
286 pa_operation_unref(o
);
290 pa_assert(i
.proplist
);
292 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
295 for (j
= 0; j
< i
.n_formats
; j
++)
296 pa_format_info_free(i
.formats
[j
]);
300 pa_xfree(i
.ports
[0]);
303 pa_proplist_free(i
.proplist
);
308 pa_operation
* pa_context_get_sink_info_list(pa_context
*c
, pa_sink_info_cb_t cb
, void *userdata
) {
309 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SINK_INFO_LIST
, context_get_sink_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
312 pa_operation
* pa_context_get_sink_info_by_index(pa_context
*c
, uint32_t idx
, pa_sink_info_cb_t cb
, void *userdata
) {
318 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
321 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
322 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
324 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
326 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
327 pa_tagstruct_putu32(t
, idx
);
328 pa_tagstruct_puts(t
, NULL
);
329 pa_pstream_send_tagstruct(c
->pstream
, t
);
330 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
);
335 pa_operation
* pa_context_get_sink_info_by_name(pa_context
*c
, const char *name
, pa_sink_info_cb_t cb
, void *userdata
) {
341 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
344 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
345 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
346 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
348 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
350 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INFO
, &tag
);
351 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
352 pa_tagstruct_puts(t
, name
);
353 pa_pstream_send_tagstruct(c
->pstream
, t
);
354 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
);
359 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
) {
365 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
367 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
368 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
369 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
370 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
372 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
374 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
375 pa_tagstruct_putu32(t
, idx
);
376 pa_tagstruct_puts(t
, NULL
);
377 pa_tagstruct_puts(t
, port
);
378 pa_pstream_send_tagstruct(c
->pstream
, t
);
379 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
);
384 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
) {
390 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
392 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
393 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
394 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
395 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
397 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
399 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_PORT
, &tag
);
400 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
401 pa_tagstruct_puts(t
, name
);
402 pa_tagstruct_puts(t
, port
);
403 pa_pstream_send_tagstruct(c
->pstream
, t
);
404 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
);
409 /*** Source info ***/
411 static void context_get_source_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
412 pa_operation
*o
= userdata
;
419 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
421 /* For safety in case someone use fail: outside the while loop below */
427 if (command
!= PA_COMMAND_REPLY
) {
428 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
434 while (!pa_tagstruct_eof(t
)) {
441 i
.proplist
= pa_proplist_new();
442 i
.base_volume
= PA_VOLUME_NORM
;
443 i
.n_volume_steps
= PA_VOLUME_NORM
+1;
445 state
= PA_SOURCE_INVALID_STATE
;
446 i
.card
= PA_INVALID_INDEX
;
448 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
449 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
450 pa_tagstruct_gets(t
, &i
.description
) < 0 ||
451 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
452 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
453 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
454 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
455 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
456 pa_tagstruct_getu32(t
, &i
.monitor_of_sink
) < 0 ||
457 pa_tagstruct_gets(t
, &i
.monitor_of_sink_name
) < 0 ||
458 pa_tagstruct_get_usec(t
, &i
.latency
) < 0 ||
459 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
460 pa_tagstruct_getu32(t
, &flags
) < 0 ||
461 (o
->context
->version
>= 13 &&
462 (pa_tagstruct_get_proplist(t
, i
.proplist
) < 0 ||
463 pa_tagstruct_get_usec(t
, &i
.configured_latency
) < 0)) ||
464 (o
->context
->version
>= 15 &&
465 (pa_tagstruct_get_volume(t
, &i
.base_volume
) < 0 ||
466 pa_tagstruct_getu32(t
, &state
) < 0 ||
467 pa_tagstruct_getu32(t
, &i
.n_volume_steps
) < 0 ||
468 pa_tagstruct_getu32(t
, &i
.card
) < 0)) ||
469 (o
->context
->version
>= 16 &&
470 (pa_tagstruct_getu32(t
, &i
.n_ports
)))) {
475 if (o
->context
->version
>= 16) {
477 i
.ports
= pa_xnew(pa_source_port_info
*, i
.n_ports
+1);
478 i
.ports
[0] = pa_xnew(pa_source_port_info
, i
.n_ports
);
480 for (j
= 0; j
< i
.n_ports
; j
++) {
481 i
.ports
[j
] = &i
.ports
[0][j
];
483 if (pa_tagstruct_gets(t
, &i
.ports
[j
]->name
) < 0 ||
484 pa_tagstruct_gets(t
, &i
.ports
[j
]->description
) < 0 ||
485 pa_tagstruct_getu32(t
, &i
.ports
[j
]->priority
) < 0) {
490 i
.ports
[j
]->available
= PA_PORT_AVAILABLE_UNKNOWN
;
491 if (o
->context
->version
>= 24) {
493 if (pa_tagstruct_getu32(t
, &av
) < 0 || av
> PA_PORT_AVAILABLE_YES
)
495 i
.ports
[j
]->available
= av
;
502 if (pa_tagstruct_gets(t
, &ap
) < 0)
506 for (j
= 0; j
< i
.n_ports
; j
++)
507 if (pa_streq(i
.ports
[j
]->name
, ap
)) {
508 i
.active_port
= i
.ports
[j
];
514 if (o
->context
->version
>= 22) {
516 if (pa_tagstruct_getu8(t
, &n_formats
) < 0 || n_formats
< 1)
519 i
.formats
= pa_xnew0(pa_format_info
*, n_formats
);
521 for (j
= 0; j
< n_formats
; j
++) {
523 i
.formats
[j
] = pa_format_info_new();
525 if (pa_tagstruct_get_format_info(t
, i
.formats
[j
]) < 0)
531 i
.flags
= (pa_source_flags_t
) flags
;
532 i
.state
= (pa_source_state_t
) state
;
535 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
536 cb(o
->context
, &i
, 0, o
->userdata
);
540 for (j
= 0; j
< i
.n_formats
; j
++)
541 pa_format_info_free(i
.formats
[j
]);
545 pa_xfree(i
.ports
[0]);
548 pa_proplist_free(i
.proplist
);
553 pa_source_info_cb_t cb
= (pa_source_info_cb_t
) o
->callback
;
554 cb(o
->context
, NULL
, eol
, o
->userdata
);
558 pa_operation_done(o
);
559 pa_operation_unref(o
);
563 pa_assert(i
.proplist
);
565 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
568 for (j
= 0; j
< i
.n_formats
; j
++)
569 pa_format_info_free(i
.formats
[j
]);
573 pa_xfree(i
.ports
[0]);
576 pa_proplist_free(i
.proplist
);
581 pa_operation
* pa_context_get_source_info_list(pa_context
*c
, pa_source_info_cb_t cb
, void *userdata
) {
582 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SOURCE_INFO_LIST
, context_get_source_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
585 pa_operation
* pa_context_get_source_info_by_index(pa_context
*c
, uint32_t idx
, pa_source_info_cb_t cb
, void *userdata
) {
591 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
);
597 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
599 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
600 pa_tagstruct_putu32(t
, idx
);
601 pa_tagstruct_puts(t
, NULL
);
602 pa_pstream_send_tagstruct(c
->pstream
, t
);
603 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
);
608 pa_operation
* pa_context_get_source_info_by_name(pa_context
*c
, const char *name
, pa_source_info_cb_t cb
, void *userdata
) {
614 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
617 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
618 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
619 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
621 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
623 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_INFO
, &tag
);
624 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
625 pa_tagstruct_puts(t
, name
);
626 pa_pstream_send_tagstruct(c
->pstream
, t
);
627 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
);
632 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
) {
638 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
640 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
641 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
642 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
643 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
645 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
647 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
648 pa_tagstruct_putu32(t
, idx
);
649 pa_tagstruct_puts(t
, NULL
);
650 pa_tagstruct_puts(t
, port
);
651 pa_pstream_send_tagstruct(c
->pstream
, t
);
652 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
);
657 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
) {
663 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
665 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
666 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
667 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
668 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 16, PA_ERR_NOTSUPPORTED
);
670 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
672 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_PORT
, &tag
);
673 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
674 pa_tagstruct_puts(t
, name
);
675 pa_tagstruct_puts(t
, port
);
676 pa_pstream_send_tagstruct(c
->pstream
, t
);
677 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
);
682 /*** Client info ***/
684 static void context_get_client_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
685 pa_operation
*o
= userdata
;
690 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
695 if (command
!= PA_COMMAND_REPLY
) {
696 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
702 while (!pa_tagstruct_eof(t
)) {
706 i
.proplist
= pa_proplist_new();
708 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
709 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
710 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
711 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
712 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
714 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
715 pa_proplist_free(i
.proplist
);
720 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
721 cb(o
->context
, &i
, 0, o
->userdata
);
724 pa_proplist_free(i
.proplist
);
729 pa_client_info_cb_t cb
= (pa_client_info_cb_t
) o
->callback
;
730 cb(o
->context
, NULL
, eol
, o
->userdata
);
734 pa_operation_done(o
);
735 pa_operation_unref(o
);
738 pa_operation
* pa_context_get_client_info(pa_context
*c
, uint32_t idx
, pa_client_info_cb_t cb
, void *userdata
) {
744 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
747 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
748 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
749 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
751 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
753 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CLIENT_INFO
, &tag
);
754 pa_tagstruct_putu32(t
, idx
);
755 pa_pstream_send_tagstruct(c
->pstream
, t
);
756 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
);
761 pa_operation
* pa_context_get_client_info_list(pa_context
*c
, pa_client_info_cb_t cb
, void *userdata
) {
762 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CLIENT_INFO_LIST
, context_get_client_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
767 static void card_info_free(pa_card_info
* i
) {
769 pa_proplist_free(i
->proplist
);
771 pa_xfree(i
->profiles
);
776 for (j
= 0; j
< i
->n_profiles
; j
++)
777 pa_xfree(i
->profiles2
[j
]);
779 pa_xfree(i
->profiles2
);
785 for (j
= 0; j
< i
->n_ports
; j
++) {
787 if (i
->ports
[j
]->profiles
)
788 pa_xfree(i
->ports
[j
]->profiles
);
789 if (i
->ports
[j
]->profiles2
)
790 pa_xfree(i
->ports
[j
]->profiles2
);
791 if (i
->ports
[j
]->proplist
)
792 pa_proplist_free(i
->ports
[j
]->proplist
);
796 pa_xfree(i
->ports
[0]);
801 static int fill_card_port_info(pa_context
*context
, pa_tagstruct
* t
, pa_card_info
* i
) {
804 if (pa_tagstruct_getu32(t
, &i
->n_ports
) < 0)
805 return -PA_ERR_PROTOCOL
;
807 if (i
->n_ports
== 0) {
812 i
->ports
= pa_xnew0(pa_card_port_info
*, i
->n_ports
+1);
813 i
->ports
[0] = pa_xnew0(pa_card_port_info
, i
->n_ports
);
815 for (j
= 0; j
< i
->n_ports
; j
++) {
818 pa_card_port_info
* port
= i
->ports
[j
] = &i
->ports
[0][j
];
820 port
->proplist
= pa_proplist_new();
822 if (pa_tagstruct_gets(t
, &port
->name
) < 0 ||
823 pa_tagstruct_gets(t
, &port
->description
) < 0 ||
824 pa_tagstruct_getu32(t
, &port
->priority
) < 0 ||
825 pa_tagstruct_getu32(t
, &available
) < 0 ||
826 pa_tagstruct_getu8(t
, &direction
) < 0 ||
827 !pa_direction_valid(direction
) ||
828 pa_tagstruct_get_proplist(t
, port
->proplist
) < 0 ||
829 pa_tagstruct_getu32(t
, &port
->n_profiles
) < 0) {
831 return -PA_ERR_PROTOCOL
;
834 if (available
> PA_PORT_AVAILABLE_YES
) {
835 return -PA_ERR_PROTOCOL
;
838 port
->direction
= direction
;
839 port
->available
= available
;
841 if (port
->n_profiles
> 0) {
842 port
->profiles
= pa_xnew0(pa_card_profile_info
*, i
->n_profiles
+1);
843 port
->profiles2
= pa_xnew0(pa_card_profile_info2
*, i
->n_profiles
+1);
845 for (k
= 0; k
< port
->n_profiles
; k
++) {
846 const char* profilename
;
848 if (pa_tagstruct_gets(t
, &profilename
) < 0)
849 return -PA_ERR_PROTOCOL
;
851 for (l
= 0; l
< i
->n_profiles
; l
++) {
852 if (pa_streq(i
->profiles
[l
].name
, profilename
)) {
853 port
->profiles
[k
] = &i
->profiles
[l
];
854 port
->profiles2
[k
] = i
->profiles2
[l
];
859 if (l
>= i
->n_profiles
)
860 return -PA_ERR_PROTOCOL
;
863 if (context
->version
>= 27) {
864 if (pa_tagstruct_gets64(t
, &port
->latency_offset
) < 0)
865 return -PA_ERR_PROTOCOL
;
867 port
->latency_offset
= 0;
873 static int fill_card_profile_info(pa_context
*context
, pa_tagstruct
* t
, pa_card_info
* i
) {
876 i
->profiles
= pa_xnew0(pa_card_profile_info
, i
->n_profiles
+1);
877 i
->profiles2
= pa_xnew0(pa_card_profile_info2
*, i
->n_profiles
+1);
879 for (j
= 0; j
< i
->n_profiles
; j
++) {
880 if (pa_tagstruct_gets(t
, &i
->profiles
[j
].name
) < 0 ||
881 pa_tagstruct_gets(t
, &i
->profiles
[j
].description
) < 0 ||
882 pa_tagstruct_getu32(t
, &i
->profiles
[j
].n_sinks
) < 0 ||
883 pa_tagstruct_getu32(t
, &i
->profiles
[j
].n_sources
) < 0 ||
884 pa_tagstruct_getu32(t
, &i
->profiles
[j
].priority
) < 0)
885 return -PA_ERR_PROTOCOL
;
887 i
->profiles2
[j
] = pa_xnew0(pa_card_profile_info2
, 1);
888 i
->profiles2
[j
]->name
= i
->profiles
[j
].name
;
889 i
->profiles2
[j
]->description
= i
->profiles
[j
].description
;
890 i
->profiles2
[j
]->n_sinks
= i
->profiles
[j
].n_sinks
;
891 i
->profiles2
[j
]->n_sources
= i
->profiles
[j
].n_sources
;
892 i
->profiles2
[j
]->priority
= i
->profiles
[j
].priority
;
893 i
->profiles2
[j
]->available
= 1;
895 if (context
->version
>= 29) {
898 if (pa_tagstruct_getu32(t
, &av
) < 0)
899 return -PA_ERR_PROTOCOL
;
901 i
->profiles2
[j
]->available
= av
;
908 static void context_get_card_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
909 pa_operation
*o
= userdata
;
915 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
920 if (command
!= PA_COMMAND_REPLY
) {
921 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
927 while (!pa_tagstruct_eof(t
)) {
933 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
934 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
935 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
936 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
937 pa_tagstruct_getu32(t
, &i
.n_profiles
) < 0)
940 if (i
.n_profiles
> 0) {
941 if (fill_card_profile_info(o
->context
, t
, &i
) < 0)
945 i
.proplist
= pa_proplist_new();
947 if (pa_tagstruct_gets(t
, &ap
) < 0 ||
948 pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) {
950 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
956 for (j
= 0; j
< i
.n_profiles
; j
++)
957 if (pa_streq(i
.profiles
[j
].name
, ap
)) {
958 i
.active_profile
= &i
.profiles
[j
];
959 i
.active_profile2
= i
.profiles2
[j
];
964 if (o
->context
->version
>= 26) {
965 if (fill_card_port_info(o
->context
, t
, &i
) < 0)
970 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
971 cb(o
->context
, &i
, 0, o
->userdata
);
979 pa_card_info_cb_t cb
= (pa_card_info_cb_t
) o
->callback
;
980 cb(o
->context
, NULL
, eol
, o
->userdata
);
984 pa_operation_done(o
);
985 pa_operation_unref(o
);
989 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
994 pa_operation
* pa_context_get_card_info_by_index(pa_context
*c
, uint32_t idx
, pa_card_info_cb_t cb
, void *userdata
) {
1000 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1003 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1004 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1005 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1006 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
1008 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1010 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
1011 pa_tagstruct_putu32(t
, idx
);
1012 pa_tagstruct_puts(t
, NULL
);
1013 pa_pstream_send_tagstruct(c
->pstream
, t
);
1014 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
);
1019 pa_operation
* pa_context_get_card_info_by_name(pa_context
*c
, const char*name
, pa_card_info_cb_t cb
, void *userdata
) {
1025 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1028 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1029 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1030 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1031 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
1033 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1035 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_CARD_INFO
, &tag
);
1036 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1037 pa_tagstruct_puts(t
, name
);
1038 pa_pstream_send_tagstruct(c
->pstream
, t
);
1039 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
);
1044 pa_operation
* pa_context_get_card_info_list(pa_context
*c
, pa_card_info_cb_t cb
, void *userdata
) {
1045 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
1047 return pa_context_send_simple_command(c
, PA_COMMAND_GET_CARD_INFO_LIST
, context_get_card_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1050 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
) {
1056 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1058 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1059 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1060 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1061 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
1063 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1065 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
1066 pa_tagstruct_putu32(t
, idx
);
1067 pa_tagstruct_puts(t
, NULL
);
1068 pa_tagstruct_puts(t
, profile
);
1069 pa_pstream_send_tagstruct(c
->pstream
, t
);
1070 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
);
1075 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
) {
1081 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1083 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1084 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1085 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1086 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 15, PA_ERR_NOTSUPPORTED
);
1088 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1090 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_CARD_PROFILE
, &tag
);
1091 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1092 pa_tagstruct_puts(t
, name
);
1093 pa_tagstruct_puts(t
, profile
);
1094 pa_pstream_send_tagstruct(c
->pstream
, t
);
1095 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
);
1100 /*** Module info ***/
1102 static void context_get_module_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1103 pa_operation
*o
= userdata
;
1108 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1113 if (command
!= PA_COMMAND_REPLY
) {
1114 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
1120 while (!pa_tagstruct_eof(t
)) {
1122 bool auto_unload
= false;
1125 i
.proplist
= pa_proplist_new();
1127 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1128 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1129 pa_tagstruct_gets(t
, &i
.argument
) < 0 ||
1130 pa_tagstruct_getu32(t
, &i
.n_used
) < 0 ||
1131 (o
->context
->version
< 15 && pa_tagstruct_get_boolean(t
, &auto_unload
) < 0) ||
1132 (o
->context
->version
>= 15 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1133 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1137 i
.auto_unload
= (int) auto_unload
;
1140 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
1141 cb(o
->context
, &i
, 0, o
->userdata
);
1144 pa_proplist_free(i
.proplist
);
1149 pa_module_info_cb_t cb
= (pa_module_info_cb_t
) o
->callback
;
1150 cb(o
->context
, NULL
, eol
, o
->userdata
);
1154 pa_operation_done(o
);
1155 pa_operation_unref(o
);
1158 pa_operation
* pa_context_get_module_info(pa_context
*c
, uint32_t idx
, pa_module_info_cb_t cb
, void *userdata
) {
1164 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1167 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1168 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1169 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1171 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1173 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_MODULE_INFO
, &tag
);
1174 pa_tagstruct_putu32(t
, idx
);
1175 pa_pstream_send_tagstruct(c
->pstream
, t
);
1176 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
);
1181 pa_operation
* pa_context_get_module_info_list(pa_context
*c
, pa_module_info_cb_t cb
, void *userdata
) {
1182 return pa_context_send_simple_command(c
, PA_COMMAND_GET_MODULE_INFO_LIST
, context_get_module_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1185 /*** Sink input info ***/
1187 static void context_get_sink_input_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1188 pa_operation
*o
= userdata
;
1193 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1198 if (command
!= PA_COMMAND_REPLY
) {
1199 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
1205 while (!pa_tagstruct_eof(t
)) {
1206 pa_sink_input_info i
;
1207 bool mute
= false, corked
= false, has_volume
= false, volume_writable
= true;
1210 i
.proplist
= pa_proplist_new();
1211 i
.format
= pa_format_info_new();
1213 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1214 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1215 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1216 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1217 pa_tagstruct_getu32(t
, &i
.sink
) < 0 ||
1218 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1219 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1220 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1221 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1222 pa_tagstruct_get_usec(t
, &i
.sink_usec
) < 0 ||
1223 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1224 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1225 (o
->context
->version
>= 11 && pa_tagstruct_get_boolean(t
, &mute
) < 0) ||
1226 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1227 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0) ||
1228 (o
->context
->version
>= 20 && (pa_tagstruct_get_boolean(t
, &has_volume
) < 0 ||
1229 pa_tagstruct_get_boolean(t
, &volume_writable
) < 0)) ||
1230 (o
->context
->version
>= 21 && pa_tagstruct_get_format_info(t
, i
.format
) < 0)) {
1232 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1233 pa_proplist_free(i
.proplist
);
1234 pa_format_info_free(i
.format
);
1238 i
.mute
= (int) mute
;
1239 i
.corked
= (int) corked
;
1240 i
.has_volume
= (int) has_volume
;
1241 i
.volume_writable
= (int) volume_writable
;
1244 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1245 cb(o
->context
, &i
, 0, o
->userdata
);
1248 pa_proplist_free(i
.proplist
);
1249 pa_format_info_free(i
.format
);
1254 pa_sink_input_info_cb_t cb
= (pa_sink_input_info_cb_t
) o
->callback
;
1255 cb(o
->context
, NULL
, eol
, o
->userdata
);
1259 pa_operation_done(o
);
1260 pa_operation_unref(o
);
1263 pa_operation
* pa_context_get_sink_input_info(pa_context
*c
, uint32_t idx
, pa_sink_input_info_cb_t cb
, void *userdata
) {
1269 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1272 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1273 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1274 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1276 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1278 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SINK_INPUT_INFO
, &tag
);
1279 pa_tagstruct_putu32(t
, idx
);
1280 pa_pstream_send_tagstruct(c
->pstream
, t
);
1281 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
);
1286 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
) {
1287 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
);
1290 /*** Source output info ***/
1292 static void context_get_source_output_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1293 pa_operation
*o
= userdata
;
1298 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1303 if (command
!= PA_COMMAND_REPLY
) {
1304 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
1310 while (!pa_tagstruct_eof(t
)) {
1311 pa_source_output_info i
;
1312 bool mute
= false, corked
= false, has_volume
= false, volume_writable
= true;
1315 i
.proplist
= pa_proplist_new();
1316 i
.format
= pa_format_info_new();
1318 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1319 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1320 pa_tagstruct_getu32(t
, &i
.owner_module
) < 0 ||
1321 pa_tagstruct_getu32(t
, &i
.client
) < 0 ||
1322 pa_tagstruct_getu32(t
, &i
.source
) < 0 ||
1323 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1324 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1325 pa_tagstruct_get_usec(t
, &i
.buffer_usec
) < 0 ||
1326 pa_tagstruct_get_usec(t
, &i
.source_usec
) < 0 ||
1327 pa_tagstruct_gets(t
, &i
.resample_method
) < 0 ||
1328 pa_tagstruct_gets(t
, &i
.driver
) < 0 ||
1329 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0) ||
1330 (o
->context
->version
>= 19 && pa_tagstruct_get_boolean(t
, &corked
) < 0) ||
1331 (o
->context
->version
>= 22 && (pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1332 pa_tagstruct_get_boolean(t
, &mute
) < 0 ||
1333 pa_tagstruct_get_boolean(t
, &has_volume
) < 0 ||
1334 pa_tagstruct_get_boolean(t
, &volume_writable
) < 0 ||
1335 pa_tagstruct_get_format_info(t
, i
.format
) < 0))) {
1337 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1338 pa_proplist_free(i
.proplist
);
1339 pa_format_info_free(i
.format
);
1343 i
.mute
= (int) mute
;
1344 i
.corked
= (int) corked
;
1345 i
.has_volume
= (int) has_volume
;
1346 i
.volume_writable
= (int) volume_writable
;
1349 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1350 cb(o
->context
, &i
, 0, o
->userdata
);
1353 pa_proplist_free(i
.proplist
);
1354 pa_format_info_free(i
.format
);
1359 pa_source_output_info_cb_t cb
= (pa_source_output_info_cb_t
) o
->callback
;
1360 cb(o
->context
, NULL
, eol
, o
->userdata
);
1364 pa_operation_done(o
);
1365 pa_operation_unref(o
);
1368 pa_operation
* pa_context_get_source_output_info(pa_context
*c
, uint32_t idx
, pa_source_output_info_cb_t cb
, void *userdata
) {
1374 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1377 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1378 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1379 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1381 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1383 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SOURCE_OUTPUT_INFO
, &tag
);
1384 pa_tagstruct_putu32(t
, idx
);
1385 pa_pstream_send_tagstruct(c
->pstream
, t
);
1386 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
);
1391 pa_operation
* pa_context_get_source_output_info_list(pa_context
*c
, pa_source_output_info_cb_t cb
, void *userdata
) {
1392 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
);
1395 /*** Volume manipulation ***/
1397 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
) {
1403 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1406 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1407 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1408 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1410 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1412 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1413 pa_tagstruct_putu32(t
, idx
);
1414 pa_tagstruct_puts(t
, NULL
);
1415 pa_tagstruct_put_cvolume(t
, volume
);
1416 pa_pstream_send_tagstruct(c
->pstream
, t
);
1417 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
);
1422 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
) {
1428 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1432 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1433 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1434 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1435 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1437 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1439 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_VOLUME
, &tag
);
1440 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1441 pa_tagstruct_puts(t
, name
);
1442 pa_tagstruct_put_cvolume(t
, volume
);
1443 pa_pstream_send_tagstruct(c
->pstream
, t
);
1444 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
);
1449 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
) {
1455 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1457 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1458 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1460 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1462 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1463 pa_tagstruct_putu32(t
, idx
);
1464 pa_tagstruct_puts(t
, NULL
);
1465 pa_tagstruct_put_boolean(t
, mute
);
1466 pa_pstream_send_tagstruct(c
->pstream
, t
);
1467 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
);
1472 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
) {
1478 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1481 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1482 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1483 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1485 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1487 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_MUTE
, &tag
);
1488 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1489 pa_tagstruct_puts(t
, name
);
1490 pa_tagstruct_put_boolean(t
, mute
);
1491 pa_pstream_send_tagstruct(c
->pstream
, t
);
1492 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
);
1497 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
) {
1503 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1506 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1507 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1508 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1509 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1511 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1513 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_VOLUME
, &tag
);
1514 pa_tagstruct_putu32(t
, idx
);
1515 pa_tagstruct_put_cvolume(t
, volume
);
1516 pa_pstream_send_tagstruct(c
->pstream
, t
);
1517 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
);
1522 pa_operation
* pa_context_set_sink_input_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1528 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
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1533 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
1535 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1537 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SINK_INPUT_MUTE
, &tag
);
1538 pa_tagstruct_putu32(t
, idx
);
1539 pa_tagstruct_put_boolean(t
, mute
);
1540 pa_pstream_send_tagstruct(c
->pstream
, t
);
1541 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
);
1546 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
) {
1552 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1555 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1556 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1557 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1559 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1561 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1562 pa_tagstruct_putu32(t
, idx
);
1563 pa_tagstruct_puts(t
, NULL
);
1564 pa_tagstruct_put_cvolume(t
, volume
);
1565 pa_pstream_send_tagstruct(c
->pstream
, t
);
1566 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
);
1571 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
) {
1577 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
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1584 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1586 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1588 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_VOLUME
, &tag
);
1589 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1590 pa_tagstruct_puts(t
, name
);
1591 pa_tagstruct_put_cvolume(t
, volume
);
1592 pa_pstream_send_tagstruct(c
->pstream
, t
);
1593 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
);
1598 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
) {
1604 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1606 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1607 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1609 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1611 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1612 pa_tagstruct_putu32(t
, idx
);
1613 pa_tagstruct_puts(t
, NULL
);
1614 pa_tagstruct_put_boolean(t
, mute
);
1615 pa_pstream_send_tagstruct(c
->pstream
, t
);
1616 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
);
1621 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
) {
1627 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1630 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1631 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1632 PA_CHECK_VALIDITY_RETURN_NULL(c
, !name
|| *name
, PA_ERR_INVALID
);
1634 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1636 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_MUTE
, &tag
);
1637 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1638 pa_tagstruct_puts(t
, name
);
1639 pa_tagstruct_put_boolean(t
, mute
);
1640 pa_pstream_send_tagstruct(c
->pstream
, t
);
1641 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
);
1646 pa_operation
* pa_context_set_source_output_volume(pa_context
*c
, uint32_t idx
, const pa_cvolume
*volume
, pa_context_success_cb_t cb
, void *userdata
) {
1652 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1655 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1656 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1657 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1658 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 22, PA_ERR_NOTSUPPORTED
);
1659 PA_CHECK_VALIDITY_RETURN_NULL(c
, pa_cvolume_valid(volume
), PA_ERR_INVALID
);
1661 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1663 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_OUTPUT_VOLUME
, &tag
);
1664 pa_tagstruct_putu32(t
, idx
);
1665 pa_tagstruct_put_cvolume(t
, volume
);
1666 pa_pstream_send_tagstruct(c
->pstream
, t
);
1667 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
);
1672 pa_operation
* pa_context_set_source_output_mute(pa_context
*c
, uint32_t idx
, int mute
, pa_context_success_cb_t cb
, void *userdata
) {
1678 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1680 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1681 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1682 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1683 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 22, PA_ERR_NOTSUPPORTED
);
1685 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1687 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_SOURCE_OUTPUT_MUTE
, &tag
);
1688 pa_tagstruct_putu32(t
, idx
);
1689 pa_tagstruct_put_boolean(t
, mute
);
1690 pa_pstream_send_tagstruct(c
->pstream
, t
);
1691 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
);
1696 /** Sample Cache **/
1698 static void context_get_sample_info_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1699 pa_operation
*o
= userdata
;
1704 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1709 if (command
!= PA_COMMAND_REPLY
) {
1710 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
1716 while (!pa_tagstruct_eof(t
)) {
1721 i
.proplist
= pa_proplist_new();
1723 if (pa_tagstruct_getu32(t
, &i
.index
) < 0 ||
1724 pa_tagstruct_gets(t
, &i
.name
) < 0 ||
1725 pa_tagstruct_get_cvolume(t
, &i
.volume
) < 0 ||
1726 pa_tagstruct_get_usec(t
, &i
.duration
) < 0 ||
1727 pa_tagstruct_get_sample_spec(t
, &i
.sample_spec
) < 0 ||
1728 pa_tagstruct_get_channel_map(t
, &i
.channel_map
) < 0 ||
1729 pa_tagstruct_getu32(t
, &i
.bytes
) < 0 ||
1730 pa_tagstruct_get_boolean(t
, &lazy
) < 0 ||
1731 pa_tagstruct_gets(t
, &i
.filename
) < 0 ||
1732 (o
->context
->version
>= 13 && pa_tagstruct_get_proplist(t
, i
.proplist
) < 0)) {
1734 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1738 i
.lazy
= (int) lazy
;
1741 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1742 cb(o
->context
, &i
, 0, o
->userdata
);
1745 pa_proplist_free(i
.proplist
);
1750 pa_sample_info_cb_t cb
= (pa_sample_info_cb_t
) o
->callback
;
1751 cb(o
->context
, NULL
, eol
, o
->userdata
);
1755 pa_operation_done(o
);
1756 pa_operation_unref(o
);
1759 pa_operation
* pa_context_get_sample_info_by_name(pa_context
*c
, const char *name
, pa_sample_info_cb_t cb
, void *userdata
) {
1765 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1768 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1769 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1770 PA_CHECK_VALIDITY_RETURN_NULL(c
, name
&& *name
, PA_ERR_INVALID
);
1772 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1774 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1775 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1776 pa_tagstruct_puts(t
, name
);
1777 pa_pstream_send_tagstruct(c
->pstream
, t
);
1778 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
);
1783 pa_operation
* pa_context_get_sample_info_by_index(pa_context
*c
, uint32_t idx
, pa_sample_info_cb_t cb
, void *userdata
) {
1789 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1792 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1793 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1794 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1796 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1798 t
= pa_tagstruct_command(c
, PA_COMMAND_GET_SAMPLE_INFO
, &tag
);
1799 pa_tagstruct_putu32(t
, idx
);
1800 pa_tagstruct_puts(t
, NULL
);
1801 pa_pstream_send_tagstruct(c
->pstream
, t
);
1802 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
);
1807 pa_operation
* pa_context_get_sample_info_list(pa_context
*c
, pa_sample_info_cb_t cb
, void *userdata
) {
1808 return pa_context_send_simple_command(c
, PA_COMMAND_GET_SAMPLE_INFO_LIST
, context_get_sample_info_callback
, (pa_operation_cb_t
) cb
, userdata
);
1811 static pa_operation
* command_kill(pa_context
*c
, uint32_t command
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1817 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1819 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1820 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1821 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
1823 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1825 t
= pa_tagstruct_command(c
, command
, &tag
);
1826 pa_tagstruct_putu32(t
, idx
);
1827 pa_pstream_send_tagstruct(c
->pstream
, t
);
1828 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
);
1833 pa_operation
* pa_context_kill_client(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1834 return command_kill(c
, PA_COMMAND_KILL_CLIENT
, idx
, cb
, userdata
);
1837 pa_operation
* pa_context_kill_sink_input(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1838 return command_kill(c
, PA_COMMAND_KILL_SINK_INPUT
, idx
, cb
, userdata
);
1841 pa_operation
* pa_context_kill_source_output(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1842 return command_kill(c
, PA_COMMAND_KILL_SOURCE_OUTPUT
, idx
, cb
, userdata
);
1845 static void context_index_callback(pa_pdispatch
*pd
, uint32_t command
, uint32_t tag
, pa_tagstruct
*t
, void *userdata
) {
1846 pa_operation
*o
= userdata
;
1851 pa_assert(PA_REFCNT_VALUE(o
) >= 1);
1856 if (command
!= PA_COMMAND_REPLY
) {
1857 if (pa_context_handle_error(o
->context
, command
, t
, false) < 0)
1860 idx
= PA_INVALID_INDEX
;
1861 } else if (pa_tagstruct_getu32(t
, &idx
) ||
1862 !pa_tagstruct_eof(t
)) {
1863 pa_context_fail(o
->context
, PA_ERR_PROTOCOL
);
1868 pa_context_index_cb_t cb
= (pa_context_index_cb_t
) o
->callback
;
1869 cb(o
->context
, idx
, o
->userdata
);
1873 pa_operation_done(o
);
1874 pa_operation_unref(o
);
1877 pa_operation
* pa_context_load_module(pa_context
*c
, const char*name
, const char *argument
, pa_context_index_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
, name
&& *name
, PA_ERR_INVALID
);
1889 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1891 t
= pa_tagstruct_command(c
, PA_COMMAND_LOAD_MODULE
, &tag
);
1892 pa_tagstruct_puts(t
, name
);
1893 pa_tagstruct_puts(t
, argument
);
1894 pa_pstream_send_tagstruct(c
->pstream
, t
);
1895 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, context_index_callback
, pa_operation_ref(o
), (pa_free_cb_t
) pa_operation_unref
);
1900 pa_operation
* pa_context_unload_module(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void *userdata
) {
1901 return command_kill(c
, PA_COMMAND_UNLOAD_MODULE
, idx
, cb
, userdata
);
1904 pa_operation
* pa_context_set_port_latency_offset(pa_context
*c
, const char *card_name
, const char *port_name
, int64_t offset
, pa_context_success_cb_t cb
, void *userdata
) {
1910 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1912 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1913 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1914 PA_CHECK_VALIDITY_RETURN_NULL(c
, card_name
&& *card_name
, PA_ERR_INVALID
);
1915 PA_CHECK_VALIDITY_RETURN_NULL(c
, port_name
&& *port_name
, PA_ERR_INVALID
);
1916 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 27, PA_ERR_NOTSUPPORTED
);
1918 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
1920 t
= pa_tagstruct_command(c
, PA_COMMAND_SET_PORT_LATENCY_OFFSET
, &tag
);
1921 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
1922 pa_tagstruct_puts(t
, card_name
);
1923 pa_tagstruct_puts(t
, port_name
);
1924 pa_tagstruct_puts64(t
, offset
);
1925 pa_pstream_send_tagstruct(c
->pstream
, t
);
1926 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
);
1931 /*** Autoload stuff ***/
1933 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name
, "Module auto-loading no longer supported.");
1935 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
) {
1938 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1940 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1943 PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index
, "Module auto-loading no longer supported.");
1945 pa_operation
* pa_context_get_autoload_info_by_index(pa_context
*c
, uint32_t idx
, pa_autoload_info_cb_t cb
, void *userdata
) {
1947 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1949 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1952 PA_WARN_REFERENCE(pa_context_get_autoload_info_list
, "Module auto-loading no longer supported.");
1954 pa_operation
* pa_context_get_autoload_info_list(pa_context
*c
, pa_autoload_info_cb_t cb
, void *userdata
) {
1956 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1958 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1961 PA_WARN_REFERENCE(pa_context_add_autoload
, "Module auto-loading no longer supported.");
1963 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
) {
1965 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1967 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1970 PA_WARN_REFERENCE(pa_context_remove_autoload_by_name
, "Module auto-loading no longer supported.");
1972 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
) {
1974 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1976 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1979 PA_WARN_REFERENCE(pa_context_remove_autoload_by_index
, "Module auto-loading no longer supported.");
1981 pa_operation
* pa_context_remove_autoload_by_index(pa_context
*c
, uint32_t idx
, pa_context_success_cb_t cb
, void* userdata
) {
1983 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1985 PA_FAIL_RETURN_NULL(c
, PA_ERR_OBSOLETE
);
1988 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
) {
1994 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
1996 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
1997 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
1998 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
1999 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
2000 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_name
&& *sink_name
, PA_ERR_INVALID
);
2002 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2004 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
2005 pa_tagstruct_putu32(t
, idx
);
2006 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
2007 pa_tagstruct_puts(t
, sink_name
);
2008 pa_pstream_send_tagstruct(c
->pstream
, t
);
2009 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
);
2014 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
) {
2020 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
2022 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
2023 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
2024 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
2025 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
2026 PA_CHECK_VALIDITY_RETURN_NULL(c
, sink_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
2028 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2030 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SINK_INPUT
, &tag
);
2031 pa_tagstruct_putu32(t
, idx
);
2032 pa_tagstruct_putu32(t
, sink_idx
);
2033 pa_tagstruct_puts(t
, NULL
);
2034 pa_pstream_send_tagstruct(c
->pstream
, t
);
2035 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
);
2040 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
) {
2046 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
2048 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
2049 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
2050 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
2051 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
2052 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_name
&& *source_name
, PA_ERR_INVALID
);
2054 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2056 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
2057 pa_tagstruct_putu32(t
, idx
);
2058 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
2059 pa_tagstruct_puts(t
, source_name
);
2060 pa_pstream_send_tagstruct(c
->pstream
, t
);
2061 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
);
2066 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
) {
2072 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
2074 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
2075 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
2076 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 10, PA_ERR_NOTSUPPORTED
);
2077 PA_CHECK_VALIDITY_RETURN_NULL(c
, idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
2078 PA_CHECK_VALIDITY_RETURN_NULL(c
, source_idx
!= PA_INVALID_INDEX
, PA_ERR_INVALID
);
2080 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2082 t
= pa_tagstruct_command(c
, PA_COMMAND_MOVE_SOURCE_OUTPUT
, &tag
);
2083 pa_tagstruct_putu32(t
, idx
);
2084 pa_tagstruct_putu32(t
, source_idx
);
2085 pa_tagstruct_puts(t
, NULL
);
2086 pa_pstream_send_tagstruct(c
->pstream
, t
);
2087 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
);
2092 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
) {
2098 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
2100 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
2101 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
2102 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
2103 PA_CHECK_VALIDITY_RETURN_NULL(c
, !sink_name
|| *sink_name
, PA_ERR_INVALID
);
2105 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2107 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
2108 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
2109 pa_tagstruct_puts(t
, sink_name
);
2110 pa_tagstruct_put_boolean(t
, suspend
);
2111 pa_pstream_send_tagstruct(c
->pstream
, t
);
2112 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
);
2117 pa_operation
* pa_context_suspend_sink_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
2123 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
2125 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
2126 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
2127 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
2129 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2131 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SINK
, &tag
);
2132 pa_tagstruct_putu32(t
, idx
);
2133 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
2134 pa_tagstruct_put_boolean(t
, suspend
);
2135 pa_pstream_send_tagstruct(c
->pstream
, t
);
2136 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
);
2141 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
) {
2147 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
2149 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
2150 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
2151 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
2152 PA_CHECK_VALIDITY_RETURN_NULL(c
, !source_name
|| *source_name
, PA_ERR_INVALID
);
2154 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2156 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
2157 pa_tagstruct_putu32(t
, PA_INVALID_INDEX
);
2158 pa_tagstruct_puts(t
, source_name
);
2159 pa_tagstruct_put_boolean(t
, suspend
);
2160 pa_pstream_send_tagstruct(c
->pstream
, t
);
2161 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
);
2166 pa_operation
* pa_context_suspend_source_by_index(pa_context
*c
, uint32_t idx
, int suspend
, pa_context_success_cb_t cb
, void* userdata
) {
2172 pa_assert(PA_REFCNT_VALUE(c
) >= 1);
2174 PA_CHECK_VALIDITY_RETURN_NULL(c
, !pa_detect_fork(), PA_ERR_FORKED
);
2175 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->state
== PA_CONTEXT_READY
, PA_ERR_BADSTATE
);
2176 PA_CHECK_VALIDITY_RETURN_NULL(c
, c
->version
>= 11, PA_ERR_NOTSUPPORTED
);
2178 o
= pa_operation_new(c
, NULL
, (pa_operation_cb_t
) cb
, userdata
);
2180 t
= pa_tagstruct_command(c
, PA_COMMAND_SUSPEND_SOURCE
, &tag
);
2181 pa_tagstruct_putu32(t
, idx
);
2182 pa_tagstruct_puts(t
, idx
== PA_INVALID_INDEX
? "" : NULL
);
2183 pa_tagstruct_put_boolean(t
, suspend
);
2184 pa_pstream_send_tagstruct(c
->pstream
, t
);
2185 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
);