2018-06-01 11:28:31 +02:00
|
|
|
/* PipeWire
|
|
|
|
|
* Copyright (C) 2018 Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
#include <spa/param/props.h>
|
|
|
|
|
|
2019-01-14 13:01:47 +01:00
|
|
|
#include <pipewire/pipewire.h>
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
#include <pulse/introspect.h>
|
|
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
2018-12-04 16:36:49 +01:00
|
|
|
struct success_ack {
|
|
|
|
|
pa_context_success_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void on_success(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct success_ack *d = userdata;
|
|
|
|
|
pa_context *c = o->context;
|
|
|
|
|
if (d->cb)
|
|
|
|
|
d->cb(c, PA_OK, d->userdata);
|
|
|
|
|
pa_operation_done(o);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
struct sink_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_sink_info_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
struct global *global;
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-04 18:43:45 +02:00
|
|
|
static pa_sink_state_t node_state_to_sink(enum pw_node_state s)
|
|
|
|
|
{
|
|
|
|
|
switch(s) {
|
|
|
|
|
case PW_NODE_STATE_ERROR:
|
|
|
|
|
return PA_SINK_UNLINKED;
|
|
|
|
|
case PW_NODE_STATE_CREATING:
|
|
|
|
|
return PA_SINK_INIT;
|
|
|
|
|
case PW_NODE_STATE_SUSPENDED:
|
|
|
|
|
return PA_SINK_SUSPENDED;
|
|
|
|
|
case PW_NODE_STATE_IDLE:
|
|
|
|
|
return PA_SINK_IDLE;
|
|
|
|
|
case PW_NODE_STATE_RUNNING:
|
|
|
|
|
return PA_SINK_RUNNING;
|
|
|
|
|
default:
|
|
|
|
|
return PA_SINK_INVALID_STATE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
static int wait_global(pa_context *c, struct global *g, pa_operation *o)
|
|
|
|
|
{
|
|
|
|
|
if (g->init) {
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return -EBUSY;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int wait_globals(pa_context *c, pa_subscription_mask_t mask, pa_operation *o)
|
|
|
|
|
{
|
|
|
|
|
struct global *g;
|
|
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
|
|
|
|
if (!(g->mask & mask))
|
|
|
|
|
continue;
|
|
|
|
|
if (wait_global(c, g, o) < 0)
|
|
|
|
|
return -EBUSY;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
static void sink_callback(struct sink_data *d)
|
|
|
|
|
{
|
|
|
|
|
struct global *g = d->global;
|
2019-11-13 09:38:40 +01:00
|
|
|
struct pw_endpoint_info *info = g->info;
|
2019-08-12 12:31:55 +02:00
|
|
|
const char *str;
|
|
|
|
|
uint32_t n;
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_sink_info i;
|
2018-06-05 20:10:31 +02:00
|
|
|
pa_format_info ii[1];
|
|
|
|
|
pa_format_info *ip[1];
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
spa_zero(i);
|
2019-11-13 09:38:40 +01:00
|
|
|
if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_ENDPOINT_NAME)))
|
2019-08-12 12:31:55 +02:00
|
|
|
i.name = str;
|
|
|
|
|
else
|
|
|
|
|
i.name = "unknown";
|
2019-11-13 09:38:40 +01:00
|
|
|
pw_log_debug("sink %d %s monitor %d", g->id, i.name, g->endpoint_info.monitor);
|
2018-10-19 13:30:20 +02:00
|
|
|
i.index = g->id;
|
2019-11-13 09:38:40 +01:00
|
|
|
if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_ENDPOINT_NAME)))
|
2019-08-12 12:31:55 +02:00
|
|
|
i.description = str;
|
|
|
|
|
else
|
|
|
|
|
i.description = "unknown";
|
|
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
i.sample_spec.format = PA_SAMPLE_S16LE;
|
|
|
|
|
i.sample_spec.rate = 44100;
|
2019-11-13 09:38:40 +01:00
|
|
|
if (g->endpoint_info.n_channel_volumes)
|
|
|
|
|
i.sample_spec.channels = g->endpoint_info.n_channel_volumes;
|
2019-08-12 12:31:55 +02:00
|
|
|
else
|
|
|
|
|
i.sample_spec.channels = 2;
|
|
|
|
|
pa_channel_map_init_auto(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
2019-08-16 22:10:08 +02:00
|
|
|
i.owner_module = 0;
|
2019-08-12 12:31:55 +02:00
|
|
|
i.volume.channels = i.sample_spec.channels;
|
|
|
|
|
for (n = 0; n < i.volume.channels; n++)
|
2019-11-13 09:38:40 +01:00
|
|
|
i.volume.values[n] = g->endpoint_info.volume * g->endpoint_info.channel_volumes[n] * PA_VOLUME_NORM;
|
|
|
|
|
i.mute = g->endpoint_info.mute;
|
2019-11-18 13:12:28 +01:00
|
|
|
if (g->endpoint_info.monitor != SPA_ID_INVALID) {
|
|
|
|
|
i.monitor_source = g->endpoint_info.monitor;
|
|
|
|
|
i.monitor_source_name = "unknown";
|
|
|
|
|
} else {
|
|
|
|
|
i.monitor_source = PA_INVALID_INDEX;
|
|
|
|
|
i.monitor_source_name = NULL;
|
|
|
|
|
}
|
2018-10-19 13:30:20 +02:00
|
|
|
i.latency = 0;
|
|
|
|
|
i.driver = "PipeWire";
|
2018-12-20 13:08:09 +01:00
|
|
|
i.flags = PA_SINK_HARDWARE |
|
|
|
|
|
PA_SINK_HW_VOLUME_CTRL | PA_SINK_HW_MUTE_CTRL |
|
|
|
|
|
PA_SINK_LATENCY | PA_SINK_DYNAMIC_LATENCY |
|
|
|
|
|
PA_SINK_DECIBEL_VOLUME;
|
2018-10-19 13:30:20 +02:00
|
|
|
i.proplist = pa_proplist_new_dict(info->props);
|
|
|
|
|
i.configured_latency = 0;
|
2018-06-01 11:28:31 +02:00
|
|
|
i.base_volume = PA_VOLUME_NORM;
|
2019-11-07 16:04:42 +01:00
|
|
|
//i.state = node_state_to_sink(info->state);
|
2018-06-01 11:28:31 +02:00
|
|
|
i.n_volume_steps = PA_VOLUME_NORM+1;
|
2018-10-19 13:30:20 +02:00
|
|
|
i.card = PA_INVALID_INDEX;
|
|
|
|
|
i.n_ports = 0;
|
|
|
|
|
i.ports = NULL;
|
|
|
|
|
i.active_port = NULL;
|
2018-06-05 20:10:31 +02:00
|
|
|
i.n_formats = 1;
|
|
|
|
|
ii[0].encoding = PA_ENCODING_PCM;
|
|
|
|
|
ii[0].plist = pa_proplist_new();
|
|
|
|
|
ip[0] = ii;
|
|
|
|
|
i.formats = ip;
|
2018-06-01 11:28:31 +02:00
|
|
|
d->cb(d->context, &i, 0, d->userdata);
|
2018-11-29 17:30:24 +01:00
|
|
|
pa_proplist_free(i.proplist);
|
|
|
|
|
pa_proplist_free(ii[0].plist);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void sink_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct sink_data *d = userdata;
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_global(d->context, d->global, o) < 0)
|
|
|
|
|
return;
|
2018-06-01 11:28:31 +02:00
|
|
|
sink_callback(d);
|
|
|
|
|
d->cb(d->context, NULL, 1, d->userdata);
|
2018-06-05 20:10:31 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-05 20:10:31 +02:00
|
|
|
pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, pa_sink_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct sink_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
|
2018-09-21 16:46:51 +02:00
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SINK, name)) == NULL)
|
2018-06-05 20:10:31 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, sink_info, sizeof(struct sink_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
d->global = g;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2019-03-11 18:05:24 +01:00
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_sink_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct sink_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
2018-06-01 11:28:31 +02:00
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK))
|
2018-06-01 11:28:31 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, sink_info, sizeof(struct sink_data));
|
|
|
|
|
d = o->userdata;
|
2018-06-05 20:10:31 +02:00
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-06-01 11:28:31 +02:00
|
|
|
d->global = g;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2019-03-15 20:31:20 +01:00
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void sink_info_list(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct sink_data *d = userdata;
|
|
|
|
|
pa_context *c = d->context;
|
|
|
|
|
struct global *g;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_globals(c, PA_SUBSCRIPTION_MASK_SINK, o) < 0)
|
|
|
|
|
return;
|
2018-06-01 11:28:31 +02:00
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK))
|
2018-06-01 11:28:31 +02:00
|
|
|
continue;
|
|
|
|
|
d->global = g;
|
|
|
|
|
sink_callback(d);
|
|
|
|
|
}
|
|
|
|
|
d->cb(c, NULL, 1, d->userdata);
|
2018-06-05 20:10:31 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_sink_info_list(pa_context *c, pa_sink_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct sink_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, sink_info_list, sizeof(struct sink_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-12 12:31:55 +02:00
|
|
|
static void set_stream_volume(pa_context *c, pa_stream *s, const pa_cvolume *volume, bool mute)
|
2019-03-15 20:31:20 +01:00
|
|
|
{
|
2019-08-12 12:31:55 +02:00
|
|
|
uint32_t i, n_channel_volumes;
|
|
|
|
|
float channel_volumes[SPA_AUDIO_MAX_CHANNELS];
|
|
|
|
|
float *vols;
|
|
|
|
|
|
|
|
|
|
if (volume) {
|
|
|
|
|
for (i = 0; i < volume->channels; i++)
|
|
|
|
|
channel_volumes[i] = volume->values[i] / (float) PA_VOLUME_NORM;
|
|
|
|
|
vols = channel_volumes;
|
|
|
|
|
n_channel_volumes = volume->channels;
|
|
|
|
|
} else {
|
|
|
|
|
vols = s->channel_volumes;
|
|
|
|
|
n_channel_volumes = s->n_channel_volumes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (n_channel_volumes != s->n_channel_volumes ||
|
|
|
|
|
!memcmp(s->channel_volumes, vols, n_channel_volumes * sizeof(float)) ||
|
|
|
|
|
s->mute != mute) {
|
2019-08-13 18:46:27 +02:00
|
|
|
float val = s->mute ? 1.0f : 0.0f;
|
2019-03-18 16:11:23 +01:00
|
|
|
pw_stream_set_control(s->stream,
|
2019-08-12 12:31:55 +02:00
|
|
|
SPA_PROP_mute, 1, &val,
|
2019-08-13 18:46:27 +02:00
|
|
|
SPA_PROP_channelVolumes, n_channel_volumes, vols,
|
2019-03-18 16:11:23 +01:00
|
|
|
0);
|
|
|
|
|
}
|
2019-01-04 10:00:57 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
static void set_endpoint_volume(pa_context *c, struct global *g, const pa_cvolume *volume, bool mute)
|
2019-01-04 10:00:57 +01:00
|
|
|
{
|
|
|
|
|
char buf[1024];
|
|
|
|
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
|
2019-08-12 12:31:55 +02:00
|
|
|
uint32_t i, n_channel_volumes;
|
|
|
|
|
float channel_volumes[SPA_AUDIO_MAX_CHANNELS];
|
|
|
|
|
float *vols;
|
|
|
|
|
|
|
|
|
|
if (volume) {
|
|
|
|
|
for (i = 0; i < volume->channels; i++)
|
|
|
|
|
channel_volumes[i] = volume->values[i] / (float) PA_VOLUME_NORM;
|
|
|
|
|
vols = channel_volumes;
|
|
|
|
|
n_channel_volumes = volume->channels;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
if (n_channel_volumes == g->endpoint_info.n_channel_volumes &&
|
|
|
|
|
memcmp(g->endpoint_info.channel_volumes, vols, n_channel_volumes * sizeof(float)) == 0 &&
|
|
|
|
|
mute == g->endpoint_info.mute)
|
2019-08-12 12:31:55 +02:00
|
|
|
return;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
memcpy(g->endpoint_info.channel_volumes, vols, n_channel_volumes * sizeof(float));
|
|
|
|
|
g->endpoint_info.n_channel_volumes = n_channel_volumes;
|
2019-08-12 12:31:55 +02:00
|
|
|
} else {
|
2019-11-13 09:38:40 +01:00
|
|
|
n_channel_volumes = g->endpoint_info.n_channel_volumes;
|
|
|
|
|
vols = g->endpoint_info.channel_volumes;
|
|
|
|
|
if (mute == g->endpoint_info.mute)
|
2019-08-12 12:31:55 +02:00
|
|
|
return;
|
2019-03-18 16:11:23 +01:00
|
|
|
}
|
2019-11-13 09:38:40 +01:00
|
|
|
g->endpoint_info.mute = mute;
|
2019-08-12 12:31:55 +02:00
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
pw_endpoint_proxy_set_param((struct pw_endpoint_proxy*)g->proxy,
|
2019-08-12 12:31:55 +02:00
|
|
|
SPA_PARAM_Props, 0,
|
|
|
|
|
spa_pod_builder_add_object(&b,
|
|
|
|
|
SPA_TYPE_OBJECT_Props, SPA_PARAM_Props,
|
|
|
|
|
SPA_PROP_mute, SPA_POD_Bool(mute),
|
|
|
|
|
SPA_PROP_channelVolumes, SPA_POD_Array(sizeof(float),
|
|
|
|
|
SPA_TYPE_Float,
|
|
|
|
|
n_channel_volumes,
|
|
|
|
|
vols)));
|
2019-01-04 10:00:57 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-12 12:31:55 +02:00
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: index %d", c, idx);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, volume, g->endpoint_info.mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: name %s", c, name);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SINK, name)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, volume, g->endpoint_info.mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: index %d", c, idx);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, NULL, mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: name %s", c, name);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SINK, name)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, NULL, mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_suspend_sink_by_name(pa_context *c, const char *sink_name, int suspend, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_suspend_sink_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_sink_port_by_index(pa_context *c, uint32_t idx, const char*port, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_sink_port_by_name(pa_context *c, const char*name, const char*port, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct source_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_source_info_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
struct global *global;
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-04 18:43:45 +02:00
|
|
|
static pa_source_state_t node_state_to_source(enum pw_node_state s)
|
|
|
|
|
{
|
|
|
|
|
switch(s) {
|
|
|
|
|
case PW_NODE_STATE_ERROR:
|
|
|
|
|
return PA_SOURCE_UNLINKED;
|
|
|
|
|
case PW_NODE_STATE_CREATING:
|
|
|
|
|
return PA_SOURCE_INIT;
|
|
|
|
|
case PW_NODE_STATE_SUSPENDED:
|
|
|
|
|
return PA_SOURCE_SUSPENDED;
|
|
|
|
|
case PW_NODE_STATE_IDLE:
|
|
|
|
|
return PA_SOURCE_IDLE;
|
|
|
|
|
case PW_NODE_STATE_RUNNING:
|
|
|
|
|
return PA_SOURCE_RUNNING;
|
|
|
|
|
default:
|
|
|
|
|
return PA_SOURCE_INVALID_STATE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-01 11:28:31 +02:00
|
|
|
static void source_callback(struct source_data *d)
|
|
|
|
|
{
|
|
|
|
|
struct global *g = d->global;
|
2019-11-13 09:38:40 +01:00
|
|
|
struct pw_endpoint_info *info = g->info;
|
2019-08-12 12:31:55 +02:00
|
|
|
const char *str;
|
|
|
|
|
uint32_t n;
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_source_info i;
|
2018-07-04 18:43:45 +02:00
|
|
|
pa_format_info ii[1];
|
|
|
|
|
pa_format_info *ip[1];
|
2018-12-20 13:08:09 +01:00
|
|
|
enum pa_sink_flags flags;
|
|
|
|
|
|
|
|
|
|
flags = PA_SOURCE_LATENCY | PA_SOURCE_DYNAMIC_LATENCY |
|
|
|
|
|
PA_SOURCE_DECIBEL_VOLUME;
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
spa_zero(i);
|
2019-11-13 09:38:40 +01:00
|
|
|
if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_ENDPOINT_NAME)))
|
2019-08-12 12:31:55 +02:00
|
|
|
i.name = str;
|
|
|
|
|
else
|
|
|
|
|
i.name = "unknown";
|
2018-10-19 13:30:20 +02:00
|
|
|
i.index = g->id;
|
2019-11-13 09:38:40 +01:00
|
|
|
if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_ENDPOINT_NAME)))
|
2019-08-12 12:31:55 +02:00
|
|
|
i.description = str;
|
|
|
|
|
else
|
|
|
|
|
i.description = "unknown";
|
2018-10-19 13:30:20 +02:00
|
|
|
i.sample_spec.format = PA_SAMPLE_S16LE;
|
|
|
|
|
i.sample_spec.rate = 44100;
|
2019-11-13 09:38:40 +01:00
|
|
|
if (g->endpoint_info.n_channel_volumes)
|
|
|
|
|
i.sample_spec.channels = g->endpoint_info.n_channel_volumes;
|
2019-08-12 12:31:55 +02:00
|
|
|
else
|
|
|
|
|
i.sample_spec.channels = 2;
|
|
|
|
|
pa_channel_map_init_auto(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
2019-08-16 22:10:08 +02:00
|
|
|
i.owner_module = 0;
|
2019-08-12 12:31:55 +02:00
|
|
|
i.volume.channels = i.sample_spec.channels;
|
|
|
|
|
for (n = 0; n < i.volume.channels; n++)
|
2019-11-13 09:38:40 +01:00
|
|
|
i.volume.values[n] = g->endpoint_info.volume * g->endpoint_info.channel_volumes[n] * PA_VOLUME_NORM;
|
|
|
|
|
i.mute = g->endpoint_info.mute;
|
2019-11-18 13:12:28 +01:00
|
|
|
if (g->endpoint_info.monitor != SPA_ID_INVALID) {
|
|
|
|
|
i.monitor_of_sink = g->endpoint_info.monitor;
|
2018-12-11 16:37:30 +01:00
|
|
|
i.monitor_of_sink_name = "unknown";
|
|
|
|
|
} else {
|
|
|
|
|
i.monitor_of_sink = PA_INVALID_INDEX;
|
|
|
|
|
i.monitor_of_sink_name = NULL;
|
2018-12-20 13:08:09 +01:00
|
|
|
flags |= PA_SOURCE_HARDWARE | PA_SOURCE_HW_VOLUME_CTRL | PA_SOURCE_HW_MUTE_CTRL;
|
2018-12-11 16:37:30 +01:00
|
|
|
}
|
2018-10-19 13:30:20 +02:00
|
|
|
i.latency = 0;
|
|
|
|
|
i.driver = "PipeWire";
|
2018-12-20 13:08:09 +01:00
|
|
|
i.flags = flags;
|
2018-10-19 13:30:20 +02:00
|
|
|
i.proplist = pa_proplist_new_dict(info->props);
|
|
|
|
|
i.configured_latency = 0;
|
2018-06-01 11:28:31 +02:00
|
|
|
i.base_volume = PA_VOLUME_NORM;
|
2019-11-07 16:04:42 +01:00
|
|
|
//i.state = node_state_to_source(info->state);
|
2018-06-01 11:28:31 +02:00
|
|
|
i.n_volume_steps = PA_VOLUME_NORM+1;
|
2018-10-19 13:30:20 +02:00
|
|
|
i.card = PA_INVALID_INDEX;
|
|
|
|
|
i.n_ports = 0;
|
|
|
|
|
i.ports = NULL;
|
|
|
|
|
i.active_port = NULL;
|
2018-07-04 18:43:45 +02:00
|
|
|
i.n_formats = 1;
|
|
|
|
|
ii[0].encoding = PA_ENCODING_PCM;
|
|
|
|
|
ii[0].plist = pa_proplist_new();
|
|
|
|
|
ip[0] = ii;
|
|
|
|
|
i.formats = ip;
|
2018-06-01 11:28:31 +02:00
|
|
|
d->cb(d->context, &i, 0, d->userdata);
|
2018-11-29 17:30:24 +01:00
|
|
|
pa_proplist_free(i.proplist);
|
|
|
|
|
pa_proplist_free(ii[0].plist);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void source_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct source_data *d = userdata;
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_global(d->context, d->global, o) < 0)
|
|
|
|
|
return;
|
2018-06-01 11:28:31 +02:00
|
|
|
source_callback(d);
|
|
|
|
|
d->cb(d->context, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name, pa_source_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-11-28 13:38:37 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct source_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SOURCE, name)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, source_info, sizeof(struct source_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
d->global = g;
|
|
|
|
|
pa_operation_sync(o);
|
2019-03-11 18:05:24 +01:00
|
|
|
|
2018-11-28 13:38:37 +01:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, pa_source_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct source_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
2019-07-02 17:38:16 +02:00
|
|
|
pw_log_debug("context %p: index %d", c, idx);
|
|
|
|
|
|
2019-11-18 13:12:28 +01:00
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL ||
|
|
|
|
|
!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE))
|
2018-06-01 11:28:31 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, source_info, sizeof(struct source_data));
|
|
|
|
|
d = o->userdata;
|
2018-07-03 22:03:25 +02:00
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-06-01 11:28:31 +02:00
|
|
|
d->global = g;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2019-03-11 18:05:24 +01:00
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void source_info_list(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct source_data *d = userdata;
|
|
|
|
|
pa_context *c = d->context;
|
|
|
|
|
struct global *g;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_globals(c, PA_SUBSCRIPTION_MASK_SOURCE, o) < 0)
|
|
|
|
|
return;
|
2018-06-01 11:28:31 +02:00
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE))
|
2018-06-01 11:28:31 +02:00
|
|
|
continue;
|
|
|
|
|
d->global = g;
|
|
|
|
|
source_callback(d);
|
|
|
|
|
}
|
|
|
|
|
d->cb(c, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_source_info_list(pa_context *c, pa_source_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct source_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, source_info_list, sizeof(struct source_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: index %d", c, idx);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, volume, g->endpoint_info.mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: name %s", c, name);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SOURCE, name)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, volume, g->endpoint_info.mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: index %d", c, idx);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, NULL, mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-01-04 10:00:57 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
pw_log_debug("context %p: name %s", c, name);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SOURCE, name)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, NULL, mute);
|
2019-01-04 10:00:57 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_suspend_source_by_name(pa_context *c, const char *source_name, int suspend, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_suspend_source_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_port_by_index(pa_context *c, uint32_t idx, const char*port, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_port_by_name(pa_context *c, const char*name, const char*port, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
struct server_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_server_info_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
struct global *global;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void server_callback(struct server_data *d)
|
|
|
|
|
{
|
|
|
|
|
pa_context *c = d->context;
|
2019-01-10 09:31:37 +01:00
|
|
|
const struct pw_core_info *info = c->core_info;
|
2018-10-19 13:30:20 +02:00
|
|
|
pa_server_info i;
|
|
|
|
|
|
|
|
|
|
spa_zero(i);
|
|
|
|
|
i.user_name = info->user_name;
|
|
|
|
|
i.host_name = info->host_name;
|
|
|
|
|
i.server_version = info->version;
|
|
|
|
|
i.server_name = info->name;
|
|
|
|
|
i.sample_spec.format = PA_SAMPLE_S16LE;
|
|
|
|
|
i.sample_spec.rate = 44100;
|
|
|
|
|
i.sample_spec.channels = 2;
|
|
|
|
|
i.default_sink_name = "unknown";
|
|
|
|
|
i.default_source_name = "unknown";
|
|
|
|
|
i.cookie = info->cookie;
|
2019-08-12 12:31:55 +02:00
|
|
|
pa_channel_map_init_extend(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
2018-10-19 13:30:20 +02:00
|
|
|
d->cb(d->context, &i, d->userdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void server_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct server_data *d = userdata;
|
|
|
|
|
server_callback(d);
|
|
|
|
|
pa_operation_done(o);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-10-19 13:30:20 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct server_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, server_info, sizeof(struct server_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct module_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_module_info_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
struct global *global;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void module_callback(struct module_data *d)
|
|
|
|
|
{
|
|
|
|
|
struct global *g = d->global;
|
2018-11-29 17:30:24 +01:00
|
|
|
d->cb(d->context, &g->module_info.info, 0, d->userdata);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void module_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct module_data *d = userdata;
|
|
|
|
|
module_callback(d);
|
|
|
|
|
d->cb(d->context, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct module_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_MODULE))
|
2018-06-01 11:28:31 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, module_info, sizeof(struct module_data));
|
|
|
|
|
d = o->userdata;
|
2018-07-03 22:03:25 +02:00
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-06-01 11:28:31 +02:00
|
|
|
d->global = g;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void module_info_list(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct module_data *d = userdata;
|
|
|
|
|
pa_context *c = d->context;
|
|
|
|
|
struct global *g;
|
|
|
|
|
|
|
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_MODULE))
|
2018-06-01 11:28:31 +02:00
|
|
|
continue;
|
|
|
|
|
d->global = g;
|
|
|
|
|
module_callback(d);
|
|
|
|
|
}
|
|
|
|
|
d->cb(c, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_module_info_list(pa_context *c, pa_module_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct module_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, module_info_list, sizeof(struct module_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_load_module(pa_context *c, const char*name, const char *argument, pa_context_index_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct client_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_client_info_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
struct global *global;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void client_callback(struct client_data *d)
|
|
|
|
|
{
|
|
|
|
|
struct global *g = d->global;
|
2018-11-29 17:30:24 +01:00
|
|
|
d->cb(d->context, &g->client_info.info, 0, d->userdata);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void client_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct client_data *d = userdata;
|
|
|
|
|
client_callback(d);
|
|
|
|
|
d->cb(d->context, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct client_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_CLIENT))
|
2018-06-01 11:28:31 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, client_info, sizeof(struct client_data));
|
|
|
|
|
d = o->userdata;
|
2018-07-03 22:03:25 +02:00
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-06-01 11:28:31 +02:00
|
|
|
d->global = g;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void client_info_list(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct client_data *d = userdata;
|
|
|
|
|
pa_context *c = d->context;
|
|
|
|
|
struct global *g;
|
|
|
|
|
|
|
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_CLIENT))
|
2018-06-01 11:28:31 +02:00
|
|
|
continue;
|
|
|
|
|
d->global = g;
|
|
|
|
|
client_callback(d);
|
|
|
|
|
}
|
|
|
|
|
d->cb(c, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct client_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, client_info_list, sizeof(struct client_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-12-04 16:36:49 +01:00
|
|
|
struct global *g;
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_CLIENT))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-12-11 09:44:48 +01:00
|
|
|
pw_registry_destroy(c->registry, g->id);
|
2018-12-04 16:36:49 +01:00
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
struct card_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_card_info_cb_t cb;
|
2018-11-29 17:30:24 +01:00
|
|
|
pa_context_success_cb_t success_cb;
|
2018-10-19 13:30:20 +02:00
|
|
|
void *userdata;
|
2018-11-28 11:13:21 +01:00
|
|
|
struct global *global;
|
2018-11-29 17:30:24 +01:00
|
|
|
char *profile;
|
2018-10-19 13:30:20 +02:00
|
|
|
};
|
|
|
|
|
|
2018-11-28 11:13:21 +01:00
|
|
|
static void card_callback(struct card_data *d)
|
|
|
|
|
{
|
|
|
|
|
struct global *g = d->global;
|
2018-11-29 17:30:24 +01:00
|
|
|
pa_card_info *i = &g->card_info.info;
|
|
|
|
|
int n_profiles, j;
|
2019-03-15 20:31:20 +01:00
|
|
|
struct param *p;
|
2018-11-29 17:30:24 +01:00
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
n_profiles = g->card_info.n_profiles;
|
2018-11-29 17:30:24 +01:00
|
|
|
|
|
|
|
|
i->profiles = alloca(sizeof(pa_card_profile_info) * n_profiles);
|
|
|
|
|
i->profiles2 = alloca(sizeof(pa_card_profile_info2 *) * n_profiles);
|
|
|
|
|
i->n_profiles = 0;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
pw_log_debug("context %p: info for %d", g->context, g->id);
|
|
|
|
|
|
|
|
|
|
spa_list_for_each(p, &g->card_info.profiles, link) {
|
2018-11-29 17:30:24 +01:00
|
|
|
uint32_t id;
|
|
|
|
|
const char *name;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
if (spa_pod_parse_object(p->param,
|
2019-01-16 11:04:22 +01:00
|
|
|
SPA_TYPE_OBJECT_ParamProfile, NULL,
|
2019-01-18 13:39:37 +01:00
|
|
|
SPA_PARAM_PROFILE_index, SPA_POD_Int(&id),
|
|
|
|
|
SPA_PARAM_PROFILE_name, SPA_POD_String(&name)) < 0) {
|
2019-03-15 20:31:20 +01:00
|
|
|
pw_log_warn("device %d: can't parse profile", g->id);
|
2018-11-29 17:30:24 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
j = i->n_profiles++;
|
2018-11-29 17:30:24 +01:00
|
|
|
i->profiles[j].name = name;
|
|
|
|
|
i->profiles[j].description = name;
|
|
|
|
|
i->profiles[j].n_sinks = 1;
|
|
|
|
|
i->profiles[j].n_sources = 1;
|
|
|
|
|
i->profiles[j].priority = 1;
|
|
|
|
|
|
|
|
|
|
i->profiles2[j] = alloca(sizeof(pa_card_profile_info2));
|
|
|
|
|
i->profiles2[j]->name = i->profiles[j].name;
|
|
|
|
|
i->profiles2[j]->description = i->profiles[j].description;
|
|
|
|
|
i->profiles2[j]->n_sinks = i->profiles[j].n_sinks;
|
|
|
|
|
i->profiles2[j]->n_sources = i->profiles[j].n_sources;
|
|
|
|
|
i->profiles2[j]->priority = i->profiles[j].priority;
|
|
|
|
|
i->profiles2[j]->available = 1;
|
|
|
|
|
|
|
|
|
|
if (g->card_info.active_profile == id) {
|
|
|
|
|
i->active_profile = &i->profiles[j];
|
|
|
|
|
i->active_profile2 = i->profiles2[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
d->cb(d->context, i, 0, d->userdata);
|
2018-11-28 11:13:21 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-28 13:38:37 +01:00
|
|
|
static void card_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct card_data *d = userdata;
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_global(d->context, d->global, o) < 0)
|
|
|
|
|
return;
|
2018-11-28 13:38:37 +01:00
|
|
|
card_callback(d);
|
|
|
|
|
d->cb(d->context, NULL, 1, d->userdata);
|
|
|
|
|
pa_operation_done(o);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-11-28 13:38:37 +01:00
|
|
|
pa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_card_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct card_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
pw_log_debug("context %p: %u", c, idx);
|
|
|
|
|
|
2018-11-28 13:38:37 +01:00
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_CARD))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, card_info, sizeof(struct card_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
d->global = g;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-11-28 13:38:37 +01:00
|
|
|
pa_operation* pa_context_get_card_info_by_name(pa_context *c, const char *name, pa_card_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct card_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
pw_log_debug("context %p: %s", c, name);
|
|
|
|
|
|
2018-11-28 13:38:37 +01:00
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_CARD, name)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, card_info, sizeof(struct card_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
d->global = g;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-28 11:13:21 +01:00
|
|
|
static void card_info_list(pa_operation *o, void *userdata)
|
2018-10-19 13:30:20 +02:00
|
|
|
{
|
|
|
|
|
struct card_data *d = userdata;
|
2018-11-28 11:13:21 +01:00
|
|
|
pa_context *c = d->context;
|
|
|
|
|
struct global *g;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_globals(c, PA_SUBSCRIPTION_MASK_CARD, o) < 0)
|
|
|
|
|
return;
|
2018-11-28 11:13:21 +01:00
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_CARD))
|
|
|
|
|
continue;
|
|
|
|
|
d->global = g;
|
|
|
|
|
card_callback(d);
|
|
|
|
|
}
|
|
|
|
|
d->cb(c, NULL, 1, d->userdata);
|
2018-10-19 13:30:20 +02:00
|
|
|
pa_operation_done(o);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_card_info_list(pa_context *c, pa_card_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-10-19 13:30:20 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct card_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
2018-11-28 11:13:21 +01:00
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
pw_log_debug("context %p", c);
|
|
|
|
|
|
2018-11-28 11:13:21 +01:00
|
|
|
o = pa_operation_new(c, NULL, card_info_list, sizeof(struct card_data));
|
2018-10-19 13:30:20 +02:00
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-29 17:30:24 +01:00
|
|
|
static void card_profile(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct card_data *d = userdata;
|
|
|
|
|
struct global *g = d->global;
|
|
|
|
|
pa_context *c = d->context;
|
2019-01-07 15:04:34 +01:00
|
|
|
int res = 0;
|
|
|
|
|
uint32_t id = SPA_ID_INVALID;
|
2018-11-29 17:30:24 +01:00
|
|
|
char buf[1024];
|
|
|
|
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
|
2019-03-15 20:31:20 +01:00
|
|
|
struct param *p;
|
2018-11-29 17:30:24 +01:00
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
spa_list_for_each(p, &g->card_info.profiles, link) {
|
2018-11-29 17:30:24 +01:00
|
|
|
uint32_t test_id;
|
|
|
|
|
const char *name;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
if (spa_pod_parse_object(p->param,
|
2019-01-16 11:04:22 +01:00
|
|
|
SPA_TYPE_OBJECT_ParamProfile, NULL,
|
2019-01-18 13:39:37 +01:00
|
|
|
SPA_PARAM_PROFILE_index, SPA_POD_Int(&test_id),
|
|
|
|
|
SPA_PARAM_PROFILE_name, SPA_POD_String(&name)) < 0) {
|
2019-03-15 20:31:20 +01:00
|
|
|
pw_log_warn("device %d: can't parse profile", g->id);
|
2018-11-29 17:30:24 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, d->profile) == 0) {
|
|
|
|
|
id = test_id;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (id == SPA_ID_INVALID)
|
|
|
|
|
goto done;;
|
|
|
|
|
|
|
|
|
|
pw_device_proxy_set_param((struct pw_device_proxy*)g->proxy,
|
|
|
|
|
SPA_PARAM_Profile, 0,
|
2019-01-16 11:04:22 +01:00
|
|
|
spa_pod_builder_add_object(&b,
|
2018-11-29 17:30:24 +01:00
|
|
|
SPA_TYPE_OBJECT_ParamProfile, SPA_PARAM_Profile,
|
2019-01-18 13:39:37 +01:00
|
|
|
SPA_PARAM_PROFILE_index, SPA_POD_Int(id)));
|
2018-11-29 17:30:24 +01:00
|
|
|
res = 1;
|
|
|
|
|
done:
|
|
|
|
|
if (d->success_cb)
|
|
|
|
|
d->success_cb(c, res, d->userdata);
|
|
|
|
|
pa_operation_done(o);
|
|
|
|
|
free(d->profile);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_card_profile_by_index(pa_context *c, uint32_t idx, const char*profile, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-11-29 17:30:24 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct card_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_CARD))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
pw_log_debug("Card set profile %s", profile);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, card_profile, sizeof(struct card_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->success_cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
d->global = g;
|
|
|
|
|
d->profile = strdup(profile);
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_card_profile_by_name(pa_context *c, const char*name, const char*profile, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-12-14 16:42:36 +01:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct card_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_CARD, name)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
pw_log_debug("Card set profile %s", profile);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, card_profile, sizeof(struct card_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->success_cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
d->global = g;
|
|
|
|
|
d->profile = strdup(profile);
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_port_latency_offset(pa_context *c, const char *card_name, const char *port_name, int64_t offset, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-04 15:33:20 +02:00
|
|
|
static pa_stream *find_stream(pa_context *c, uint32_t idx)
|
|
|
|
|
{
|
|
|
|
|
pa_stream *s;
|
|
|
|
|
spa_list_for_each(s, &c->streams, link) {
|
|
|
|
|
if (pw_stream_get_node_id(s->stream) == idx)
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
struct sink_input_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_sink_input_info_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
struct global *global;
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
static void sink_input_callback(struct sink_input_data *d)
|
|
|
|
|
{
|
2019-07-16 18:53:34 +02:00
|
|
|
struct global *g = d->global, *cl;
|
2019-11-13 09:38:40 +01:00
|
|
|
struct pw_endpoint_info *info = g->info;
|
2018-12-04 11:48:15 +01:00
|
|
|
const char *name;
|
2019-08-12 12:31:55 +02:00
|
|
|
uint32_t n;
|
2018-06-05 20:10:31 +02:00
|
|
|
pa_sink_input_info i;
|
|
|
|
|
pa_format_info ii[1];
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_stream *s;
|
2018-06-05 20:10:31 +02:00
|
|
|
|
2018-10-19 16:57:03 +02:00
|
|
|
if (info == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-11-26 17:51:54 +01:00
|
|
|
s = find_stream(d->context, g->endpoint_info.node_id);
|
2018-07-04 15:33:20 +02:00
|
|
|
|
2018-12-04 11:48:15 +01:00
|
|
|
if (info->props) {
|
2019-05-24 15:47:05 +02:00
|
|
|
if ((name = spa_dict_lookup(info->props, PW_KEY_MEDIA_NAME)) == NULL &&
|
2019-08-12 12:31:55 +02:00
|
|
|
(name = spa_dict_lookup(info->props, PW_KEY_APP_NAME)) == NULL &&
|
2019-11-13 09:38:40 +01:00
|
|
|
(name = spa_dict_lookup(info->props, PW_KEY_ENDPOINT_NAME)) == NULL)
|
2019-08-12 12:31:55 +02:00
|
|
|
name = "unknown";
|
2018-12-04 11:48:15 +01:00
|
|
|
}
|
|
|
|
|
else
|
2019-08-12 12:31:55 +02:00
|
|
|
name = "unknown";
|
2018-12-04 11:48:15 +01:00
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
cl = pa_context_find_global(d->context, g->endpoint_info.client_id);
|
2018-12-04 16:34:58 +01:00
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
spa_zero(i);
|
|
|
|
|
i.index = g->id;
|
2019-08-12 12:31:55 +02:00
|
|
|
i.name = name;
|
2018-10-19 16:57:03 +02:00
|
|
|
i.owner_module = PA_INVALID_INDEX;
|
2019-11-13 09:38:40 +01:00
|
|
|
i.client = g->endpoint_info.client_id;
|
2018-11-28 11:13:21 +01:00
|
|
|
if (s) {
|
|
|
|
|
i.sink = s->device_index;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2019-07-16 18:53:34 +02:00
|
|
|
struct global *l;
|
2018-11-28 11:13:21 +01:00
|
|
|
l = pa_context_find_linked(d->context, g->id);
|
|
|
|
|
i.sink = l ? l->id : PA_INVALID_INDEX;
|
|
|
|
|
}
|
2018-10-19 13:30:20 +02:00
|
|
|
if (s && s->sample_spec.channels > 0) {
|
2018-07-04 18:43:45 +02:00
|
|
|
i.sample_spec = s->sample_spec;
|
2018-11-28 11:13:21 +01:00
|
|
|
if (s->channel_map.channels == s->sample_spec.channels)
|
|
|
|
|
i.channel_map = s->channel_map;
|
|
|
|
|
else
|
|
|
|
|
pa_channel_map_init_auto(&i.channel_map,
|
2019-08-12 12:31:55 +02:00
|
|
|
i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
2018-07-04 18:43:45 +02:00
|
|
|
i.format = s->format;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-10-19 13:30:20 +02:00
|
|
|
i.sample_spec.format = PA_SAMPLE_S16LE;
|
|
|
|
|
i.sample_spec.rate = 44100;
|
2019-11-13 09:38:40 +01:00
|
|
|
i.sample_spec.channels = g->endpoint_info.n_channel_volumes;
|
2019-08-12 12:31:55 +02:00
|
|
|
if (i.sample_spec.channels == 0)
|
|
|
|
|
i.sample_spec.channels = 2;
|
|
|
|
|
pa_channel_map_init_auto(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
2018-07-04 18:43:45 +02:00
|
|
|
ii[0].encoding = PA_ENCODING_PCM;
|
|
|
|
|
ii[0].plist = pa_proplist_new();
|
|
|
|
|
i.format = ii;
|
|
|
|
|
}
|
2019-03-15 20:31:20 +01:00
|
|
|
pa_cvolume_init(&i.volume);
|
2019-08-12 12:31:55 +02:00
|
|
|
i.volume.channels = i.sample_spec.channels;
|
|
|
|
|
for (n = 0; n < i.volume.channels; n++)
|
2019-11-13 09:38:40 +01:00
|
|
|
i.volume.values[n] = g->endpoint_info.volume * g->endpoint_info.channel_volumes[n] * PA_VOLUME_NORM;
|
2019-08-12 12:31:55 +02:00
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
i.mute = g->endpoint_info.mute;
|
2018-07-04 18:43:45 +02:00
|
|
|
i.buffer_usec = 0;
|
|
|
|
|
i.sink_usec = 0;
|
2018-07-03 22:03:25 +02:00
|
|
|
i.resample_method = "PipeWire resampler";
|
|
|
|
|
i.driver = "PipeWire";
|
2018-07-04 18:43:45 +02:00
|
|
|
i.proplist = pa_proplist_new_dict(info->props);
|
2018-12-04 16:34:58 +01:00
|
|
|
if (cl && cl->client_info.info.proplist)
|
|
|
|
|
pa_proplist_update(i.proplist, PA_UPDATE_MERGE, cl->client_info.info.proplist);
|
2018-07-03 22:03:25 +02:00
|
|
|
i.corked = false;
|
|
|
|
|
i.has_volume = true;
|
|
|
|
|
i.volume_writable = true;
|
2018-11-29 17:30:24 +01:00
|
|
|
|
2019-07-16 18:53:34 +02:00
|
|
|
pw_log_debug("context %p: sink info for %d sink:%d", g->context, i.index, i.sink);
|
|
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
d->cb(d->context, &i, 0, d->userdata);
|
2018-11-29 17:30:24 +01:00
|
|
|
|
|
|
|
|
pa_proplist_free(i.proplist);
|
2018-06-05 20:10:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void sink_input_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct sink_input_data *d = userdata;
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_global(d->context, d->global, o) < 0)
|
|
|
|
|
return;
|
2018-06-05 20:10:31 +02:00
|
|
|
sink_input_callback(d);
|
|
|
|
|
d->cb(d->context, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-05 20:10:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sink_input_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-06-05 20:10:31 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct sink_input_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
2018-10-19 16:57:03 +02:00
|
|
|
pw_log_debug("context %p: info for %d", c, idx);
|
|
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK_INPUT))
|
2018-06-05 20:10:31 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, sink_input_info, sizeof(struct sink_input_data));
|
|
|
|
|
d = o->userdata;
|
2018-07-03 22:03:25 +02:00
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-06-05 20:10:31 +02:00
|
|
|
d->global = g;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2019-03-15 20:31:20 +01:00
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void sink_input_info_list(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct sink_input_data *d = userdata;
|
|
|
|
|
pa_context *c = d->context;
|
|
|
|
|
struct global *g;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_globals(c, PA_SUBSCRIPTION_MASK_SINK_INPUT, o) < 0)
|
|
|
|
|
return;
|
2018-06-05 20:10:31 +02:00
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
2018-07-03 22:03:25 +02:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK_INPUT))
|
2018-06-05 20:10:31 +02:00
|
|
|
continue;
|
|
|
|
|
d->global = g;
|
|
|
|
|
sink_input_callback(d);
|
|
|
|
|
}
|
|
|
|
|
d->cb(c, NULL, 1, d->userdata);
|
2018-07-04 15:33:20 +02:00
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_sink_input_info_list(pa_context *c, pa_sink_input_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-06-05 20:10:31 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct sink_input_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
|
2018-10-19 16:57:03 +02:00
|
|
|
pw_log_debug("context %p", c);
|
|
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
o = pa_operation_new(c, NULL, sink_input_info_list, sizeof(struct sink_input_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2019-03-11 18:05:24 +01:00
|
|
|
|
2018-06-05 20:10:31 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_move_sink_input_by_name(pa_context *c, uint32_t idx, const char *sink_name, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_move_sink_input_by_index(pa_context *c, uint32_t idx, uint32_t sink_idx, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-07-03 22:03:25 +02:00
|
|
|
pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pa_stream *s;
|
2018-10-19 13:30:20 +02:00
|
|
|
struct global *g;
|
2018-07-03 22:03:25 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
2019-01-04 10:00:57 +01:00
|
|
|
pw_log_debug("contex %p: index %d", c, idx);
|
2018-07-03 22:03:25 +02:00
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
if ((s = find_stream(c, idx)) == NULL) {
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
2018-12-04 16:36:49 +01:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK_INPUT))
|
|
|
|
|
return NULL;
|
2018-10-19 13:30:20 +02:00
|
|
|
}
|
2018-07-03 22:03:25 +02:00
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
if (s) {
|
2019-08-12 12:31:55 +02:00
|
|
|
set_stream_volume(c, s, volume, s->mute);
|
2018-10-19 13:30:20 +02:00
|
|
|
}
|
|
|
|
|
else if (g) {
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, volume, g->endpoint_info.mute);
|
2018-10-19 13:30:20 +02:00
|
|
|
}
|
2018-07-03 22:03:25 +02:00
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-07-03 22:03:25 +02:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-07-03 22:03:25 +02:00
|
|
|
pa_stream *s;
|
2018-10-19 16:57:03 +02:00
|
|
|
struct global *g;
|
2018-07-03 22:03:25 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
2019-03-18 16:11:23 +01:00
|
|
|
pw_log_debug("contex %p: index %d", c, idx);
|
|
|
|
|
|
2018-10-19 16:57:03 +02:00
|
|
|
if ((s = find_stream(c, idx)) == NULL) {
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
2018-12-04 16:36:49 +01:00
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK_INPUT))
|
|
|
|
|
return NULL;
|
2018-10-19 16:57:03 +02:00
|
|
|
}
|
2018-07-03 22:03:25 +02:00
|
|
|
|
2018-10-19 16:57:03 +02:00
|
|
|
if (s) {
|
2019-08-12 12:31:55 +02:00
|
|
|
set_stream_volume(c, s, NULL, mute);
|
2018-10-19 16:57:03 +02:00
|
|
|
}
|
|
|
|
|
else if (g) {
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, NULL, mute);
|
2018-10-19 16:57:03 +02:00
|
|
|
}
|
2018-07-03 22:03:25 +02:00
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
2018-08-02 10:31:29 +02:00
|
|
|
pa_operation_sync(o);
|
2018-07-03 22:03:25 +02:00
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-12-04 16:36:49 +01:00
|
|
|
pa_stream *s;
|
|
|
|
|
struct global *g;
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
if ((s = find_stream(c, idx)) == NULL) {
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK_INPUT))
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
|
pw_stream_destroy(s->stream);
|
|
|
|
|
}
|
|
|
|
|
else if (g) {
|
2019-12-11 09:44:48 +01:00
|
|
|
pw_registry_destroy(c->registry, g->id);
|
2018-12-04 16:36:49 +01:00
|
|
|
}
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
struct source_output_data {
|
|
|
|
|
pa_context *context;
|
|
|
|
|
pa_source_output_info_cb_t cb;
|
|
|
|
|
void *userdata;
|
|
|
|
|
struct global *global;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void source_output_callback(struct source_output_data *d)
|
|
|
|
|
{
|
2018-12-04 16:34:58 +01:00
|
|
|
struct global *g = d->global, *l, *cl;
|
2019-11-13 09:38:40 +01:00
|
|
|
struct pw_endpoint_info *info = g->info;
|
2019-08-12 12:31:55 +02:00
|
|
|
const char *name = NULL;
|
|
|
|
|
uint32_t n;
|
2018-10-19 13:30:20 +02:00
|
|
|
pa_source_output_info i;
|
|
|
|
|
pa_format_info ii[1];
|
|
|
|
|
pa_stream *s;
|
|
|
|
|
|
|
|
|
|
pw_log_debug("index %d", g->id);
|
2018-10-19 16:57:03 +02:00
|
|
|
if (info == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-11-26 17:51:54 +01:00
|
|
|
s = find_stream(d->context, g->endpoint_info.node_id);
|
2018-10-19 13:30:20 +02:00
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
name = info->name;
|
|
|
|
|
if (name == NULL && info->props) {
|
2019-05-24 15:47:05 +02:00
|
|
|
if ((name = spa_dict_lookup(info->props, PW_KEY_MEDIA_NAME)) == NULL &&
|
2019-08-12 12:31:55 +02:00
|
|
|
(name = spa_dict_lookup(info->props, PW_KEY_APP_NAME)) == NULL &&
|
2019-11-15 18:21:04 +01:00
|
|
|
(name = spa_dict_lookup(info->props, PW_KEY_ENDPOINT_NAME)) == NULL)
|
2019-08-12 12:31:55 +02:00
|
|
|
name = NULL;
|
2018-12-04 11:48:15 +01:00
|
|
|
}
|
2019-08-12 12:31:55 +02:00
|
|
|
if (name == NULL)
|
|
|
|
|
name = "unknown";
|
2018-12-04 11:48:15 +01:00
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
cl = pa_context_find_global(d->context, g->endpoint_info.client_id);
|
2018-12-04 16:34:58 +01:00
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
spa_zero(i);
|
|
|
|
|
i.index = g->id;
|
2018-12-04 11:48:15 +01:00
|
|
|
i.name = name ? name : "Unknown";
|
2018-10-19 16:57:03 +02:00
|
|
|
i.owner_module = PA_INVALID_INDEX;
|
2019-11-13 09:38:40 +01:00
|
|
|
i.client = g->endpoint_info.client_id;
|
2018-11-28 11:13:21 +01:00
|
|
|
if (s) {
|
|
|
|
|
i.source = s->device_index;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
l = pa_context_find_linked(d->context, g->id);
|
|
|
|
|
i.source = l ? l->id : PA_INVALID_INDEX;
|
|
|
|
|
}
|
2018-10-19 13:30:20 +02:00
|
|
|
if (s && s->sample_spec.channels > 0) {
|
|
|
|
|
i.sample_spec = s->sample_spec;
|
2018-11-28 11:13:21 +01:00
|
|
|
if (s->channel_map.channels == s->sample_spec.channels)
|
|
|
|
|
i.channel_map = s->channel_map;
|
|
|
|
|
else
|
|
|
|
|
pa_channel_map_init_auto(&i.channel_map,
|
2019-08-12 12:31:55 +02:00
|
|
|
i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
2018-10-19 13:30:20 +02:00
|
|
|
i.format = s->format;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
i.sample_spec.format = PA_SAMPLE_S16LE;
|
|
|
|
|
i.sample_spec.rate = 44100;
|
2019-11-13 09:38:40 +01:00
|
|
|
i.sample_spec.channels = g->endpoint_info.n_channel_volumes;
|
2019-08-12 12:31:55 +02:00
|
|
|
if (i.sample_spec.channels == 0)
|
|
|
|
|
i.sample_spec.channels = 2;
|
|
|
|
|
pa_channel_map_init_auto(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
2018-10-19 13:30:20 +02:00
|
|
|
ii[0].encoding = PA_ENCODING_PCM;
|
|
|
|
|
ii[0].plist = pa_proplist_new();
|
|
|
|
|
i.format = ii;
|
|
|
|
|
}
|
2019-03-15 20:31:20 +01:00
|
|
|
pa_cvolume_init(&i.volume);
|
2019-08-12 12:31:55 +02:00
|
|
|
i.volume.channels = i.sample_spec.channels;
|
|
|
|
|
for (n = 0; n < i.volume.channels; n++)
|
2019-11-13 09:38:40 +01:00
|
|
|
i.volume.values[n] = g->endpoint_info.volume * g->endpoint_info.channel_volumes[n] * PA_VOLUME_NORM;
|
2019-08-12 12:31:55 +02:00
|
|
|
|
2019-11-13 09:38:40 +01:00
|
|
|
i.mute = g->endpoint_info.mute;
|
2018-10-19 13:30:20 +02:00
|
|
|
i.buffer_usec = 0;
|
|
|
|
|
i.source_usec = 0;
|
|
|
|
|
i.resample_method = "PipeWire resampler";
|
|
|
|
|
i.driver = "PipeWire";
|
|
|
|
|
i.proplist = pa_proplist_new_dict(info->props);
|
2018-12-04 16:34:58 +01:00
|
|
|
if (cl && cl->client_info.info.proplist)
|
|
|
|
|
pa_proplist_update(i.proplist, PA_UPDATE_MERGE, cl->client_info.info.proplist);
|
2018-10-19 13:30:20 +02:00
|
|
|
i.corked = false;
|
|
|
|
|
i.has_volume = true;
|
|
|
|
|
i.volume_writable = true;
|
2018-11-29 17:30:24 +01:00
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
d->cb(d->context, &i, 0, d->userdata);
|
2018-11-29 17:30:24 +01:00
|
|
|
|
|
|
|
|
pa_proplist_free(i.proplist);
|
2018-10-19 13:30:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void source_output_info(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct source_output_data *d = userdata;
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_global(d->context, d->global, o) < 0)
|
|
|
|
|
return;
|
2018-10-19 13:30:20 +02:00
|
|
|
source_output_callback(d);
|
|
|
|
|
d->cb(d->context, NULL, 1, d->userdata);
|
|
|
|
|
pa_operation_done(o);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_source_output_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-10-19 13:30:20 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct global *g;
|
|
|
|
|
struct source_output_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
|
|
|
|
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, source_output_info, sizeof(struct source_output_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
d->global = g;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void source_output_info_list(pa_operation *o, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
struct source_output_data *d = userdata;
|
|
|
|
|
pa_context *c = d->context;
|
|
|
|
|
struct global *g;
|
|
|
|
|
|
2019-03-15 20:31:20 +01:00
|
|
|
if (wait_globals(c, PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, o) < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-10-19 13:30:20 +02:00
|
|
|
spa_list_for_each(g, &c->globals, link) {
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT))
|
|
|
|
|
continue;
|
|
|
|
|
d->global = g;
|
|
|
|
|
source_output_callback(d);
|
|
|
|
|
}
|
|
|
|
|
d->cb(c, NULL, 1, d->userdata);
|
|
|
|
|
pa_operation_done(o);
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_source_output_info_list(pa_context *c, pa_source_output_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-10-19 13:30:20 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct source_output_data *d;
|
|
|
|
|
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
pa_assert(c->refcount >= 1);
|
|
|
|
|
pa_assert(cb);
|
|
|
|
|
|
|
|
|
|
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, source_output_info_list, sizeof(struct source_output_data));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->context = c;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx, const char *source_name, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx, uint32_t source_idx, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
2019-04-17 15:44:40 +02:00
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
2018-06-01 11:28:31 +02:00
|
|
|
pw_log_warn("Not Implemented");
|
2019-04-17 15:44:40 +02:00
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_output_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-12-14 16:42:36 +01:00
|
|
|
pa_stream *s;
|
|
|
|
|
struct global *g;
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
2019-01-04 10:00:57 +01:00
|
|
|
pw_log_debug("contex %p: index %d", c, idx);
|
2018-12-14 16:42:36 +01:00
|
|
|
|
|
|
|
|
if ((s = find_stream(c, idx)) == NULL) {
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT))
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s) {
|
2019-08-12 12:31:55 +02:00
|
|
|
set_stream_volume(c, s, volume, s->mute);
|
2018-12-14 16:42:36 +01:00
|
|
|
}
|
|
|
|
|
else if (g) {
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, volume, g->endpoint_info.mute);
|
2018-12-14 16:42:36 +01:00
|
|
|
}
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_set_source_output_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-12-14 16:42:36 +01:00
|
|
|
pa_stream *s;
|
|
|
|
|
struct global *g;
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
if ((s = find_stream(c, idx)) == NULL) {
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT))
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s) {
|
2019-08-12 12:31:55 +02:00
|
|
|
set_stream_volume(c, s, NULL, mute);
|
2018-12-14 16:42:36 +01:00
|
|
|
}
|
|
|
|
|
else if (g) {
|
2019-11-13 09:38:40 +01:00
|
|
|
set_endpoint_volume(c, g, NULL, mute);
|
2018-12-14 16:42:36 +01:00
|
|
|
}
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata)
|
|
|
|
|
{
|
2018-12-04 16:36:49 +01:00
|
|
|
pa_stream *s;
|
|
|
|
|
struct global *g;
|
|
|
|
|
pa_operation *o;
|
|
|
|
|
struct success_ack *d;
|
|
|
|
|
|
|
|
|
|
if ((s = find_stream(c, idx)) == NULL) {
|
|
|
|
|
if ((g = pa_context_find_global(c, idx)) == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT))
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
|
pw_stream_destroy(s->stream);
|
|
|
|
|
}
|
|
|
|
|
else if (g) {
|
2019-12-11 09:44:48 +01:00
|
|
|
pw_registry_destroy(c->registry, g->id);
|
2018-12-04 16:36:49 +01:00
|
|
|
}
|
|
|
|
|
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
|
|
|
|
d = o->userdata;
|
|
|
|
|
d->cb = cb;
|
|
|
|
|
d->userdata = userdata;
|
|
|
|
|
pa_operation_sync(o);
|
|
|
|
|
|
|
|
|
|
return o;
|
2018-06-01 11:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_stat(pa_context *c, pa_stat_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name, pa_sample_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, pa_sample_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_sample_info_list(pa_context *c, pa_sample_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_autoload_info_by_name(pa_context *c, const char *name, pa_autoload_type_t type, pa_autoload_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Deprecated: Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, pa_autoload_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Deprecated: Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_get_autoload_info_list(pa_context *c, pa_autoload_info_cb_t cb, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Deprecated: Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autoload_type_t type, const char *module, const char*argument, pa_context_index_cb_t cb, void* userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Deprecated: Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name, pa_autoload_type_t type, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Deprecated: Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 13:23:43 +01:00
|
|
|
SPA_EXPORT
|
2018-06-01 11:28:31 +02:00
|
|
|
pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void* userdata)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("Deprecated: Not Implemented");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|