153a5a1b3Sopenharmony_ci/*** 253a5a1b3Sopenharmony_ci This file is part of PulseAudio. 353a5a1b3Sopenharmony_ci 453a5a1b3Sopenharmony_ci Copyright 2004-2006 Lennart Poettering 553a5a1b3Sopenharmony_ci Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB 653a5a1b3Sopenharmony_ci 753a5a1b3Sopenharmony_ci PulseAudio is free software; you can redistribute it and/or modify 853a5a1b3Sopenharmony_ci it under the terms of the GNU Lesser General Public License as published 953a5a1b3Sopenharmony_ci by the Free Software Foundation; either version 2.1 of the License, 1053a5a1b3Sopenharmony_ci or (at your option) any later version. 1153a5a1b3Sopenharmony_ci 1253a5a1b3Sopenharmony_ci PulseAudio is distributed in the hope that it will be useful, but 1353a5a1b3Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 1453a5a1b3Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1553a5a1b3Sopenharmony_ci General Public License for more details. 1653a5a1b3Sopenharmony_ci 1753a5a1b3Sopenharmony_ci You should have received a copy of the GNU Lesser General Public License 1853a5a1b3Sopenharmony_ci along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 1953a5a1b3Sopenharmony_ci***/ 2053a5a1b3Sopenharmony_ci 2153a5a1b3Sopenharmony_ci#ifdef HAVE_CONFIG_H 2253a5a1b3Sopenharmony_ci#include <config.h> 2353a5a1b3Sopenharmony_ci#endif 2453a5a1b3Sopenharmony_ci 2553a5a1b3Sopenharmony_ci#include <pulse/context.h> 2653a5a1b3Sopenharmony_ci#include <pulse/direction.h> 2753a5a1b3Sopenharmony_ci#include <pulse/xmalloc.h> 2853a5a1b3Sopenharmony_ci#include <pulse/fork-detect.h> 2953a5a1b3Sopenharmony_ci 3053a5a1b3Sopenharmony_ci#include <pulsecore/macro.h> 3153a5a1b3Sopenharmony_ci#include <pulsecore/core-util.h> 3253a5a1b3Sopenharmony_ci#include <pulsecore/pstream-util.h> 3353a5a1b3Sopenharmony_ci 3453a5a1b3Sopenharmony_ci#include "internal.h" 3553a5a1b3Sopenharmony_ci#include "introspect.h" 3653a5a1b3Sopenharmony_ci 3753a5a1b3Sopenharmony_ci/*** Statistics ***/ 3853a5a1b3Sopenharmony_ci 3953a5a1b3Sopenharmony_cistatic void context_stat_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 4053a5a1b3Sopenharmony_ci pa_operation *o = userdata; 4153a5a1b3Sopenharmony_ci pa_stat_info i, *p = &i; 4253a5a1b3Sopenharmony_ci 4353a5a1b3Sopenharmony_ci pa_assert(pd); 4453a5a1b3Sopenharmony_ci pa_assert(o); 4553a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 4653a5a1b3Sopenharmony_ci 4753a5a1b3Sopenharmony_ci pa_zero(i); 4853a5a1b3Sopenharmony_ci 4953a5a1b3Sopenharmony_ci if (!o->context) 5053a5a1b3Sopenharmony_ci goto finish; 5153a5a1b3Sopenharmony_ci 5253a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 5353a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 5453a5a1b3Sopenharmony_ci goto finish; 5553a5a1b3Sopenharmony_ci 5653a5a1b3Sopenharmony_ci p = NULL; 5753a5a1b3Sopenharmony_ci } else if (pa_tagstruct_getu32(t, &i.memblock_total) < 0 || 5853a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.memblock_total_size) < 0 || 5953a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.memblock_allocated) < 0 || 6053a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.memblock_allocated_size) < 0 || 6153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.scache_size) < 0 || 6253a5a1b3Sopenharmony_ci !pa_tagstruct_eof(t)) { 6353a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 6453a5a1b3Sopenharmony_ci goto finish; 6553a5a1b3Sopenharmony_ci } 6653a5a1b3Sopenharmony_ci 6753a5a1b3Sopenharmony_ci if (o->callback) { 6853a5a1b3Sopenharmony_ci pa_stat_info_cb_t cb = (pa_stat_info_cb_t) o->callback; 6953a5a1b3Sopenharmony_ci cb(o->context, p, o->userdata); 7053a5a1b3Sopenharmony_ci } 7153a5a1b3Sopenharmony_ci 7253a5a1b3Sopenharmony_cifinish: 7353a5a1b3Sopenharmony_ci pa_operation_done(o); 7453a5a1b3Sopenharmony_ci pa_operation_unref(o); 7553a5a1b3Sopenharmony_ci} 7653a5a1b3Sopenharmony_ci 7753a5a1b3Sopenharmony_cipa_operation* pa_context_stat(pa_context *c, pa_stat_info_cb_t cb, void *userdata) { 7853a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_STAT, context_stat_callback, (pa_operation_cb_t) cb, userdata); 7953a5a1b3Sopenharmony_ci} 8053a5a1b3Sopenharmony_ci 8153a5a1b3Sopenharmony_ci/*** Server Info ***/ 8253a5a1b3Sopenharmony_ci 8353a5a1b3Sopenharmony_cistatic void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 8453a5a1b3Sopenharmony_ci pa_operation *o = userdata; 8553a5a1b3Sopenharmony_ci pa_server_info i, *p = &i; 8653a5a1b3Sopenharmony_ci 8753a5a1b3Sopenharmony_ci pa_assert(pd); 8853a5a1b3Sopenharmony_ci pa_assert(o); 8953a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 9053a5a1b3Sopenharmony_ci 9153a5a1b3Sopenharmony_ci pa_zero(i); 9253a5a1b3Sopenharmony_ci 9353a5a1b3Sopenharmony_ci if (!o->context) 9453a5a1b3Sopenharmony_ci goto finish; 9553a5a1b3Sopenharmony_ci 9653a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 9753a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 9853a5a1b3Sopenharmony_ci goto finish; 9953a5a1b3Sopenharmony_ci 10053a5a1b3Sopenharmony_ci p = NULL; 10153a5a1b3Sopenharmony_ci } else if (pa_tagstruct_gets(t, &i.server_name) < 0 || 10253a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.server_version) < 0 || 10353a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.user_name) < 0 || 10453a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.host_name) < 0 || 10553a5a1b3Sopenharmony_ci pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 || 10653a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.default_sink_name) < 0 || 10753a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.default_source_name) < 0 || 10853a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.cookie) < 0 || 10953a5a1b3Sopenharmony_ci (o->context->version >= 15 && 11053a5a1b3Sopenharmony_ci pa_tagstruct_get_channel_map(t, &i.channel_map) < 0) || 11153a5a1b3Sopenharmony_ci !pa_tagstruct_eof(t)) { 11253a5a1b3Sopenharmony_ci 11353a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 11453a5a1b3Sopenharmony_ci goto finish; 11553a5a1b3Sopenharmony_ci } 11653a5a1b3Sopenharmony_ci 11753a5a1b3Sopenharmony_ci if (p && o->context->version < 15) 11853a5a1b3Sopenharmony_ci pa_channel_map_init_extend(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_DEFAULT); 11953a5a1b3Sopenharmony_ci 12053a5a1b3Sopenharmony_ci if (o->callback) { 12153a5a1b3Sopenharmony_ci pa_server_info_cb_t cb = (pa_server_info_cb_t) o->callback; 12253a5a1b3Sopenharmony_ci cb(o->context, p, o->userdata); 12353a5a1b3Sopenharmony_ci } 12453a5a1b3Sopenharmony_ci 12553a5a1b3Sopenharmony_cifinish: 12653a5a1b3Sopenharmony_ci pa_operation_done(o); 12753a5a1b3Sopenharmony_ci pa_operation_unref(o); 12853a5a1b3Sopenharmony_ci} 12953a5a1b3Sopenharmony_ci 13053a5a1b3Sopenharmony_cipa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb, void *userdata) { 13153a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_GET_SERVER_INFO, context_get_server_info_callback, (pa_operation_cb_t) cb, userdata); 13253a5a1b3Sopenharmony_ci} 13353a5a1b3Sopenharmony_ci 13453a5a1b3Sopenharmony_ci/*** Sink Info ***/ 13553a5a1b3Sopenharmony_ci 13653a5a1b3Sopenharmony_cistatic void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 13753a5a1b3Sopenharmony_ci pa_operation *o = userdata; 13853a5a1b3Sopenharmony_ci int eol = 1; 13953a5a1b3Sopenharmony_ci pa_sink_info i; 14053a5a1b3Sopenharmony_ci uint32_t j; 14153a5a1b3Sopenharmony_ci 14253a5a1b3Sopenharmony_ci pa_assert(pd); 14353a5a1b3Sopenharmony_ci pa_assert(o); 14453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 14553a5a1b3Sopenharmony_ci 14653a5a1b3Sopenharmony_ci /* For safety in case someone use fail: outside the while loop below */ 14753a5a1b3Sopenharmony_ci pa_zero(i); 14853a5a1b3Sopenharmony_ci 14953a5a1b3Sopenharmony_ci if (!o->context) 15053a5a1b3Sopenharmony_ci goto finish; 15153a5a1b3Sopenharmony_ci 15253a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 15353a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 15453a5a1b3Sopenharmony_ci goto finish; 15553a5a1b3Sopenharmony_ci 15653a5a1b3Sopenharmony_ci eol = -1; 15753a5a1b3Sopenharmony_ci } else { 15853a5a1b3Sopenharmony_ci 15953a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 16053a5a1b3Sopenharmony_ci bool mute; 16153a5a1b3Sopenharmony_ci uint32_t flags; 16253a5a1b3Sopenharmony_ci uint32_t state; 16353a5a1b3Sopenharmony_ci const char *ap = NULL; 16453a5a1b3Sopenharmony_ci 16553a5a1b3Sopenharmony_ci pa_zero(i); 16653a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 16753a5a1b3Sopenharmony_ci i.base_volume = PA_VOLUME_NORM; 16853a5a1b3Sopenharmony_ci i.n_volume_steps = PA_VOLUME_NORM+1; 16953a5a1b3Sopenharmony_ci mute = false; 17053a5a1b3Sopenharmony_ci state = PA_SINK_INVALID_STATE; 17153a5a1b3Sopenharmony_ci i.card = PA_INVALID_INDEX; 17253a5a1b3Sopenharmony_ci 17353a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 17453a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 17553a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.description) < 0 || 17653a5a1b3Sopenharmony_ci pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 || 17753a5a1b3Sopenharmony_ci pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 || 17853a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.owner_module) < 0 || 17953a5a1b3Sopenharmony_ci pa_tagstruct_get_cvolume(t, &i.volume) < 0 || 18053a5a1b3Sopenharmony_ci pa_tagstruct_get_boolean(t, &mute) < 0 || 18153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.monitor_source) < 0 || 18253a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.monitor_source_name) < 0 || 18353a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.latency) < 0 || 18453a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.driver) < 0 || 18553a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &flags) < 0 || 18653a5a1b3Sopenharmony_ci (o->context->version >= 13 && 18753a5a1b3Sopenharmony_ci (pa_tagstruct_get_proplist(t, i.proplist) < 0 || 18853a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) || 18953a5a1b3Sopenharmony_ci (o->context->version >= 15 && 19053a5a1b3Sopenharmony_ci (pa_tagstruct_get_volume(t, &i.base_volume) < 0 || 19153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &state) < 0 || 19253a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.n_volume_steps) < 0 || 19353a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.card) < 0)) || 19453a5a1b3Sopenharmony_ci (o->context->version >= 16 && 19553a5a1b3Sopenharmony_ci (pa_tagstruct_getu32(t, &i.n_ports)))) { 19653a5a1b3Sopenharmony_ci 19753a5a1b3Sopenharmony_ci goto fail; 19853a5a1b3Sopenharmony_ci } 19953a5a1b3Sopenharmony_ci 20053a5a1b3Sopenharmony_ci if (o->context->version >= 16) { 20153a5a1b3Sopenharmony_ci if (i.n_ports > 0) { 20253a5a1b3Sopenharmony_ci i.ports = pa_xnew(pa_sink_port_info*, i.n_ports+1); 20353a5a1b3Sopenharmony_ci i.ports[0] = pa_xnew(pa_sink_port_info, i.n_ports); 20453a5a1b3Sopenharmony_ci 20553a5a1b3Sopenharmony_ci for (j = 0; j < i.n_ports; j++) { 20653a5a1b3Sopenharmony_ci i.ports[j] = &i.ports[0][j]; 20753a5a1b3Sopenharmony_ci 20853a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &i.ports[j]->name) < 0 || 20953a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.ports[j]->description) < 0 || 21053a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.ports[j]->priority) < 0) { 21153a5a1b3Sopenharmony_ci 21253a5a1b3Sopenharmony_ci goto fail; 21353a5a1b3Sopenharmony_ci } 21453a5a1b3Sopenharmony_ci 21553a5a1b3Sopenharmony_ci i.ports[j]->available = PA_PORT_AVAILABLE_UNKNOWN; 21653a5a1b3Sopenharmony_ci if (o->context->version >= 24) { 21753a5a1b3Sopenharmony_ci uint32_t av; 21853a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES) 21953a5a1b3Sopenharmony_ci goto fail; 22053a5a1b3Sopenharmony_ci i.ports[j]->available = av; 22153a5a1b3Sopenharmony_ci } 22253a5a1b3Sopenharmony_ci i.ports[j]->availability_group = NULL; 22353a5a1b3Sopenharmony_ci i.ports[j]->type = PA_DEVICE_PORT_TYPE_UNKNOWN; 22453a5a1b3Sopenharmony_ci if (o->context->version >= 34) { 22553a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &i.ports[j]->availability_group) < 0 || 22653a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.ports[j]->type) < 0) 22753a5a1b3Sopenharmony_ci goto fail; 22853a5a1b3Sopenharmony_ci } 22953a5a1b3Sopenharmony_ci } 23053a5a1b3Sopenharmony_ci 23153a5a1b3Sopenharmony_ci i.ports[j] = NULL; 23253a5a1b3Sopenharmony_ci } 23353a5a1b3Sopenharmony_ci 23453a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &ap) < 0) 23553a5a1b3Sopenharmony_ci goto fail; 23653a5a1b3Sopenharmony_ci 23753a5a1b3Sopenharmony_ci if (ap) { 23853a5a1b3Sopenharmony_ci for (j = 0; j < i.n_ports; j++) 23953a5a1b3Sopenharmony_ci if (pa_streq(i.ports[j]->name, ap)) { 24053a5a1b3Sopenharmony_ci i.active_port = i.ports[j]; 24153a5a1b3Sopenharmony_ci break; 24253a5a1b3Sopenharmony_ci } 24353a5a1b3Sopenharmony_ci } 24453a5a1b3Sopenharmony_ci } 24553a5a1b3Sopenharmony_ci 24653a5a1b3Sopenharmony_ci if (o->context->version >= 21) { 24753a5a1b3Sopenharmony_ci uint8_t n_formats; 24853a5a1b3Sopenharmony_ci if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1) 24953a5a1b3Sopenharmony_ci goto fail; 25053a5a1b3Sopenharmony_ci 25153a5a1b3Sopenharmony_ci i.formats = pa_xnew0(pa_format_info*, n_formats); 25253a5a1b3Sopenharmony_ci 25353a5a1b3Sopenharmony_ci for (j = 0; j < n_formats; j++) { 25453a5a1b3Sopenharmony_ci i.n_formats++; 25553a5a1b3Sopenharmony_ci i.formats[j] = pa_format_info_new(); 25653a5a1b3Sopenharmony_ci 25753a5a1b3Sopenharmony_ci if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0) 25853a5a1b3Sopenharmony_ci goto fail; 25953a5a1b3Sopenharmony_ci } 26053a5a1b3Sopenharmony_ci } 26153a5a1b3Sopenharmony_ci 26253a5a1b3Sopenharmony_ci i.mute = (int) mute; 26353a5a1b3Sopenharmony_ci i.flags = (pa_sink_flags_t) flags; 26453a5a1b3Sopenharmony_ci i.state = (pa_sink_state_t) state; 26553a5a1b3Sopenharmony_ci 26653a5a1b3Sopenharmony_ci if (o->callback) { 26753a5a1b3Sopenharmony_ci pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback; 26853a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 26953a5a1b3Sopenharmony_ci } 27053a5a1b3Sopenharmony_ci 27153a5a1b3Sopenharmony_ci if (i.formats) { 27253a5a1b3Sopenharmony_ci for (j = 0; j < i.n_formats; j++) 27353a5a1b3Sopenharmony_ci pa_format_info_free(i.formats[j]); 27453a5a1b3Sopenharmony_ci pa_xfree(i.formats); 27553a5a1b3Sopenharmony_ci } 27653a5a1b3Sopenharmony_ci if (i.ports) { 27753a5a1b3Sopenharmony_ci pa_xfree(i.ports[0]); 27853a5a1b3Sopenharmony_ci pa_xfree(i.ports); 27953a5a1b3Sopenharmony_ci } 28053a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 28153a5a1b3Sopenharmony_ci } 28253a5a1b3Sopenharmony_ci } 28353a5a1b3Sopenharmony_ci 28453a5a1b3Sopenharmony_ci if (o->callback) { 28553a5a1b3Sopenharmony_ci pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback; 28653a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 28753a5a1b3Sopenharmony_ci } 28853a5a1b3Sopenharmony_ci 28953a5a1b3Sopenharmony_cifinish: 29053a5a1b3Sopenharmony_ci pa_operation_done(o); 29153a5a1b3Sopenharmony_ci pa_operation_unref(o); 29253a5a1b3Sopenharmony_ci return; 29353a5a1b3Sopenharmony_ci 29453a5a1b3Sopenharmony_cifail: 29553a5a1b3Sopenharmony_ci pa_assert(i.proplist); 29653a5a1b3Sopenharmony_ci 29753a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 29853a5a1b3Sopenharmony_ci 29953a5a1b3Sopenharmony_ci if (i.formats) { 30053a5a1b3Sopenharmony_ci for (j = 0; j < i.n_formats; j++) 30153a5a1b3Sopenharmony_ci pa_format_info_free(i.formats[j]); 30253a5a1b3Sopenharmony_ci pa_xfree(i.formats); 30353a5a1b3Sopenharmony_ci } 30453a5a1b3Sopenharmony_ci if (i.ports) { 30553a5a1b3Sopenharmony_ci pa_xfree(i.ports[0]); 30653a5a1b3Sopenharmony_ci pa_xfree(i.ports); 30753a5a1b3Sopenharmony_ci } 30853a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 30953a5a1b3Sopenharmony_ci 31053a5a1b3Sopenharmony_ci goto finish; 31153a5a1b3Sopenharmony_ci} 31253a5a1b3Sopenharmony_ci 31353a5a1b3Sopenharmony_cipa_operation* pa_context_get_sink_info_list(pa_context *c, pa_sink_info_cb_t cb, void *userdata) { 31453a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INFO_LIST, context_get_sink_info_callback, (pa_operation_cb_t) cb, userdata); 31553a5a1b3Sopenharmony_ci} 31653a5a1b3Sopenharmony_ci 31753a5a1b3Sopenharmony_cipa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_sink_info_cb_t cb, void *userdata) { 31853a5a1b3Sopenharmony_ci pa_tagstruct *t; 31953a5a1b3Sopenharmony_ci pa_operation *o; 32053a5a1b3Sopenharmony_ci uint32_t tag; 32153a5a1b3Sopenharmony_ci 32253a5a1b3Sopenharmony_ci pa_assert(c); 32353a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 32453a5a1b3Sopenharmony_ci pa_assert(cb); 32553a5a1b3Sopenharmony_ci 32653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 32753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 32853a5a1b3Sopenharmony_ci 32953a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 33053a5a1b3Sopenharmony_ci 33153a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag); 33253a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 33353a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 33453a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 33553a5a1b3Sopenharmony_ci 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); 33653a5a1b3Sopenharmony_ci 33753a5a1b3Sopenharmony_ci return o; 33853a5a1b3Sopenharmony_ci} 33953a5a1b3Sopenharmony_ci 34053a5a1b3Sopenharmony_cipa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, pa_sink_info_cb_t cb, void *userdata) { 34153a5a1b3Sopenharmony_ci pa_tagstruct *t; 34253a5a1b3Sopenharmony_ci pa_operation *o; 34353a5a1b3Sopenharmony_ci uint32_t tag; 34453a5a1b3Sopenharmony_ci 34553a5a1b3Sopenharmony_ci pa_assert(c); 34653a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 34753a5a1b3Sopenharmony_ci pa_assert(cb); 34853a5a1b3Sopenharmony_ci 34953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 35053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 35153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 35253a5a1b3Sopenharmony_ci 35353a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 35453a5a1b3Sopenharmony_ci 35553a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag); 35653a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 35753a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 35853a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 35953a5a1b3Sopenharmony_ci 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); 36053a5a1b3Sopenharmony_ci 36153a5a1b3Sopenharmony_ci return o; 36253a5a1b3Sopenharmony_ci} 36353a5a1b3Sopenharmony_ci 36453a5a1b3Sopenharmony_cipa_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) { 36553a5a1b3Sopenharmony_ci pa_operation *o; 36653a5a1b3Sopenharmony_ci pa_tagstruct *t; 36753a5a1b3Sopenharmony_ci uint32_t tag; 36853a5a1b3Sopenharmony_ci 36953a5a1b3Sopenharmony_ci pa_assert(c); 37053a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 37153a5a1b3Sopenharmony_ci 37253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 37353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 37453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 37553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED); 37653a5a1b3Sopenharmony_ci 37753a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 37853a5a1b3Sopenharmony_ci 37953a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_PORT, &tag); 38053a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 38153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 38253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, port); 38353a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 38453a5a1b3Sopenharmony_ci 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); 38553a5a1b3Sopenharmony_ci 38653a5a1b3Sopenharmony_ci return o; 38753a5a1b3Sopenharmony_ci} 38853a5a1b3Sopenharmony_ci 38953a5a1b3Sopenharmony_cipa_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) { 39053a5a1b3Sopenharmony_ci pa_operation *o; 39153a5a1b3Sopenharmony_ci pa_tagstruct *t; 39253a5a1b3Sopenharmony_ci uint32_t tag; 39353a5a1b3Sopenharmony_ci 39453a5a1b3Sopenharmony_ci pa_assert(c); 39553a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 39653a5a1b3Sopenharmony_ci 39753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 39853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 39953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 40053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED); 40153a5a1b3Sopenharmony_ci 40253a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 40353a5a1b3Sopenharmony_ci 40453a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_PORT, &tag); 40553a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 40653a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 40753a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, port); 40853a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 40953a5a1b3Sopenharmony_ci 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); 41053a5a1b3Sopenharmony_ci 41153a5a1b3Sopenharmony_ci return o; 41253a5a1b3Sopenharmony_ci} 41353a5a1b3Sopenharmony_ci 41453a5a1b3Sopenharmony_ci/*** Source info ***/ 41553a5a1b3Sopenharmony_ci 41653a5a1b3Sopenharmony_cistatic void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 41753a5a1b3Sopenharmony_ci pa_operation *o = userdata; 41853a5a1b3Sopenharmony_ci int eol = 1; 41953a5a1b3Sopenharmony_ci pa_source_info i; 42053a5a1b3Sopenharmony_ci uint32_t j; 42153a5a1b3Sopenharmony_ci 42253a5a1b3Sopenharmony_ci pa_assert(pd); 42353a5a1b3Sopenharmony_ci pa_assert(o); 42453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 42553a5a1b3Sopenharmony_ci 42653a5a1b3Sopenharmony_ci /* For safety in case someone use fail: outside the while loop below */ 42753a5a1b3Sopenharmony_ci pa_zero(i); 42853a5a1b3Sopenharmony_ci 42953a5a1b3Sopenharmony_ci if (!o->context) 43053a5a1b3Sopenharmony_ci goto finish; 43153a5a1b3Sopenharmony_ci 43253a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 43353a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 43453a5a1b3Sopenharmony_ci goto finish; 43553a5a1b3Sopenharmony_ci 43653a5a1b3Sopenharmony_ci eol = -1; 43753a5a1b3Sopenharmony_ci } else { 43853a5a1b3Sopenharmony_ci 43953a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 44053a5a1b3Sopenharmony_ci bool mute; 44153a5a1b3Sopenharmony_ci uint32_t flags; 44253a5a1b3Sopenharmony_ci uint32_t state; 44353a5a1b3Sopenharmony_ci const char *ap; 44453a5a1b3Sopenharmony_ci 44553a5a1b3Sopenharmony_ci pa_zero(i); 44653a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 44753a5a1b3Sopenharmony_ci i.base_volume = PA_VOLUME_NORM; 44853a5a1b3Sopenharmony_ci i.n_volume_steps = PA_VOLUME_NORM+1; 44953a5a1b3Sopenharmony_ci mute = false; 45053a5a1b3Sopenharmony_ci state = PA_SOURCE_INVALID_STATE; 45153a5a1b3Sopenharmony_ci i.card = PA_INVALID_INDEX; 45253a5a1b3Sopenharmony_ci 45353a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 45453a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 45553a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.description) < 0 || 45653a5a1b3Sopenharmony_ci pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 || 45753a5a1b3Sopenharmony_ci pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 || 45853a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.owner_module) < 0 || 45953a5a1b3Sopenharmony_ci pa_tagstruct_get_cvolume(t, &i.volume) < 0 || 46053a5a1b3Sopenharmony_ci pa_tagstruct_get_boolean(t, &mute) < 0 || 46153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.monitor_of_sink) < 0 || 46253a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.monitor_of_sink_name) < 0 || 46353a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.latency) < 0 || 46453a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.driver) < 0 || 46553a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &flags) < 0 || 46653a5a1b3Sopenharmony_ci (o->context->version >= 13 && 46753a5a1b3Sopenharmony_ci (pa_tagstruct_get_proplist(t, i.proplist) < 0 || 46853a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) || 46953a5a1b3Sopenharmony_ci (o->context->version >= 15 && 47053a5a1b3Sopenharmony_ci (pa_tagstruct_get_volume(t, &i.base_volume) < 0 || 47153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &state) < 0 || 47253a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.n_volume_steps) < 0 || 47353a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.card) < 0)) || 47453a5a1b3Sopenharmony_ci (o->context->version >= 16 && 47553a5a1b3Sopenharmony_ci (pa_tagstruct_getu32(t, &i.n_ports)))) { 47653a5a1b3Sopenharmony_ci 47753a5a1b3Sopenharmony_ci goto fail; 47853a5a1b3Sopenharmony_ci } 47953a5a1b3Sopenharmony_ci 48053a5a1b3Sopenharmony_ci if (o->context->version >= 16) { 48153a5a1b3Sopenharmony_ci if (i.n_ports > 0) { 48253a5a1b3Sopenharmony_ci i.ports = pa_xnew(pa_source_port_info*, i.n_ports+1); 48353a5a1b3Sopenharmony_ci i.ports[0] = pa_xnew(pa_source_port_info, i.n_ports); 48453a5a1b3Sopenharmony_ci 48553a5a1b3Sopenharmony_ci for (j = 0; j < i.n_ports; j++) { 48653a5a1b3Sopenharmony_ci i.ports[j] = &i.ports[0][j]; 48753a5a1b3Sopenharmony_ci 48853a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &i.ports[j]->name) < 0 || 48953a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.ports[j]->description) < 0 || 49053a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.ports[j]->priority) < 0) { 49153a5a1b3Sopenharmony_ci 49253a5a1b3Sopenharmony_ci goto fail; 49353a5a1b3Sopenharmony_ci } 49453a5a1b3Sopenharmony_ci 49553a5a1b3Sopenharmony_ci i.ports[j]->available = PA_PORT_AVAILABLE_UNKNOWN; 49653a5a1b3Sopenharmony_ci if (o->context->version >= 24) { 49753a5a1b3Sopenharmony_ci uint32_t av; 49853a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES) 49953a5a1b3Sopenharmony_ci goto fail; 50053a5a1b3Sopenharmony_ci i.ports[j]->available = av; 50153a5a1b3Sopenharmony_ci } 50253a5a1b3Sopenharmony_ci i.ports[j]->availability_group = NULL; 50353a5a1b3Sopenharmony_ci i.ports[j]->type = PA_DEVICE_PORT_TYPE_UNKNOWN; 50453a5a1b3Sopenharmony_ci if (o->context->version >= 34) { 50553a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &i.ports[j]->availability_group) < 0 || 50653a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.ports[j]->type)) 50753a5a1b3Sopenharmony_ci goto fail; 50853a5a1b3Sopenharmony_ci } 50953a5a1b3Sopenharmony_ci } 51053a5a1b3Sopenharmony_ci 51153a5a1b3Sopenharmony_ci i.ports[j] = NULL; 51253a5a1b3Sopenharmony_ci } 51353a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &ap) < 0) 51453a5a1b3Sopenharmony_ci goto fail; 51553a5a1b3Sopenharmony_ci 51653a5a1b3Sopenharmony_ci if (ap) { 51753a5a1b3Sopenharmony_ci for (j = 0; j < i.n_ports; j++) 51853a5a1b3Sopenharmony_ci if (pa_streq(i.ports[j]->name, ap)) { 51953a5a1b3Sopenharmony_ci i.active_port = i.ports[j]; 52053a5a1b3Sopenharmony_ci break; 52153a5a1b3Sopenharmony_ci } 52253a5a1b3Sopenharmony_ci } 52353a5a1b3Sopenharmony_ci } 52453a5a1b3Sopenharmony_ci 52553a5a1b3Sopenharmony_ci if (o->context->version >= 22) { 52653a5a1b3Sopenharmony_ci uint8_t n_formats; 52753a5a1b3Sopenharmony_ci if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1) 52853a5a1b3Sopenharmony_ci goto fail; 52953a5a1b3Sopenharmony_ci 53053a5a1b3Sopenharmony_ci i.formats = pa_xnew0(pa_format_info*, n_formats); 53153a5a1b3Sopenharmony_ci 53253a5a1b3Sopenharmony_ci for (j = 0; j < n_formats; j++) { 53353a5a1b3Sopenharmony_ci i.n_formats++; 53453a5a1b3Sopenharmony_ci i.formats[j] = pa_format_info_new(); 53553a5a1b3Sopenharmony_ci 53653a5a1b3Sopenharmony_ci if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0) 53753a5a1b3Sopenharmony_ci goto fail; 53853a5a1b3Sopenharmony_ci } 53953a5a1b3Sopenharmony_ci } 54053a5a1b3Sopenharmony_ci 54153a5a1b3Sopenharmony_ci i.mute = (int) mute; 54253a5a1b3Sopenharmony_ci i.flags = (pa_source_flags_t) flags; 54353a5a1b3Sopenharmony_ci i.state = (pa_source_state_t) state; 54453a5a1b3Sopenharmony_ci 54553a5a1b3Sopenharmony_ci if (o->callback) { 54653a5a1b3Sopenharmony_ci pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback; 54753a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 54853a5a1b3Sopenharmony_ci } 54953a5a1b3Sopenharmony_ci 55053a5a1b3Sopenharmony_ci if (i.formats) { 55153a5a1b3Sopenharmony_ci for (j = 0; j < i.n_formats; j++) 55253a5a1b3Sopenharmony_ci pa_format_info_free(i.formats[j]); 55353a5a1b3Sopenharmony_ci pa_xfree(i.formats); 55453a5a1b3Sopenharmony_ci } 55553a5a1b3Sopenharmony_ci if (i.ports) { 55653a5a1b3Sopenharmony_ci pa_xfree(i.ports[0]); 55753a5a1b3Sopenharmony_ci pa_xfree(i.ports); 55853a5a1b3Sopenharmony_ci } 55953a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 56053a5a1b3Sopenharmony_ci } 56153a5a1b3Sopenharmony_ci } 56253a5a1b3Sopenharmony_ci 56353a5a1b3Sopenharmony_ci if (o->callback) { 56453a5a1b3Sopenharmony_ci pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback; 56553a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 56653a5a1b3Sopenharmony_ci } 56753a5a1b3Sopenharmony_ci 56853a5a1b3Sopenharmony_cifinish: 56953a5a1b3Sopenharmony_ci pa_operation_done(o); 57053a5a1b3Sopenharmony_ci pa_operation_unref(o); 57153a5a1b3Sopenharmony_ci return; 57253a5a1b3Sopenharmony_ci 57353a5a1b3Sopenharmony_cifail: 57453a5a1b3Sopenharmony_ci pa_assert(i.proplist); 57553a5a1b3Sopenharmony_ci 57653a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 57753a5a1b3Sopenharmony_ci 57853a5a1b3Sopenharmony_ci if (i.formats) { 57953a5a1b3Sopenharmony_ci for (j = 0; j < i.n_formats; j++) 58053a5a1b3Sopenharmony_ci pa_format_info_free(i.formats[j]); 58153a5a1b3Sopenharmony_ci pa_xfree(i.formats); 58253a5a1b3Sopenharmony_ci } 58353a5a1b3Sopenharmony_ci if (i.ports) { 58453a5a1b3Sopenharmony_ci pa_xfree(i.ports[0]); 58553a5a1b3Sopenharmony_ci pa_xfree(i.ports); 58653a5a1b3Sopenharmony_ci } 58753a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 58853a5a1b3Sopenharmony_ci 58953a5a1b3Sopenharmony_ci goto finish; 59053a5a1b3Sopenharmony_ci} 59153a5a1b3Sopenharmony_ci 59253a5a1b3Sopenharmony_cipa_operation* pa_context_get_source_info_list(pa_context *c, pa_source_info_cb_t cb, void *userdata) { 59353a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_INFO_LIST, context_get_source_info_callback, (pa_operation_cb_t) cb, userdata); 59453a5a1b3Sopenharmony_ci} 59553a5a1b3Sopenharmony_ci 59653a5a1b3Sopenharmony_cipa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, pa_source_info_cb_t cb, void *userdata) { 59753a5a1b3Sopenharmony_ci pa_tagstruct *t; 59853a5a1b3Sopenharmony_ci pa_operation *o; 59953a5a1b3Sopenharmony_ci uint32_t tag; 60053a5a1b3Sopenharmony_ci 60153a5a1b3Sopenharmony_ci pa_assert(c); 60253a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 60353a5a1b3Sopenharmony_ci pa_assert(cb); 60453a5a1b3Sopenharmony_ci 60553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 60653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 60753a5a1b3Sopenharmony_ci 60853a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 60953a5a1b3Sopenharmony_ci 61053a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag); 61153a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 61253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 61353a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 61453a5a1b3Sopenharmony_ci 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); 61553a5a1b3Sopenharmony_ci 61653a5a1b3Sopenharmony_ci return o; 61753a5a1b3Sopenharmony_ci} 61853a5a1b3Sopenharmony_ci 61953a5a1b3Sopenharmony_cipa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name, pa_source_info_cb_t cb, void *userdata) { 62053a5a1b3Sopenharmony_ci pa_tagstruct *t; 62153a5a1b3Sopenharmony_ci pa_operation *o; 62253a5a1b3Sopenharmony_ci uint32_t tag; 62353a5a1b3Sopenharmony_ci 62453a5a1b3Sopenharmony_ci pa_assert(c); 62553a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 62653a5a1b3Sopenharmony_ci pa_assert(cb); 62753a5a1b3Sopenharmony_ci 62853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 62953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 63053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 63153a5a1b3Sopenharmony_ci 63253a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 63353a5a1b3Sopenharmony_ci 63453a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag); 63553a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 63653a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 63753a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 63853a5a1b3Sopenharmony_ci 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); 63953a5a1b3Sopenharmony_ci 64053a5a1b3Sopenharmony_ci return o; 64153a5a1b3Sopenharmony_ci} 64253a5a1b3Sopenharmony_ci 64353a5a1b3Sopenharmony_cipa_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) { 64453a5a1b3Sopenharmony_ci pa_operation *o; 64553a5a1b3Sopenharmony_ci pa_tagstruct *t; 64653a5a1b3Sopenharmony_ci uint32_t tag; 64753a5a1b3Sopenharmony_ci 64853a5a1b3Sopenharmony_ci pa_assert(c); 64953a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 65053a5a1b3Sopenharmony_ci 65153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 65253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 65353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 65453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED); 65553a5a1b3Sopenharmony_ci 65653a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 65753a5a1b3Sopenharmony_ci 65853a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_PORT, &tag); 65953a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 66053a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 66153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, port); 66253a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 66353a5a1b3Sopenharmony_ci 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); 66453a5a1b3Sopenharmony_ci 66553a5a1b3Sopenharmony_ci return o; 66653a5a1b3Sopenharmony_ci} 66753a5a1b3Sopenharmony_ci 66853a5a1b3Sopenharmony_cipa_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) { 66953a5a1b3Sopenharmony_ci pa_operation *o; 67053a5a1b3Sopenharmony_ci pa_tagstruct *t; 67153a5a1b3Sopenharmony_ci uint32_t tag; 67253a5a1b3Sopenharmony_ci 67353a5a1b3Sopenharmony_ci pa_assert(c); 67453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 67553a5a1b3Sopenharmony_ci 67653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 67753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 67853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 67953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED); 68053a5a1b3Sopenharmony_ci 68153a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 68253a5a1b3Sopenharmony_ci 68353a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_PORT, &tag); 68453a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 68553a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 68653a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, port); 68753a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 68853a5a1b3Sopenharmony_ci 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); 68953a5a1b3Sopenharmony_ci 69053a5a1b3Sopenharmony_ci return o; 69153a5a1b3Sopenharmony_ci} 69253a5a1b3Sopenharmony_ci 69353a5a1b3Sopenharmony_ci/*** Client info ***/ 69453a5a1b3Sopenharmony_ci 69553a5a1b3Sopenharmony_cistatic void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 69653a5a1b3Sopenharmony_ci pa_operation *o = userdata; 69753a5a1b3Sopenharmony_ci int eol = 1; 69853a5a1b3Sopenharmony_ci 69953a5a1b3Sopenharmony_ci pa_assert(pd); 70053a5a1b3Sopenharmony_ci pa_assert(o); 70153a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 70253a5a1b3Sopenharmony_ci 70353a5a1b3Sopenharmony_ci if (!o->context) 70453a5a1b3Sopenharmony_ci goto finish; 70553a5a1b3Sopenharmony_ci 70653a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 70753a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 70853a5a1b3Sopenharmony_ci goto finish; 70953a5a1b3Sopenharmony_ci 71053a5a1b3Sopenharmony_ci eol = -1; 71153a5a1b3Sopenharmony_ci } else { 71253a5a1b3Sopenharmony_ci 71353a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 71453a5a1b3Sopenharmony_ci pa_client_info i; 71553a5a1b3Sopenharmony_ci 71653a5a1b3Sopenharmony_ci pa_zero(i); 71753a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 71853a5a1b3Sopenharmony_ci 71953a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 72053a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 72153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.owner_module) < 0 || 72253a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.driver) < 0 || 72353a5a1b3Sopenharmony_ci (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) { 72453a5a1b3Sopenharmony_ci 72553a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 72653a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 72753a5a1b3Sopenharmony_ci goto finish; 72853a5a1b3Sopenharmony_ci } 72953a5a1b3Sopenharmony_ci 73053a5a1b3Sopenharmony_ci if (o->callback) { 73153a5a1b3Sopenharmony_ci pa_client_info_cb_t cb = (pa_client_info_cb_t) o->callback; 73253a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 73353a5a1b3Sopenharmony_ci } 73453a5a1b3Sopenharmony_ci 73553a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 73653a5a1b3Sopenharmony_ci } 73753a5a1b3Sopenharmony_ci } 73853a5a1b3Sopenharmony_ci 73953a5a1b3Sopenharmony_ci if (o->callback) { 74053a5a1b3Sopenharmony_ci pa_client_info_cb_t cb = (pa_client_info_cb_t) o->callback; 74153a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 74253a5a1b3Sopenharmony_ci } 74353a5a1b3Sopenharmony_ci 74453a5a1b3Sopenharmony_cifinish: 74553a5a1b3Sopenharmony_ci pa_operation_done(o); 74653a5a1b3Sopenharmony_ci pa_operation_unref(o); 74753a5a1b3Sopenharmony_ci} 74853a5a1b3Sopenharmony_ci 74953a5a1b3Sopenharmony_cipa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_info_cb_t cb, void *userdata) { 75053a5a1b3Sopenharmony_ci pa_tagstruct *t; 75153a5a1b3Sopenharmony_ci pa_operation *o; 75253a5a1b3Sopenharmony_ci uint32_t tag; 75353a5a1b3Sopenharmony_ci 75453a5a1b3Sopenharmony_ci pa_assert(c); 75553a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 75653a5a1b3Sopenharmony_ci pa_assert(cb); 75753a5a1b3Sopenharmony_ci 75853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 75953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 76053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 76153a5a1b3Sopenharmony_ci 76253a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 76353a5a1b3Sopenharmony_ci 76453a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_CLIENT_INFO, &tag); 76553a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 76653a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 76753a5a1b3Sopenharmony_ci 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); 76853a5a1b3Sopenharmony_ci 76953a5a1b3Sopenharmony_ci return o; 77053a5a1b3Sopenharmony_ci} 77153a5a1b3Sopenharmony_ci 77253a5a1b3Sopenharmony_cipa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t cb, void *userdata) { 77353a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_GET_CLIENT_INFO_LIST, context_get_client_info_callback, (pa_operation_cb_t) cb, userdata); 77453a5a1b3Sopenharmony_ci} 77553a5a1b3Sopenharmony_ci 77653a5a1b3Sopenharmony_ci/*** Card info ***/ 77753a5a1b3Sopenharmony_ci 77853a5a1b3Sopenharmony_cistatic void card_info_free(pa_card_info* i) { 77953a5a1b3Sopenharmony_ci if (i->proplist) 78053a5a1b3Sopenharmony_ci pa_proplist_free(i->proplist); 78153a5a1b3Sopenharmony_ci 78253a5a1b3Sopenharmony_ci pa_xfree(i->profiles); 78353a5a1b3Sopenharmony_ci 78453a5a1b3Sopenharmony_ci if (i->n_profiles) { 78553a5a1b3Sopenharmony_ci uint32_t j; 78653a5a1b3Sopenharmony_ci 78753a5a1b3Sopenharmony_ci for (j = 0; j < i->n_profiles; j++) 78853a5a1b3Sopenharmony_ci pa_xfree(i->profiles2[j]); 78953a5a1b3Sopenharmony_ci 79053a5a1b3Sopenharmony_ci pa_xfree(i->profiles2); 79153a5a1b3Sopenharmony_ci } 79253a5a1b3Sopenharmony_ci 79353a5a1b3Sopenharmony_ci if (i->ports) { 79453a5a1b3Sopenharmony_ci uint32_t j; 79553a5a1b3Sopenharmony_ci 79653a5a1b3Sopenharmony_ci for (j = 0; j < i->n_ports; j++) { 79753a5a1b3Sopenharmony_ci if (i->ports[j]) { 79853a5a1b3Sopenharmony_ci if (i->ports[j]->profiles) 79953a5a1b3Sopenharmony_ci pa_xfree(i->ports[j]->profiles); 80053a5a1b3Sopenharmony_ci if (i->ports[j]->profiles2) 80153a5a1b3Sopenharmony_ci pa_xfree(i->ports[j]->profiles2); 80253a5a1b3Sopenharmony_ci if (i->ports[j]->proplist) 80353a5a1b3Sopenharmony_ci pa_proplist_free(i->ports[j]->proplist); 80453a5a1b3Sopenharmony_ci } 80553a5a1b3Sopenharmony_ci } 80653a5a1b3Sopenharmony_ci 80753a5a1b3Sopenharmony_ci pa_xfree(i->ports[0]); 80853a5a1b3Sopenharmony_ci pa_xfree(i->ports); 80953a5a1b3Sopenharmony_ci } 81053a5a1b3Sopenharmony_ci} 81153a5a1b3Sopenharmony_ci 81253a5a1b3Sopenharmony_cistatic int fill_card_port_info(pa_context *context, pa_tagstruct* t, pa_card_info* i) { 81353a5a1b3Sopenharmony_ci uint32_t j, k, l; 81453a5a1b3Sopenharmony_ci 81553a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i->n_ports) < 0) 81653a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 81753a5a1b3Sopenharmony_ci 81853a5a1b3Sopenharmony_ci if (i->n_ports == 0) { 81953a5a1b3Sopenharmony_ci i->ports = NULL; 82053a5a1b3Sopenharmony_ci return 0; 82153a5a1b3Sopenharmony_ci } 82253a5a1b3Sopenharmony_ci 82353a5a1b3Sopenharmony_ci i->ports = pa_xnew0(pa_card_port_info*, i->n_ports+1); 82453a5a1b3Sopenharmony_ci i->ports[0] = pa_xnew0(pa_card_port_info, i->n_ports); 82553a5a1b3Sopenharmony_ci 82653a5a1b3Sopenharmony_ci for (j = 0; j < i->n_ports; j++) { 82753a5a1b3Sopenharmony_ci uint8_t direction; 82853a5a1b3Sopenharmony_ci uint32_t available; 82953a5a1b3Sopenharmony_ci pa_card_port_info* port = i->ports[j] = &i->ports[0][j]; 83053a5a1b3Sopenharmony_ci 83153a5a1b3Sopenharmony_ci port->proplist = pa_proplist_new(); 83253a5a1b3Sopenharmony_ci 83353a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &port->name) < 0 || 83453a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &port->description) < 0 || 83553a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &port->priority) < 0 || 83653a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &available) < 0 || 83753a5a1b3Sopenharmony_ci pa_tagstruct_getu8(t, &direction) < 0 || 83853a5a1b3Sopenharmony_ci !pa_direction_valid(direction) || 83953a5a1b3Sopenharmony_ci pa_tagstruct_get_proplist(t, port->proplist) < 0 || 84053a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &port->n_profiles) < 0) { 84153a5a1b3Sopenharmony_ci 84253a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 84353a5a1b3Sopenharmony_ci } 84453a5a1b3Sopenharmony_ci 84553a5a1b3Sopenharmony_ci if (available > PA_PORT_AVAILABLE_YES ) { 84653a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 84753a5a1b3Sopenharmony_ci } 84853a5a1b3Sopenharmony_ci 84953a5a1b3Sopenharmony_ci port->direction = direction; 85053a5a1b3Sopenharmony_ci port->available = available; 85153a5a1b3Sopenharmony_ci 85253a5a1b3Sopenharmony_ci if (port->n_profiles > 0) { 85353a5a1b3Sopenharmony_ci port->profiles = pa_xnew0(pa_card_profile_info*, i->n_profiles+1); 85453a5a1b3Sopenharmony_ci port->profiles2 = pa_xnew0(pa_card_profile_info2*, i->n_profiles+1); 85553a5a1b3Sopenharmony_ci 85653a5a1b3Sopenharmony_ci for (k = 0; k < port->n_profiles; k++) { 85753a5a1b3Sopenharmony_ci const char* profilename; 85853a5a1b3Sopenharmony_ci 85953a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &profilename) < 0) 86053a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 86153a5a1b3Sopenharmony_ci 86253a5a1b3Sopenharmony_ci for (l = 0; l < i->n_profiles; l++) { 86353a5a1b3Sopenharmony_ci if (pa_streq(i->profiles[l].name, profilename)) { 86453a5a1b3Sopenharmony_ci port->profiles[k] = &i->profiles[l]; 86553a5a1b3Sopenharmony_ci port->profiles2[k] = i->profiles2[l]; 86653a5a1b3Sopenharmony_ci break; 86753a5a1b3Sopenharmony_ci } 86853a5a1b3Sopenharmony_ci } 86953a5a1b3Sopenharmony_ci 87053a5a1b3Sopenharmony_ci if (l >= i->n_profiles) 87153a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 87253a5a1b3Sopenharmony_ci } 87353a5a1b3Sopenharmony_ci } 87453a5a1b3Sopenharmony_ci if (context->version >= 27) { 87553a5a1b3Sopenharmony_ci if (pa_tagstruct_gets64(t, &port->latency_offset) < 0) 87653a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 87753a5a1b3Sopenharmony_ci } else 87853a5a1b3Sopenharmony_ci port->latency_offset = 0; 87953a5a1b3Sopenharmony_ci 88053a5a1b3Sopenharmony_ci port->type = PA_DEVICE_PORT_TYPE_UNKNOWN; 88153a5a1b3Sopenharmony_ci if (context->version >= 34) { 88253a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &port->availability_group) < 0 || 88353a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &port->type) < 0) 88453a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 88553a5a1b3Sopenharmony_ci } else 88653a5a1b3Sopenharmony_ci port->availability_group = NULL; 88753a5a1b3Sopenharmony_ci } 88853a5a1b3Sopenharmony_ci 88953a5a1b3Sopenharmony_ci return 0; 89053a5a1b3Sopenharmony_ci} 89153a5a1b3Sopenharmony_ci 89253a5a1b3Sopenharmony_cistatic int fill_card_profile_info(pa_context *context, pa_tagstruct* t, pa_card_info* i) { 89353a5a1b3Sopenharmony_ci uint32_t j; 89453a5a1b3Sopenharmony_ci 89553a5a1b3Sopenharmony_ci i->profiles = pa_xnew0(pa_card_profile_info, i->n_profiles+1); 89653a5a1b3Sopenharmony_ci i->profiles2 = pa_xnew0(pa_card_profile_info2*, i->n_profiles+1); 89753a5a1b3Sopenharmony_ci 89853a5a1b3Sopenharmony_ci for (j = 0; j < i->n_profiles; j++) { 89953a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &i->profiles[j].name) < 0 || 90053a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i->profiles[j].description) < 0 || 90153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i->profiles[j].n_sinks) < 0 || 90253a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i->profiles[j].n_sources) < 0 || 90353a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i->profiles[j].priority) < 0) 90453a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 90553a5a1b3Sopenharmony_ci 90653a5a1b3Sopenharmony_ci i->profiles2[j] = pa_xnew0(pa_card_profile_info2, 1); 90753a5a1b3Sopenharmony_ci i->profiles2[j]->name = i->profiles[j].name; 90853a5a1b3Sopenharmony_ci i->profiles2[j]->description = i->profiles[j].description; 90953a5a1b3Sopenharmony_ci i->profiles2[j]->n_sinks = i->profiles[j].n_sinks; 91053a5a1b3Sopenharmony_ci i->profiles2[j]->n_sources = i->profiles[j].n_sources; 91153a5a1b3Sopenharmony_ci i->profiles2[j]->priority = i->profiles[j].priority; 91253a5a1b3Sopenharmony_ci i->profiles2[j]->available = 1; 91353a5a1b3Sopenharmony_ci 91453a5a1b3Sopenharmony_ci if (context->version >= 29) { 91553a5a1b3Sopenharmony_ci uint32_t av; 91653a5a1b3Sopenharmony_ci 91753a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &av) < 0) 91853a5a1b3Sopenharmony_ci return -PA_ERR_PROTOCOL; 91953a5a1b3Sopenharmony_ci 92053a5a1b3Sopenharmony_ci i->profiles2[j]->available = av; 92153a5a1b3Sopenharmony_ci } 92253a5a1b3Sopenharmony_ci } 92353a5a1b3Sopenharmony_ci 92453a5a1b3Sopenharmony_ci return 0; 92553a5a1b3Sopenharmony_ci} 92653a5a1b3Sopenharmony_ci 92753a5a1b3Sopenharmony_cistatic void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 92853a5a1b3Sopenharmony_ci pa_operation *o = userdata; 92953a5a1b3Sopenharmony_ci int eol = 1; 93053a5a1b3Sopenharmony_ci pa_card_info i; 93153a5a1b3Sopenharmony_ci 93253a5a1b3Sopenharmony_ci pa_assert(pd); 93353a5a1b3Sopenharmony_ci pa_assert(o); 93453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 93553a5a1b3Sopenharmony_ci 93653a5a1b3Sopenharmony_ci if (!o->context) 93753a5a1b3Sopenharmony_ci goto finish; 93853a5a1b3Sopenharmony_ci 93953a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 94053a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 94153a5a1b3Sopenharmony_ci goto finish; 94253a5a1b3Sopenharmony_ci 94353a5a1b3Sopenharmony_ci eol = -1; 94453a5a1b3Sopenharmony_ci } else { 94553a5a1b3Sopenharmony_ci 94653a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 94753a5a1b3Sopenharmony_ci uint32_t j; 94853a5a1b3Sopenharmony_ci const char*ap; 94953a5a1b3Sopenharmony_ci 95053a5a1b3Sopenharmony_ci pa_zero(i); 95153a5a1b3Sopenharmony_ci 95253a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 95353a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 95453a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.owner_module) < 0 || 95553a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.driver) < 0 || 95653a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.n_profiles) < 0) 95753a5a1b3Sopenharmony_ci goto fail; 95853a5a1b3Sopenharmony_ci 95953a5a1b3Sopenharmony_ci if (i.n_profiles > 0) { 96053a5a1b3Sopenharmony_ci if (fill_card_profile_info(o->context, t, &i) < 0) 96153a5a1b3Sopenharmony_ci goto fail; 96253a5a1b3Sopenharmony_ci } 96353a5a1b3Sopenharmony_ci 96453a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 96553a5a1b3Sopenharmony_ci 96653a5a1b3Sopenharmony_ci if (pa_tagstruct_gets(t, &ap) < 0 || 96753a5a1b3Sopenharmony_ci pa_tagstruct_get_proplist(t, i.proplist) < 0) { 96853a5a1b3Sopenharmony_ci 96953a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 97053a5a1b3Sopenharmony_ci card_info_free(&i); 97153a5a1b3Sopenharmony_ci goto finish; 97253a5a1b3Sopenharmony_ci } 97353a5a1b3Sopenharmony_ci 97453a5a1b3Sopenharmony_ci if (ap) { 97553a5a1b3Sopenharmony_ci for (j = 0; j < i.n_profiles; j++) 97653a5a1b3Sopenharmony_ci if (pa_streq(i.profiles[j].name, ap)) { 97753a5a1b3Sopenharmony_ci i.active_profile = &i.profiles[j]; 97853a5a1b3Sopenharmony_ci i.active_profile2 = i.profiles2[j]; 97953a5a1b3Sopenharmony_ci break; 98053a5a1b3Sopenharmony_ci } 98153a5a1b3Sopenharmony_ci } 98253a5a1b3Sopenharmony_ci 98353a5a1b3Sopenharmony_ci if (o->context->version >= 26) { 98453a5a1b3Sopenharmony_ci if (fill_card_port_info(o->context, t, &i) < 0) 98553a5a1b3Sopenharmony_ci goto fail; 98653a5a1b3Sopenharmony_ci } 98753a5a1b3Sopenharmony_ci 98853a5a1b3Sopenharmony_ci if (o->callback) { 98953a5a1b3Sopenharmony_ci pa_card_info_cb_t cb = (pa_card_info_cb_t) o->callback; 99053a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 99153a5a1b3Sopenharmony_ci } 99253a5a1b3Sopenharmony_ci 99353a5a1b3Sopenharmony_ci card_info_free(&i); 99453a5a1b3Sopenharmony_ci } 99553a5a1b3Sopenharmony_ci } 99653a5a1b3Sopenharmony_ci 99753a5a1b3Sopenharmony_ci if (o->callback) { 99853a5a1b3Sopenharmony_ci pa_card_info_cb_t cb = (pa_card_info_cb_t) o->callback; 99953a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 100053a5a1b3Sopenharmony_ci } 100153a5a1b3Sopenharmony_ci 100253a5a1b3Sopenharmony_cifinish: 100353a5a1b3Sopenharmony_ci pa_operation_done(o); 100453a5a1b3Sopenharmony_ci pa_operation_unref(o); 100553a5a1b3Sopenharmony_ci return; 100653a5a1b3Sopenharmony_ci 100753a5a1b3Sopenharmony_cifail: 100853a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 100953a5a1b3Sopenharmony_ci card_info_free(&i); 101053a5a1b3Sopenharmony_ci goto finish; 101153a5a1b3Sopenharmony_ci} 101253a5a1b3Sopenharmony_ci 101353a5a1b3Sopenharmony_cipa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_card_info_cb_t cb, void *userdata) { 101453a5a1b3Sopenharmony_ci pa_tagstruct *t; 101553a5a1b3Sopenharmony_ci pa_operation *o; 101653a5a1b3Sopenharmony_ci uint32_t tag; 101753a5a1b3Sopenharmony_ci 101853a5a1b3Sopenharmony_ci pa_assert(c); 101953a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 102053a5a1b3Sopenharmony_ci pa_assert(cb); 102153a5a1b3Sopenharmony_ci 102253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 102353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 102453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 102553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); 102653a5a1b3Sopenharmony_ci 102753a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 102853a5a1b3Sopenharmony_ci 102953a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_CARD_INFO, &tag); 103053a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 103153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 103253a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 103353a5a1b3Sopenharmony_ci 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); 103453a5a1b3Sopenharmony_ci 103553a5a1b3Sopenharmony_ci return o; 103653a5a1b3Sopenharmony_ci} 103753a5a1b3Sopenharmony_ci 103853a5a1b3Sopenharmony_cipa_operation* pa_context_get_card_info_by_name(pa_context *c, const char*name, pa_card_info_cb_t cb, void *userdata) { 103953a5a1b3Sopenharmony_ci pa_tagstruct *t; 104053a5a1b3Sopenharmony_ci pa_operation *o; 104153a5a1b3Sopenharmony_ci uint32_t tag; 104253a5a1b3Sopenharmony_ci 104353a5a1b3Sopenharmony_ci pa_assert(c); 104453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 104553a5a1b3Sopenharmony_ci pa_assert(cb); 104653a5a1b3Sopenharmony_ci 104753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 104853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 104953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 105053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); 105153a5a1b3Sopenharmony_ci 105253a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 105353a5a1b3Sopenharmony_ci 105453a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_CARD_INFO, &tag); 105553a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 105653a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 105753a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 105853a5a1b3Sopenharmony_ci 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); 105953a5a1b3Sopenharmony_ci 106053a5a1b3Sopenharmony_ci return o; 106153a5a1b3Sopenharmony_ci} 106253a5a1b3Sopenharmony_ci 106353a5a1b3Sopenharmony_cipa_operation* pa_context_get_card_info_list(pa_context *c, pa_card_info_cb_t cb, void *userdata) { 106453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); 106553a5a1b3Sopenharmony_ci 106653a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_GET_CARD_INFO_LIST, context_get_card_info_callback, (pa_operation_cb_t) cb, userdata); 106753a5a1b3Sopenharmony_ci} 106853a5a1b3Sopenharmony_ci 106953a5a1b3Sopenharmony_cipa_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) { 107053a5a1b3Sopenharmony_ci pa_operation *o; 107153a5a1b3Sopenharmony_ci pa_tagstruct *t; 107253a5a1b3Sopenharmony_ci uint32_t tag; 107353a5a1b3Sopenharmony_ci 107453a5a1b3Sopenharmony_ci pa_assert(c); 107553a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 107653a5a1b3Sopenharmony_ci 107753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 107853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 107953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 108053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); 108153a5a1b3Sopenharmony_ci 108253a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 108353a5a1b3Sopenharmony_ci 108453a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_CARD_PROFILE, &tag); 108553a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 108653a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 108753a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, profile); 108853a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 108953a5a1b3Sopenharmony_ci 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); 109053a5a1b3Sopenharmony_ci 109153a5a1b3Sopenharmony_ci return o; 109253a5a1b3Sopenharmony_ci} 109353a5a1b3Sopenharmony_ci 109453a5a1b3Sopenharmony_cipa_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) { 109553a5a1b3Sopenharmony_ci pa_operation *o; 109653a5a1b3Sopenharmony_ci pa_tagstruct *t; 109753a5a1b3Sopenharmony_ci uint32_t tag; 109853a5a1b3Sopenharmony_ci 109953a5a1b3Sopenharmony_ci pa_assert(c); 110053a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 110153a5a1b3Sopenharmony_ci 110253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 110353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 110453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 110553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); 110653a5a1b3Sopenharmony_ci 110753a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 110853a5a1b3Sopenharmony_ci 110953a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_CARD_PROFILE, &tag); 111053a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 111153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 111253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, profile); 111353a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 111453a5a1b3Sopenharmony_ci 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); 111553a5a1b3Sopenharmony_ci 111653a5a1b3Sopenharmony_ci return o; 111753a5a1b3Sopenharmony_ci} 111853a5a1b3Sopenharmony_ci 111953a5a1b3Sopenharmony_ci/*** Module info ***/ 112053a5a1b3Sopenharmony_ci 112153a5a1b3Sopenharmony_cistatic void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 112253a5a1b3Sopenharmony_ci pa_operation *o = userdata; 112353a5a1b3Sopenharmony_ci int eol = 1; 112453a5a1b3Sopenharmony_ci 112553a5a1b3Sopenharmony_ci pa_assert(pd); 112653a5a1b3Sopenharmony_ci pa_assert(o); 112753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 112853a5a1b3Sopenharmony_ci 112953a5a1b3Sopenharmony_ci if (!o->context) 113053a5a1b3Sopenharmony_ci goto finish; 113153a5a1b3Sopenharmony_ci 113253a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 113353a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 113453a5a1b3Sopenharmony_ci goto finish; 113553a5a1b3Sopenharmony_ci 113653a5a1b3Sopenharmony_ci eol = -1; 113753a5a1b3Sopenharmony_ci } else { 113853a5a1b3Sopenharmony_ci 113953a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 114053a5a1b3Sopenharmony_ci pa_module_info i; 114153a5a1b3Sopenharmony_ci bool auto_unload = false; 114253a5a1b3Sopenharmony_ci 114353a5a1b3Sopenharmony_ci pa_zero(i); 114453a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 114553a5a1b3Sopenharmony_ci 114653a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 114753a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 114853a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.argument) < 0 || 114953a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.n_used) < 0 || 115053a5a1b3Sopenharmony_ci (o->context->version < 15 && pa_tagstruct_get_boolean(t, &auto_unload) < 0) || 115153a5a1b3Sopenharmony_ci (o->context->version >= 15 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) { 115253a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 115353a5a1b3Sopenharmony_ci goto finish; 115453a5a1b3Sopenharmony_ci } 115553a5a1b3Sopenharmony_ci 115653a5a1b3Sopenharmony_ci i.auto_unload = (int) auto_unload; 115753a5a1b3Sopenharmony_ci 115853a5a1b3Sopenharmony_ci if (o->callback) { 115953a5a1b3Sopenharmony_ci pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback; 116053a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 116153a5a1b3Sopenharmony_ci } 116253a5a1b3Sopenharmony_ci 116353a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 116453a5a1b3Sopenharmony_ci } 116553a5a1b3Sopenharmony_ci } 116653a5a1b3Sopenharmony_ci 116753a5a1b3Sopenharmony_ci if (o->callback) { 116853a5a1b3Sopenharmony_ci pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback; 116953a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 117053a5a1b3Sopenharmony_ci } 117153a5a1b3Sopenharmony_ci 117253a5a1b3Sopenharmony_cifinish: 117353a5a1b3Sopenharmony_ci pa_operation_done(o); 117453a5a1b3Sopenharmony_ci pa_operation_unref(o); 117553a5a1b3Sopenharmony_ci} 117653a5a1b3Sopenharmony_ci 117753a5a1b3Sopenharmony_cipa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_info_cb_t cb, void *userdata) { 117853a5a1b3Sopenharmony_ci pa_tagstruct *t; 117953a5a1b3Sopenharmony_ci pa_operation *o; 118053a5a1b3Sopenharmony_ci uint32_t tag; 118153a5a1b3Sopenharmony_ci 118253a5a1b3Sopenharmony_ci pa_assert(c); 118353a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 118453a5a1b3Sopenharmony_ci pa_assert(cb); 118553a5a1b3Sopenharmony_ci 118653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 118753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 118853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 118953a5a1b3Sopenharmony_ci 119053a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 119153a5a1b3Sopenharmony_ci 119253a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_MODULE_INFO, &tag); 119353a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 119453a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 119553a5a1b3Sopenharmony_ci 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); 119653a5a1b3Sopenharmony_ci 119753a5a1b3Sopenharmony_ci return o; 119853a5a1b3Sopenharmony_ci} 119953a5a1b3Sopenharmony_ci 120053a5a1b3Sopenharmony_cipa_operation* pa_context_get_module_info_list(pa_context *c, pa_module_info_cb_t cb, void *userdata) { 120153a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_GET_MODULE_INFO_LIST, context_get_module_info_callback, (pa_operation_cb_t) cb, userdata); 120253a5a1b3Sopenharmony_ci} 120353a5a1b3Sopenharmony_ci 120453a5a1b3Sopenharmony_ci/*** Sink input info ***/ 120553a5a1b3Sopenharmony_ci 120653a5a1b3Sopenharmony_cistatic void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 120753a5a1b3Sopenharmony_ci pa_operation *o = userdata; 120853a5a1b3Sopenharmony_ci int eol = 1; 120953a5a1b3Sopenharmony_ci 121053a5a1b3Sopenharmony_ci pa_assert(pd); 121153a5a1b3Sopenharmony_ci pa_assert(o); 121253a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 121353a5a1b3Sopenharmony_ci 121453a5a1b3Sopenharmony_ci if (!o->context) 121553a5a1b3Sopenharmony_ci goto finish; 121653a5a1b3Sopenharmony_ci 121753a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 121853a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 121953a5a1b3Sopenharmony_ci goto finish; 122053a5a1b3Sopenharmony_ci 122153a5a1b3Sopenharmony_ci eol = -1; 122253a5a1b3Sopenharmony_ci } else { 122353a5a1b3Sopenharmony_ci 122453a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 122553a5a1b3Sopenharmony_ci pa_sink_input_info i; 122653a5a1b3Sopenharmony_ci bool mute = false, corked = false, has_volume = false, volume_writable = true; 122753a5a1b3Sopenharmony_ci 122853a5a1b3Sopenharmony_ci pa_zero(i); 122953a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 123053a5a1b3Sopenharmony_ci i.format = pa_format_info_new(); 123153a5a1b3Sopenharmony_ci 123253a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 123353a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 123453a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.owner_module) < 0 || 123553a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.client) < 0 || 123653a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.sink) < 0 || 123753a5a1b3Sopenharmony_ci pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 || 123853a5a1b3Sopenharmony_ci pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 || 123953a5a1b3Sopenharmony_ci pa_tagstruct_get_cvolume(t, &i.volume) < 0 || 124053a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.buffer_usec) < 0 || 124153a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.sink_usec) < 0 || 124253a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.resample_method) < 0 || 124353a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.driver) < 0 || 124453a5a1b3Sopenharmony_ci (o->context->version >= 11 && pa_tagstruct_get_boolean(t, &mute) < 0) || 124553a5a1b3Sopenharmony_ci (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) || 124653a5a1b3Sopenharmony_ci (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0) || 124753a5a1b3Sopenharmony_ci (o->context->version >= 20 && (pa_tagstruct_get_boolean(t, &has_volume) < 0 || 124853a5a1b3Sopenharmony_ci pa_tagstruct_get_boolean(t, &volume_writable) < 0)) || 124953a5a1b3Sopenharmony_ci (o->context->version >= 21 && pa_tagstruct_get_format_info(t, i.format) < 0)) { 125053a5a1b3Sopenharmony_ci 125153a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 125253a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 125353a5a1b3Sopenharmony_ci pa_format_info_free(i.format); 125453a5a1b3Sopenharmony_ci goto finish; 125553a5a1b3Sopenharmony_ci } 125653a5a1b3Sopenharmony_ci 125753a5a1b3Sopenharmony_ci i.mute = (int) mute; 125853a5a1b3Sopenharmony_ci i.corked = (int) corked; 125953a5a1b3Sopenharmony_ci i.has_volume = (int) has_volume; 126053a5a1b3Sopenharmony_ci i.volume_writable = (int) volume_writable; 126153a5a1b3Sopenharmony_ci 126253a5a1b3Sopenharmony_ci if (o->callback) { 126353a5a1b3Sopenharmony_ci pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback; 126453a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 126553a5a1b3Sopenharmony_ci } 126653a5a1b3Sopenharmony_ci 126753a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 126853a5a1b3Sopenharmony_ci pa_format_info_free(i.format); 126953a5a1b3Sopenharmony_ci } 127053a5a1b3Sopenharmony_ci } 127153a5a1b3Sopenharmony_ci 127253a5a1b3Sopenharmony_ci if (o->callback) { 127353a5a1b3Sopenharmony_ci pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback; 127453a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 127553a5a1b3Sopenharmony_ci } 127653a5a1b3Sopenharmony_ci 127753a5a1b3Sopenharmony_cifinish: 127853a5a1b3Sopenharmony_ci pa_operation_done(o); 127953a5a1b3Sopenharmony_ci pa_operation_unref(o); 128053a5a1b3Sopenharmony_ci} 128153a5a1b3Sopenharmony_ci 128253a5a1b3Sopenharmony_cipa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sink_input_info_cb_t cb, void *userdata) { 128353a5a1b3Sopenharmony_ci pa_tagstruct *t; 128453a5a1b3Sopenharmony_ci pa_operation *o; 128553a5a1b3Sopenharmony_ci uint32_t tag; 128653a5a1b3Sopenharmony_ci 128753a5a1b3Sopenharmony_ci pa_assert(c); 128853a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 128953a5a1b3Sopenharmony_ci pa_assert(cb); 129053a5a1b3Sopenharmony_ci 129153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 129253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 129353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 129453a5a1b3Sopenharmony_ci 129553a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 129653a5a1b3Sopenharmony_ci 129753a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INPUT_INFO, &tag); 129853a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 129953a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 130053a5a1b3Sopenharmony_ci 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); 130153a5a1b3Sopenharmony_ci 130253a5a1b3Sopenharmony_ci return o; 130353a5a1b3Sopenharmony_ci} 130453a5a1b3Sopenharmony_ci 130553a5a1b3Sopenharmony_cipa_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) { 130653a5a1b3Sopenharmony_ci 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); 130753a5a1b3Sopenharmony_ci} 130853a5a1b3Sopenharmony_ci 130953a5a1b3Sopenharmony_ci/*** Source output info ***/ 131053a5a1b3Sopenharmony_ci 131153a5a1b3Sopenharmony_cistatic void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 131253a5a1b3Sopenharmony_ci pa_operation *o = userdata; 131353a5a1b3Sopenharmony_ci int eol = 1; 131453a5a1b3Sopenharmony_ci 131553a5a1b3Sopenharmony_ci pa_assert(pd); 131653a5a1b3Sopenharmony_ci pa_assert(o); 131753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 131853a5a1b3Sopenharmony_ci 131953a5a1b3Sopenharmony_ci if (!o->context) 132053a5a1b3Sopenharmony_ci goto finish; 132153a5a1b3Sopenharmony_ci 132253a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 132353a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 132453a5a1b3Sopenharmony_ci goto finish; 132553a5a1b3Sopenharmony_ci 132653a5a1b3Sopenharmony_ci eol = -1; 132753a5a1b3Sopenharmony_ci } else { 132853a5a1b3Sopenharmony_ci 132953a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 133053a5a1b3Sopenharmony_ci pa_source_output_info i; 133153a5a1b3Sopenharmony_ci bool mute = false, corked = false, has_volume = false, volume_writable = true; 133253a5a1b3Sopenharmony_ci 133353a5a1b3Sopenharmony_ci pa_zero(i); 133453a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 133553a5a1b3Sopenharmony_ci i.format = pa_format_info_new(); 133653a5a1b3Sopenharmony_ci 133753a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 133853a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 133953a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.owner_module) < 0 || 134053a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.client) < 0 || 134153a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.source) < 0 || 134253a5a1b3Sopenharmony_ci pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 || 134353a5a1b3Sopenharmony_ci pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 || 134453a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.buffer_usec) < 0 || 134553a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.source_usec) < 0 || 134653a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.resample_method) < 0 || 134753a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.driver) < 0 || 134853a5a1b3Sopenharmony_ci (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) || 134953a5a1b3Sopenharmony_ci (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0) || 135053a5a1b3Sopenharmony_ci (o->context->version >= 22 && (pa_tagstruct_get_cvolume(t, &i.volume) < 0 || 135153a5a1b3Sopenharmony_ci pa_tagstruct_get_boolean(t, &mute) < 0 || 135253a5a1b3Sopenharmony_ci pa_tagstruct_get_boolean(t, &has_volume) < 0 || 135353a5a1b3Sopenharmony_ci pa_tagstruct_get_boolean(t, &volume_writable) < 0 || 135453a5a1b3Sopenharmony_ci pa_tagstruct_get_format_info(t, i.format) < 0))) { 135553a5a1b3Sopenharmony_ci 135653a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 135753a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 135853a5a1b3Sopenharmony_ci pa_format_info_free(i.format); 135953a5a1b3Sopenharmony_ci goto finish; 136053a5a1b3Sopenharmony_ci } 136153a5a1b3Sopenharmony_ci 136253a5a1b3Sopenharmony_ci i.mute = (int) mute; 136353a5a1b3Sopenharmony_ci i.corked = (int) corked; 136453a5a1b3Sopenharmony_ci i.has_volume = (int) has_volume; 136553a5a1b3Sopenharmony_ci i.volume_writable = (int) volume_writable; 136653a5a1b3Sopenharmony_ci 136753a5a1b3Sopenharmony_ci if (o->callback) { 136853a5a1b3Sopenharmony_ci pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback; 136953a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 137053a5a1b3Sopenharmony_ci } 137153a5a1b3Sopenharmony_ci 137253a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 137353a5a1b3Sopenharmony_ci pa_format_info_free(i.format); 137453a5a1b3Sopenharmony_ci } 137553a5a1b3Sopenharmony_ci } 137653a5a1b3Sopenharmony_ci 137753a5a1b3Sopenharmony_ci if (o->callback) { 137853a5a1b3Sopenharmony_ci pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback; 137953a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 138053a5a1b3Sopenharmony_ci } 138153a5a1b3Sopenharmony_ci 138253a5a1b3Sopenharmony_cifinish: 138353a5a1b3Sopenharmony_ci pa_operation_done(o); 138453a5a1b3Sopenharmony_ci pa_operation_unref(o); 138553a5a1b3Sopenharmony_ci} 138653a5a1b3Sopenharmony_ci 138753a5a1b3Sopenharmony_cipa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_source_output_info_cb_t cb, void *userdata) { 138853a5a1b3Sopenharmony_ci pa_tagstruct *t; 138953a5a1b3Sopenharmony_ci pa_operation *o; 139053a5a1b3Sopenharmony_ci uint32_t tag; 139153a5a1b3Sopenharmony_ci 139253a5a1b3Sopenharmony_ci pa_assert(c); 139353a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 139453a5a1b3Sopenharmony_ci pa_assert(cb); 139553a5a1b3Sopenharmony_ci 139653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 139753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 139853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 139953a5a1b3Sopenharmony_ci 140053a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 140153a5a1b3Sopenharmony_ci 140253a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO, &tag); 140353a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 140453a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 140553a5a1b3Sopenharmony_ci 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); 140653a5a1b3Sopenharmony_ci 140753a5a1b3Sopenharmony_ci return o; 140853a5a1b3Sopenharmony_ci} 140953a5a1b3Sopenharmony_ci 141053a5a1b3Sopenharmony_cipa_operation* pa_context_get_source_output_info_list(pa_context *c, pa_source_output_info_cb_t cb, void *userdata) { 141153a5a1b3Sopenharmony_ci 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); 141253a5a1b3Sopenharmony_ci} 141353a5a1b3Sopenharmony_ci 141453a5a1b3Sopenharmony_ci/*** Volume manipulation ***/ 141553a5a1b3Sopenharmony_ci 141653a5a1b3Sopenharmony_cipa_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) { 141753a5a1b3Sopenharmony_ci pa_operation *o; 141853a5a1b3Sopenharmony_ci pa_tagstruct *t; 141953a5a1b3Sopenharmony_ci uint32_t tag; 142053a5a1b3Sopenharmony_ci 142153a5a1b3Sopenharmony_ci pa_assert(c); 142253a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 142353a5a1b3Sopenharmony_ci pa_assert(volume); 142453a5a1b3Sopenharmony_ci 142553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 142653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 142753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); 142853a5a1b3Sopenharmony_ci 142953a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 143053a5a1b3Sopenharmony_ci 143153a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag); 143253a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 143353a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 143453a5a1b3Sopenharmony_ci pa_tagstruct_put_cvolume(t, volume); 143553a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 143653a5a1b3Sopenharmony_ci 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); 143753a5a1b3Sopenharmony_ci 143853a5a1b3Sopenharmony_ci return o; 143953a5a1b3Sopenharmony_ci} 144053a5a1b3Sopenharmony_ci 144153a5a1b3Sopenharmony_cipa_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) { 144253a5a1b3Sopenharmony_ci pa_operation *o; 144353a5a1b3Sopenharmony_ci pa_tagstruct *t; 144453a5a1b3Sopenharmony_ci uint32_t tag; 144553a5a1b3Sopenharmony_ci 144653a5a1b3Sopenharmony_ci pa_assert(c); 144753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 144853a5a1b3Sopenharmony_ci pa_assert(name); 144953a5a1b3Sopenharmony_ci pa_assert(volume); 145053a5a1b3Sopenharmony_ci 145153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 145253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 145353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); 145453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 145553a5a1b3Sopenharmony_ci 145653a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 145753a5a1b3Sopenharmony_ci 145853a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag); 145953a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 146053a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 146153a5a1b3Sopenharmony_ci pa_tagstruct_put_cvolume(t, volume); 146253a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 146353a5a1b3Sopenharmony_ci 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); 146453a5a1b3Sopenharmony_ci 146553a5a1b3Sopenharmony_ci return o; 146653a5a1b3Sopenharmony_ci} 146753a5a1b3Sopenharmony_ci 146853a5a1b3Sopenharmony_cipa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) { 146953a5a1b3Sopenharmony_ci pa_operation *o; 147053a5a1b3Sopenharmony_ci pa_tagstruct *t; 147153a5a1b3Sopenharmony_ci uint32_t tag; 147253a5a1b3Sopenharmony_ci 147353a5a1b3Sopenharmony_ci pa_assert(c); 147453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 147553a5a1b3Sopenharmony_ci 147653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 147753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 147853a5a1b3Sopenharmony_ci 147953a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 148053a5a1b3Sopenharmony_ci 148153a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_MUTE, &tag); 148253a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 148353a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 148453a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, mute); 148553a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 148653a5a1b3Sopenharmony_ci 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); 148753a5a1b3Sopenharmony_ci 148853a5a1b3Sopenharmony_ci return o; 148953a5a1b3Sopenharmony_ci} 149053a5a1b3Sopenharmony_ci 149153a5a1b3Sopenharmony_cipa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata) { 149253a5a1b3Sopenharmony_ci pa_operation *o; 149353a5a1b3Sopenharmony_ci pa_tagstruct *t; 149453a5a1b3Sopenharmony_ci uint32_t tag; 149553a5a1b3Sopenharmony_ci 149653a5a1b3Sopenharmony_ci pa_assert(c); 149753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 149853a5a1b3Sopenharmony_ci pa_assert(name); 149953a5a1b3Sopenharmony_ci 150053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 150153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 150253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 150353a5a1b3Sopenharmony_ci 150453a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 150553a5a1b3Sopenharmony_ci 150653a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_MUTE, &tag); 150753a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 150853a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 150953a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, mute); 151053a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 151153a5a1b3Sopenharmony_ci 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); 151253a5a1b3Sopenharmony_ci 151353a5a1b3Sopenharmony_ci return o; 151453a5a1b3Sopenharmony_ci} 151553a5a1b3Sopenharmony_ci 151653a5a1b3Sopenharmony_cipa_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) { 151753a5a1b3Sopenharmony_ci pa_operation *o; 151853a5a1b3Sopenharmony_ci pa_tagstruct *t; 151953a5a1b3Sopenharmony_ci uint32_t tag; 152053a5a1b3Sopenharmony_ci 152153a5a1b3Sopenharmony_ci pa_assert(c); 152253a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 152353a5a1b3Sopenharmony_ci pa_assert(volume); 152453a5a1b3Sopenharmony_ci 152553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 152653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 152753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 152853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); 152953a5a1b3Sopenharmony_ci 153053a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 153153a5a1b3Sopenharmony_ci 153253a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_VOLUME, &tag); 153353a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 153453a5a1b3Sopenharmony_ci pa_tagstruct_put_cvolume(t, volume); 153553a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 153653a5a1b3Sopenharmony_ci 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); 153753a5a1b3Sopenharmony_ci 153853a5a1b3Sopenharmony_ci return o; 153953a5a1b3Sopenharmony_ci} 154053a5a1b3Sopenharmony_ci 154153a5a1b3Sopenharmony_cipa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) { 154253a5a1b3Sopenharmony_ci pa_operation *o; 154353a5a1b3Sopenharmony_ci pa_tagstruct *t; 154453a5a1b3Sopenharmony_ci uint32_t tag; 154553a5a1b3Sopenharmony_ci 154653a5a1b3Sopenharmony_ci pa_assert(c); 154753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 154853a5a1b3Sopenharmony_ci 154953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 155053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 155153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 155253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED); 155353a5a1b3Sopenharmony_ci 155453a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 155553a5a1b3Sopenharmony_ci 155653a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_MUTE, &tag); 155753a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 155853a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, mute); 155953a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 156053a5a1b3Sopenharmony_ci 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); 156153a5a1b3Sopenharmony_ci 156253a5a1b3Sopenharmony_ci return o; 156353a5a1b3Sopenharmony_ci} 156453a5a1b3Sopenharmony_ci 156553a5a1b3Sopenharmony_cipa_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) { 156653a5a1b3Sopenharmony_ci pa_operation *o; 156753a5a1b3Sopenharmony_ci pa_tagstruct *t; 156853a5a1b3Sopenharmony_ci uint32_t tag; 156953a5a1b3Sopenharmony_ci 157053a5a1b3Sopenharmony_ci pa_assert(c); 157153a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 157253a5a1b3Sopenharmony_ci pa_assert(volume); 157353a5a1b3Sopenharmony_ci 157453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 157553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 157653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); 157753a5a1b3Sopenharmony_ci 157853a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 157953a5a1b3Sopenharmony_ci 158053a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag); 158153a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 158253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 158353a5a1b3Sopenharmony_ci pa_tagstruct_put_cvolume(t, volume); 158453a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 158553a5a1b3Sopenharmony_ci 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); 158653a5a1b3Sopenharmony_ci 158753a5a1b3Sopenharmony_ci return o; 158853a5a1b3Sopenharmony_ci} 158953a5a1b3Sopenharmony_ci 159053a5a1b3Sopenharmony_cipa_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) { 159153a5a1b3Sopenharmony_ci pa_operation *o; 159253a5a1b3Sopenharmony_ci pa_tagstruct *t; 159353a5a1b3Sopenharmony_ci uint32_t tag; 159453a5a1b3Sopenharmony_ci 159553a5a1b3Sopenharmony_ci pa_assert(c); 159653a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 159753a5a1b3Sopenharmony_ci pa_assert(name); 159853a5a1b3Sopenharmony_ci pa_assert(volume); 159953a5a1b3Sopenharmony_ci 160053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 160153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 160253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); 160353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 160453a5a1b3Sopenharmony_ci 160553a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 160653a5a1b3Sopenharmony_ci 160753a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag); 160853a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 160953a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 161053a5a1b3Sopenharmony_ci pa_tagstruct_put_cvolume(t, volume); 161153a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 161253a5a1b3Sopenharmony_ci 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); 161353a5a1b3Sopenharmony_ci 161453a5a1b3Sopenharmony_ci return o; 161553a5a1b3Sopenharmony_ci} 161653a5a1b3Sopenharmony_ci 161753a5a1b3Sopenharmony_cipa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) { 161853a5a1b3Sopenharmony_ci pa_operation *o; 161953a5a1b3Sopenharmony_ci pa_tagstruct *t; 162053a5a1b3Sopenharmony_ci uint32_t tag; 162153a5a1b3Sopenharmony_ci 162253a5a1b3Sopenharmony_ci pa_assert(c); 162353a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 162453a5a1b3Sopenharmony_ci 162553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 162653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 162753a5a1b3Sopenharmony_ci 162853a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 162953a5a1b3Sopenharmony_ci 163053a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_MUTE, &tag); 163153a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 163253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 163353a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, mute); 163453a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 163553a5a1b3Sopenharmony_ci 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); 163653a5a1b3Sopenharmony_ci 163753a5a1b3Sopenharmony_ci return o; 163853a5a1b3Sopenharmony_ci} 163953a5a1b3Sopenharmony_ci 164053a5a1b3Sopenharmony_cipa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata) { 164153a5a1b3Sopenharmony_ci pa_operation *o; 164253a5a1b3Sopenharmony_ci pa_tagstruct *t; 164353a5a1b3Sopenharmony_ci uint32_t tag; 164453a5a1b3Sopenharmony_ci 164553a5a1b3Sopenharmony_ci pa_assert(c); 164653a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 164753a5a1b3Sopenharmony_ci pa_assert(name); 164853a5a1b3Sopenharmony_ci 164953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 165053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 165153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); 165253a5a1b3Sopenharmony_ci 165353a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 165453a5a1b3Sopenharmony_ci 165553a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_MUTE, &tag); 165653a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 165753a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 165853a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, mute); 165953a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 166053a5a1b3Sopenharmony_ci 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); 166153a5a1b3Sopenharmony_ci 166253a5a1b3Sopenharmony_ci return o; 166353a5a1b3Sopenharmony_ci} 166453a5a1b3Sopenharmony_ci 166553a5a1b3Sopenharmony_cipa_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) { 166653a5a1b3Sopenharmony_ci pa_operation *o; 166753a5a1b3Sopenharmony_ci pa_tagstruct *t; 166853a5a1b3Sopenharmony_ci uint32_t tag; 166953a5a1b3Sopenharmony_ci 167053a5a1b3Sopenharmony_ci pa_assert(c); 167153a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 167253a5a1b3Sopenharmony_ci pa_assert(volume); 167353a5a1b3Sopenharmony_ci 167453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 167553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 167653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 167753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED); 167853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); 167953a5a1b3Sopenharmony_ci 168053a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 168153a5a1b3Sopenharmony_ci 168253a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_VOLUME, &tag); 168353a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 168453a5a1b3Sopenharmony_ci pa_tagstruct_put_cvolume(t, volume); 168553a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 168653a5a1b3Sopenharmony_ci 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); 168753a5a1b3Sopenharmony_ci 168853a5a1b3Sopenharmony_ci return o; 168953a5a1b3Sopenharmony_ci} 169053a5a1b3Sopenharmony_ci 169153a5a1b3Sopenharmony_cipa_operation* pa_context_set_source_output_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) { 169253a5a1b3Sopenharmony_ci pa_operation *o; 169353a5a1b3Sopenharmony_ci pa_tagstruct *t; 169453a5a1b3Sopenharmony_ci uint32_t tag; 169553a5a1b3Sopenharmony_ci 169653a5a1b3Sopenharmony_ci pa_assert(c); 169753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 169853a5a1b3Sopenharmony_ci 169953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 170053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 170153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 170253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED); 170353a5a1b3Sopenharmony_ci 170453a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 170553a5a1b3Sopenharmony_ci 170653a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_MUTE, &tag); 170753a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 170853a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, mute); 170953a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 171053a5a1b3Sopenharmony_ci 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); 171153a5a1b3Sopenharmony_ci 171253a5a1b3Sopenharmony_ci return o; 171353a5a1b3Sopenharmony_ci} 171453a5a1b3Sopenharmony_ci 171553a5a1b3Sopenharmony_ci/** Sample Cache **/ 171653a5a1b3Sopenharmony_ci 171753a5a1b3Sopenharmony_cistatic void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 171853a5a1b3Sopenharmony_ci pa_operation *o = userdata; 171953a5a1b3Sopenharmony_ci int eol = 1; 172053a5a1b3Sopenharmony_ci 172153a5a1b3Sopenharmony_ci pa_assert(pd); 172253a5a1b3Sopenharmony_ci pa_assert(o); 172353a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 172453a5a1b3Sopenharmony_ci 172553a5a1b3Sopenharmony_ci if (!o->context) 172653a5a1b3Sopenharmony_ci goto finish; 172753a5a1b3Sopenharmony_ci 172853a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 172953a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 173053a5a1b3Sopenharmony_ci goto finish; 173153a5a1b3Sopenharmony_ci 173253a5a1b3Sopenharmony_ci eol = -1; 173353a5a1b3Sopenharmony_ci } else { 173453a5a1b3Sopenharmony_ci 173553a5a1b3Sopenharmony_ci while (!pa_tagstruct_eof(t)) { 173653a5a1b3Sopenharmony_ci pa_sample_info i; 173753a5a1b3Sopenharmony_ci bool lazy = false; 173853a5a1b3Sopenharmony_ci 173953a5a1b3Sopenharmony_ci pa_zero(i); 174053a5a1b3Sopenharmony_ci i.proplist = pa_proplist_new(); 174153a5a1b3Sopenharmony_ci 174253a5a1b3Sopenharmony_ci if (pa_tagstruct_getu32(t, &i.index) < 0 || 174353a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.name) < 0 || 174453a5a1b3Sopenharmony_ci pa_tagstruct_get_cvolume(t, &i.volume) < 0 || 174553a5a1b3Sopenharmony_ci pa_tagstruct_get_usec(t, &i.duration) < 0 || 174653a5a1b3Sopenharmony_ci pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 || 174753a5a1b3Sopenharmony_ci pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 || 174853a5a1b3Sopenharmony_ci pa_tagstruct_getu32(t, &i.bytes) < 0 || 174953a5a1b3Sopenharmony_ci pa_tagstruct_get_boolean(t, &lazy) < 0 || 175053a5a1b3Sopenharmony_ci pa_tagstruct_gets(t, &i.filename) < 0 || 175153a5a1b3Sopenharmony_ci (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) { 175253a5a1b3Sopenharmony_ci 175353a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 175453a5a1b3Sopenharmony_ci goto finish; 175553a5a1b3Sopenharmony_ci } 175653a5a1b3Sopenharmony_ci 175753a5a1b3Sopenharmony_ci i.lazy = (int) lazy; 175853a5a1b3Sopenharmony_ci 175953a5a1b3Sopenharmony_ci if (o->callback) { 176053a5a1b3Sopenharmony_ci pa_sample_info_cb_t cb = (pa_sample_info_cb_t) o->callback; 176153a5a1b3Sopenharmony_ci cb(o->context, &i, 0, o->userdata); 176253a5a1b3Sopenharmony_ci } 176353a5a1b3Sopenharmony_ci 176453a5a1b3Sopenharmony_ci pa_proplist_free(i.proplist); 176553a5a1b3Sopenharmony_ci } 176653a5a1b3Sopenharmony_ci } 176753a5a1b3Sopenharmony_ci 176853a5a1b3Sopenharmony_ci if (o->callback) { 176953a5a1b3Sopenharmony_ci pa_sample_info_cb_t cb = (pa_sample_info_cb_t) o->callback; 177053a5a1b3Sopenharmony_ci cb(o->context, NULL, eol, o->userdata); 177153a5a1b3Sopenharmony_ci } 177253a5a1b3Sopenharmony_ci 177353a5a1b3Sopenharmony_cifinish: 177453a5a1b3Sopenharmony_ci pa_operation_done(o); 177553a5a1b3Sopenharmony_ci pa_operation_unref(o); 177653a5a1b3Sopenharmony_ci} 177753a5a1b3Sopenharmony_ci 177853a5a1b3Sopenharmony_cipa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name, pa_sample_info_cb_t cb, void *userdata) { 177953a5a1b3Sopenharmony_ci pa_tagstruct *t; 178053a5a1b3Sopenharmony_ci pa_operation *o; 178153a5a1b3Sopenharmony_ci uint32_t tag; 178253a5a1b3Sopenharmony_ci 178353a5a1b3Sopenharmony_ci pa_assert(c); 178453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 178553a5a1b3Sopenharmony_ci pa_assert(cb); 178653a5a1b3Sopenharmony_ci 178753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 178853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 178953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID); 179053a5a1b3Sopenharmony_ci 179153a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 179253a5a1b3Sopenharmony_ci 179353a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag); 179453a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 179553a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 179653a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 179753a5a1b3Sopenharmony_ci 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); 179853a5a1b3Sopenharmony_ci 179953a5a1b3Sopenharmony_ci return o; 180053a5a1b3Sopenharmony_ci} 180153a5a1b3Sopenharmony_ci 180253a5a1b3Sopenharmony_cipa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, pa_sample_info_cb_t cb, void *userdata) { 180353a5a1b3Sopenharmony_ci pa_tagstruct *t; 180453a5a1b3Sopenharmony_ci pa_operation *o; 180553a5a1b3Sopenharmony_ci uint32_t tag; 180653a5a1b3Sopenharmony_ci 180753a5a1b3Sopenharmony_ci pa_assert(c); 180853a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 180953a5a1b3Sopenharmony_ci pa_assert(cb); 181053a5a1b3Sopenharmony_ci 181153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 181253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 181353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 181453a5a1b3Sopenharmony_ci 181553a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 181653a5a1b3Sopenharmony_ci 181753a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag); 181853a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 181953a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 182053a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 182153a5a1b3Sopenharmony_ci 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); 182253a5a1b3Sopenharmony_ci 182353a5a1b3Sopenharmony_ci return o; 182453a5a1b3Sopenharmony_ci} 182553a5a1b3Sopenharmony_ci 182653a5a1b3Sopenharmony_cipa_operation* pa_context_get_sample_info_list(pa_context *c, pa_sample_info_cb_t cb, void *userdata) { 182753a5a1b3Sopenharmony_ci return pa_context_send_simple_command(c, PA_COMMAND_GET_SAMPLE_INFO_LIST, context_get_sample_info_callback, (pa_operation_cb_t) cb, userdata); 182853a5a1b3Sopenharmony_ci} 182953a5a1b3Sopenharmony_ci 183053a5a1b3Sopenharmony_cistatic pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx, pa_context_success_cb_t cb, void *userdata) { 183153a5a1b3Sopenharmony_ci pa_operation *o; 183253a5a1b3Sopenharmony_ci pa_tagstruct *t; 183353a5a1b3Sopenharmony_ci uint32_t tag; 183453a5a1b3Sopenharmony_ci 183553a5a1b3Sopenharmony_ci pa_assert(c); 183653a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 183753a5a1b3Sopenharmony_ci 183853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 183953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 184053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 184153a5a1b3Sopenharmony_ci 184253a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 184353a5a1b3Sopenharmony_ci 184453a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, command, &tag); 184553a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 184653a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 184753a5a1b3Sopenharmony_ci 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); 184853a5a1b3Sopenharmony_ci 184953a5a1b3Sopenharmony_ci return o; 185053a5a1b3Sopenharmony_ci} 185153a5a1b3Sopenharmony_ci 185253a5a1b3Sopenharmony_cipa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) { 185353a5a1b3Sopenharmony_ci return command_kill(c, PA_COMMAND_KILL_CLIENT, idx, cb, userdata); 185453a5a1b3Sopenharmony_ci} 185553a5a1b3Sopenharmony_ci 185653a5a1b3Sopenharmony_cipa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) { 185753a5a1b3Sopenharmony_ci return command_kill(c, PA_COMMAND_KILL_SINK_INPUT, idx, cb, userdata); 185853a5a1b3Sopenharmony_ci} 185953a5a1b3Sopenharmony_ci 186053a5a1b3Sopenharmony_cipa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) { 186153a5a1b3Sopenharmony_ci return command_kill(c, PA_COMMAND_KILL_SOURCE_OUTPUT, idx, cb, userdata); 186253a5a1b3Sopenharmony_ci} 186353a5a1b3Sopenharmony_ci 186453a5a1b3Sopenharmony_cistatic void context_index_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 186553a5a1b3Sopenharmony_ci pa_operation *o = userdata; 186653a5a1b3Sopenharmony_ci uint32_t idx; 186753a5a1b3Sopenharmony_ci 186853a5a1b3Sopenharmony_ci pa_assert(pd); 186953a5a1b3Sopenharmony_ci pa_assert(o); 187053a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 187153a5a1b3Sopenharmony_ci 187253a5a1b3Sopenharmony_ci if (!o->context) 187353a5a1b3Sopenharmony_ci goto finish; 187453a5a1b3Sopenharmony_ci 187553a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 187653a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 187753a5a1b3Sopenharmony_ci goto finish; 187853a5a1b3Sopenharmony_ci 187953a5a1b3Sopenharmony_ci idx = PA_INVALID_INDEX; 188053a5a1b3Sopenharmony_ci } else if (pa_tagstruct_getu32(t, &idx) || 188153a5a1b3Sopenharmony_ci !pa_tagstruct_eof(t)) { 188253a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 188353a5a1b3Sopenharmony_ci goto finish; 188453a5a1b3Sopenharmony_ci } 188553a5a1b3Sopenharmony_ci 188653a5a1b3Sopenharmony_ci if (o->callback) { 188753a5a1b3Sopenharmony_ci pa_context_index_cb_t cb = (pa_context_index_cb_t) o->callback; 188853a5a1b3Sopenharmony_ci cb(o->context, idx, o->userdata); 188953a5a1b3Sopenharmony_ci } 189053a5a1b3Sopenharmony_ci 189153a5a1b3Sopenharmony_cifinish: 189253a5a1b3Sopenharmony_ci pa_operation_done(o); 189353a5a1b3Sopenharmony_ci pa_operation_unref(o); 189453a5a1b3Sopenharmony_ci} 189553a5a1b3Sopenharmony_ci 189653a5a1b3Sopenharmony_cipa_operation* pa_context_load_module(pa_context *c, const char*name, const char *argument, pa_context_index_cb_t cb, void *userdata) { 189753a5a1b3Sopenharmony_ci pa_operation *o; 189853a5a1b3Sopenharmony_ci pa_tagstruct *t; 189953a5a1b3Sopenharmony_ci uint32_t tag; 190053a5a1b3Sopenharmony_ci 190153a5a1b3Sopenharmony_ci pa_assert(c); 190253a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 190353a5a1b3Sopenharmony_ci 190453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 190553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 190653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID); 190753a5a1b3Sopenharmony_ci 190853a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 190953a5a1b3Sopenharmony_ci 191053a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_LOAD_MODULE, &tag); 191153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, name); 191253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, argument); 191353a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 191453a5a1b3Sopenharmony_ci pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_index_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref); 191553a5a1b3Sopenharmony_ci 191653a5a1b3Sopenharmony_ci return o; 191753a5a1b3Sopenharmony_ci} 191853a5a1b3Sopenharmony_ci 191953a5a1b3Sopenharmony_cipa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) { 192053a5a1b3Sopenharmony_ci return command_kill(c, PA_COMMAND_UNLOAD_MODULE, idx, cb, userdata); 192153a5a1b3Sopenharmony_ci} 192253a5a1b3Sopenharmony_ci 192353a5a1b3Sopenharmony_cipa_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) { 192453a5a1b3Sopenharmony_ci pa_operation *o; 192553a5a1b3Sopenharmony_ci pa_tagstruct *t; 192653a5a1b3Sopenharmony_ci uint32_t tag; 192753a5a1b3Sopenharmony_ci 192853a5a1b3Sopenharmony_ci pa_assert(c); 192953a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 193053a5a1b3Sopenharmony_ci 193153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 193253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 193353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, card_name && *card_name, PA_ERR_INVALID); 193453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, port_name && *port_name, PA_ERR_INVALID); 193553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 27, PA_ERR_NOTSUPPORTED); 193653a5a1b3Sopenharmony_ci 193753a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 193853a5a1b3Sopenharmony_ci 193953a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SET_PORT_LATENCY_OFFSET, &tag); 194053a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 194153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, card_name); 194253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, port_name); 194353a5a1b3Sopenharmony_ci pa_tagstruct_puts64(t, offset); 194453a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 194553a5a1b3Sopenharmony_ci 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); 194653a5a1b3Sopenharmony_ci 194753a5a1b3Sopenharmony_ci return o; 194853a5a1b3Sopenharmony_ci} 194953a5a1b3Sopenharmony_ci 195053a5a1b3Sopenharmony_ci/*** Autoload stuff ***/ 195153a5a1b3Sopenharmony_ci 195253a5a1b3Sopenharmony_ciPA_WARN_REFERENCE(pa_context_get_autoload_info_by_name, "Module auto-loading no longer supported."); 195353a5a1b3Sopenharmony_ci 195453a5a1b3Sopenharmony_cipa_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) { 195553a5a1b3Sopenharmony_ci 195653a5a1b3Sopenharmony_ci pa_assert(c); 195753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 195853a5a1b3Sopenharmony_ci 195953a5a1b3Sopenharmony_ci PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE); 196053a5a1b3Sopenharmony_ci} 196153a5a1b3Sopenharmony_ci 196253a5a1b3Sopenharmony_ciPA_WARN_REFERENCE(pa_context_get_autoload_info_by_index, "Module auto-loading no longer supported."); 196353a5a1b3Sopenharmony_ci 196453a5a1b3Sopenharmony_cipa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, pa_autoload_info_cb_t cb, void *userdata) { 196553a5a1b3Sopenharmony_ci pa_assert(c); 196653a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 196753a5a1b3Sopenharmony_ci 196853a5a1b3Sopenharmony_ci PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE); 196953a5a1b3Sopenharmony_ci} 197053a5a1b3Sopenharmony_ci 197153a5a1b3Sopenharmony_ciPA_WARN_REFERENCE(pa_context_get_autoload_info_list, "Module auto-loading no longer supported."); 197253a5a1b3Sopenharmony_ci 197353a5a1b3Sopenharmony_cipa_operation* pa_context_get_autoload_info_list(pa_context *c, pa_autoload_info_cb_t cb, void *userdata) { 197453a5a1b3Sopenharmony_ci pa_assert(c); 197553a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 197653a5a1b3Sopenharmony_ci 197753a5a1b3Sopenharmony_ci PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE); 197853a5a1b3Sopenharmony_ci} 197953a5a1b3Sopenharmony_ci 198053a5a1b3Sopenharmony_ciPA_WARN_REFERENCE(pa_context_add_autoload, "Module auto-loading no longer supported."); 198153a5a1b3Sopenharmony_ci 198253a5a1b3Sopenharmony_cipa_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) { 198353a5a1b3Sopenharmony_ci pa_assert(c); 198453a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 198553a5a1b3Sopenharmony_ci 198653a5a1b3Sopenharmony_ci PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE); 198753a5a1b3Sopenharmony_ci} 198853a5a1b3Sopenharmony_ci 198953a5a1b3Sopenharmony_ciPA_WARN_REFERENCE(pa_context_remove_autoload_by_name, "Module auto-loading no longer supported."); 199053a5a1b3Sopenharmony_ci 199153a5a1b3Sopenharmony_cipa_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) { 199253a5a1b3Sopenharmony_ci pa_assert(c); 199353a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 199453a5a1b3Sopenharmony_ci 199553a5a1b3Sopenharmony_ci PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE); 199653a5a1b3Sopenharmony_ci} 199753a5a1b3Sopenharmony_ci 199853a5a1b3Sopenharmony_ciPA_WARN_REFERENCE(pa_context_remove_autoload_by_index, "Module auto-loading no longer supported."); 199953a5a1b3Sopenharmony_ci 200053a5a1b3Sopenharmony_cipa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void* userdata) { 200153a5a1b3Sopenharmony_ci pa_assert(c); 200253a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 200353a5a1b3Sopenharmony_ci 200453a5a1b3Sopenharmony_ci PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE); 200553a5a1b3Sopenharmony_ci} 200653a5a1b3Sopenharmony_ci 200753a5a1b3Sopenharmony_cipa_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) { 200853a5a1b3Sopenharmony_ci pa_operation *o; 200953a5a1b3Sopenharmony_ci pa_tagstruct *t; 201053a5a1b3Sopenharmony_ci uint32_t tag; 201153a5a1b3Sopenharmony_ci 201253a5a1b3Sopenharmony_ci pa_assert(c); 201353a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 201453a5a1b3Sopenharmony_ci 201553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 201653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 201753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED); 201853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 201953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, sink_name && *sink_name, PA_ERR_INVALID); 202053a5a1b3Sopenharmony_ci 202153a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 202253a5a1b3Sopenharmony_ci 202353a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SINK_INPUT, &tag); 202453a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 202553a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 202653a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, sink_name); 202753a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 202853a5a1b3Sopenharmony_ci 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); 202953a5a1b3Sopenharmony_ci 203053a5a1b3Sopenharmony_ci return o; 203153a5a1b3Sopenharmony_ci} 203253a5a1b3Sopenharmony_ci 203353a5a1b3Sopenharmony_cipa_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) { 203453a5a1b3Sopenharmony_ci pa_operation *o; 203553a5a1b3Sopenharmony_ci pa_tagstruct *t; 203653a5a1b3Sopenharmony_ci uint32_t tag; 203753a5a1b3Sopenharmony_ci 203853a5a1b3Sopenharmony_ci pa_assert(c); 203953a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 204053a5a1b3Sopenharmony_ci 204153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 204253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 204353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED); 204453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 204553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, sink_idx != PA_INVALID_INDEX, PA_ERR_INVALID); 204653a5a1b3Sopenharmony_ci 204753a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 204853a5a1b3Sopenharmony_ci 204953a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SINK_INPUT, &tag); 205053a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 205153a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, sink_idx); 205253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 205353a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 205453a5a1b3Sopenharmony_ci 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); 205553a5a1b3Sopenharmony_ci 205653a5a1b3Sopenharmony_ci return o; 205753a5a1b3Sopenharmony_ci} 205853a5a1b3Sopenharmony_ci 205953a5a1b3Sopenharmony_cipa_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) { 206053a5a1b3Sopenharmony_ci pa_operation *o; 206153a5a1b3Sopenharmony_ci pa_tagstruct *t; 206253a5a1b3Sopenharmony_ci uint32_t tag; 206353a5a1b3Sopenharmony_ci 206453a5a1b3Sopenharmony_ci pa_assert(c); 206553a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 206653a5a1b3Sopenharmony_ci 206753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 206853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 206953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED); 207053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 207153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, source_name && *source_name, PA_ERR_INVALID); 207253a5a1b3Sopenharmony_ci 207353a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 207453a5a1b3Sopenharmony_ci 207553a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SOURCE_OUTPUT, &tag); 207653a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 207753a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 207853a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, source_name); 207953a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 208053a5a1b3Sopenharmony_ci 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); 208153a5a1b3Sopenharmony_ci 208253a5a1b3Sopenharmony_ci return o; 208353a5a1b3Sopenharmony_ci} 208453a5a1b3Sopenharmony_ci 208553a5a1b3Sopenharmony_cipa_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) { 208653a5a1b3Sopenharmony_ci pa_operation *o; 208753a5a1b3Sopenharmony_ci pa_tagstruct *t; 208853a5a1b3Sopenharmony_ci uint32_t tag; 208953a5a1b3Sopenharmony_ci 209053a5a1b3Sopenharmony_ci pa_assert(c); 209153a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 209253a5a1b3Sopenharmony_ci 209353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 209453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 209553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED); 209653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); 209753a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, source_idx != PA_INVALID_INDEX, PA_ERR_INVALID); 209853a5a1b3Sopenharmony_ci 209953a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 210053a5a1b3Sopenharmony_ci 210153a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SOURCE_OUTPUT, &tag); 210253a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 210353a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, source_idx); 210453a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, NULL); 210553a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 210653a5a1b3Sopenharmony_ci 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); 210753a5a1b3Sopenharmony_ci 210853a5a1b3Sopenharmony_ci return o; 210953a5a1b3Sopenharmony_ci} 211053a5a1b3Sopenharmony_ci 211153a5a1b3Sopenharmony_cipa_operation* pa_context_suspend_sink_by_name(pa_context *c, const char *sink_name, int suspend, pa_context_success_cb_t cb, void* userdata) { 211253a5a1b3Sopenharmony_ci pa_operation *o; 211353a5a1b3Sopenharmony_ci pa_tagstruct *t; 211453a5a1b3Sopenharmony_ci uint32_t tag; 211553a5a1b3Sopenharmony_ci 211653a5a1b3Sopenharmony_ci pa_assert(c); 211753a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 211853a5a1b3Sopenharmony_ci 211953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 212053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 212153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED); 212253a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !sink_name || *sink_name, PA_ERR_INVALID); 212353a5a1b3Sopenharmony_ci 212453a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 212553a5a1b3Sopenharmony_ci 212653a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag); 212753a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 212853a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, sink_name); 212953a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, suspend); 213053a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 213153a5a1b3Sopenharmony_ci 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); 213253a5a1b3Sopenharmony_ci 213353a5a1b3Sopenharmony_ci return o; 213453a5a1b3Sopenharmony_ci} 213553a5a1b3Sopenharmony_ci 213653a5a1b3Sopenharmony_cipa_operation* pa_context_suspend_sink_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) { 213753a5a1b3Sopenharmony_ci pa_operation *o; 213853a5a1b3Sopenharmony_ci pa_tagstruct *t; 213953a5a1b3Sopenharmony_ci uint32_t tag; 214053a5a1b3Sopenharmony_ci 214153a5a1b3Sopenharmony_ci pa_assert(c); 214253a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 214353a5a1b3Sopenharmony_ci 214453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 214553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 214653a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED); 214753a5a1b3Sopenharmony_ci 214853a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 214953a5a1b3Sopenharmony_ci 215053a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag); 215153a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 215253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL); 215353a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, suspend); 215453a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 215553a5a1b3Sopenharmony_ci 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); 215653a5a1b3Sopenharmony_ci 215753a5a1b3Sopenharmony_ci return o; 215853a5a1b3Sopenharmony_ci} 215953a5a1b3Sopenharmony_ci 216053a5a1b3Sopenharmony_cipa_operation* pa_context_suspend_source_by_name(pa_context *c, const char *source_name, int suspend, pa_context_success_cb_t cb, void* userdata) { 216153a5a1b3Sopenharmony_ci pa_operation *o; 216253a5a1b3Sopenharmony_ci pa_tagstruct *t; 216353a5a1b3Sopenharmony_ci uint32_t tag; 216453a5a1b3Sopenharmony_ci 216553a5a1b3Sopenharmony_ci pa_assert(c); 216653a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 216753a5a1b3Sopenharmony_ci 216853a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 216953a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 217053a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED); 217153a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !source_name || *source_name, PA_ERR_INVALID); 217253a5a1b3Sopenharmony_ci 217353a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 217453a5a1b3Sopenharmony_ci 217553a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag); 217653a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, PA_INVALID_INDEX); 217753a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, source_name); 217853a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, suspend); 217953a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 218053a5a1b3Sopenharmony_ci 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); 218153a5a1b3Sopenharmony_ci 218253a5a1b3Sopenharmony_ci return o; 218353a5a1b3Sopenharmony_ci} 218453a5a1b3Sopenharmony_ci 218553a5a1b3Sopenharmony_cipa_operation* pa_context_suspend_source_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) { 218653a5a1b3Sopenharmony_ci pa_operation *o; 218753a5a1b3Sopenharmony_ci pa_tagstruct *t; 218853a5a1b3Sopenharmony_ci uint32_t tag; 218953a5a1b3Sopenharmony_ci 219053a5a1b3Sopenharmony_ci pa_assert(c); 219153a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 219253a5a1b3Sopenharmony_ci 219353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 219453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 219553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED); 219653a5a1b3Sopenharmony_ci 219753a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 219853a5a1b3Sopenharmony_ci 219953a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag); 220053a5a1b3Sopenharmony_ci pa_tagstruct_putu32(t, idx); 220153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL); 220253a5a1b3Sopenharmony_ci pa_tagstruct_put_boolean(t, suspend); 220353a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 220453a5a1b3Sopenharmony_ci 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); 220553a5a1b3Sopenharmony_ci 220653a5a1b3Sopenharmony_ci return o; 220753a5a1b3Sopenharmony_ci} 220853a5a1b3Sopenharmony_ci 220953a5a1b3Sopenharmony_ci/** Object response string processing **/ 221053a5a1b3Sopenharmony_ci 221153a5a1b3Sopenharmony_cistatic void context_string_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { 221253a5a1b3Sopenharmony_ci pa_operation *o = userdata; 221353a5a1b3Sopenharmony_ci const char *response; 221453a5a1b3Sopenharmony_ci int success = 1; 221553a5a1b3Sopenharmony_ci 221653a5a1b3Sopenharmony_ci pa_assert(pd); 221753a5a1b3Sopenharmony_ci pa_assert(o); 221853a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(o) >= 1); 221953a5a1b3Sopenharmony_ci 222053a5a1b3Sopenharmony_ci if (!o->context) 222153a5a1b3Sopenharmony_ci goto finish; 222253a5a1b3Sopenharmony_ci 222353a5a1b3Sopenharmony_ci if (command != PA_COMMAND_REPLY) { 222453a5a1b3Sopenharmony_ci if (pa_context_handle_error(o->context, command, t, false) < 0) 222553a5a1b3Sopenharmony_ci goto finish; 222653a5a1b3Sopenharmony_ci 222753a5a1b3Sopenharmony_ci success = 0; 222853a5a1b3Sopenharmony_ci response = ""; 222953a5a1b3Sopenharmony_ci } else if (pa_tagstruct_gets(t, &response) < 0 || 223053a5a1b3Sopenharmony_ci !pa_tagstruct_eof(t)) { 223153a5a1b3Sopenharmony_ci pa_context_fail(o->context, PA_ERR_PROTOCOL); 223253a5a1b3Sopenharmony_ci goto finish; 223353a5a1b3Sopenharmony_ci } 223453a5a1b3Sopenharmony_ci 223553a5a1b3Sopenharmony_ci if (!response) 223653a5a1b3Sopenharmony_ci response = ""; 223753a5a1b3Sopenharmony_ci 223853a5a1b3Sopenharmony_ci if (o->callback) { 223953a5a1b3Sopenharmony_ci char *response_copy; 224053a5a1b3Sopenharmony_ci pa_context_string_cb_t cb; 224153a5a1b3Sopenharmony_ci 224253a5a1b3Sopenharmony_ci response_copy = pa_xstrdup(response); 224353a5a1b3Sopenharmony_ci 224453a5a1b3Sopenharmony_ci cb = (pa_context_string_cb_t) o->callback; 224553a5a1b3Sopenharmony_ci cb(o->context, success, response_copy, o->userdata); 224653a5a1b3Sopenharmony_ci 224753a5a1b3Sopenharmony_ci pa_xfree(response_copy); 224853a5a1b3Sopenharmony_ci } 224953a5a1b3Sopenharmony_ci 225053a5a1b3Sopenharmony_cifinish: 225153a5a1b3Sopenharmony_ci pa_operation_done(o); 225253a5a1b3Sopenharmony_ci pa_operation_unref(o); 225353a5a1b3Sopenharmony_ci} 225453a5a1b3Sopenharmony_ci 225553a5a1b3Sopenharmony_cipa_operation* pa_context_send_message_to_object(pa_context *c, const char *object_path, const char *message, const char *message_parameters, pa_context_string_cb_t cb, void *userdata) { 225653a5a1b3Sopenharmony_ci pa_operation *o; 225753a5a1b3Sopenharmony_ci pa_tagstruct *t; 225853a5a1b3Sopenharmony_ci uint32_t tag; 225953a5a1b3Sopenharmony_ci 226053a5a1b3Sopenharmony_ci pa_assert(c); 226153a5a1b3Sopenharmony_ci pa_assert(PA_REFCNT_VALUE(c) >= 1); 226253a5a1b3Sopenharmony_ci 226353a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); 226453a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); 226553a5a1b3Sopenharmony_ci PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 35, PA_ERR_NOTSUPPORTED); 226653a5a1b3Sopenharmony_ci 226753a5a1b3Sopenharmony_ci o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); 226853a5a1b3Sopenharmony_ci 226953a5a1b3Sopenharmony_ci t = pa_tagstruct_command(c, PA_COMMAND_SEND_OBJECT_MESSAGE, &tag); 227053a5a1b3Sopenharmony_ci 227153a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, object_path); 227253a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, message); 227353a5a1b3Sopenharmony_ci pa_tagstruct_puts(t, message_parameters); 227453a5a1b3Sopenharmony_ci 227553a5a1b3Sopenharmony_ci pa_pstream_send_tagstruct(c->pstream, t); 227653a5a1b3Sopenharmony_ci pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_string_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref); 227753a5a1b3Sopenharmony_ci 227853a5a1b3Sopenharmony_ci return o; 227953a5a1b3Sopenharmony_ci} 2280