mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
use endpoint in pulse
This commit is contained in:
parent
c9a54112e4
commit
edd011605d
4 changed files with 180 additions and 128 deletions
|
|
@ -90,7 +90,7 @@ static int wait_globals(pa_context *c, pa_subscription_mask_t mask, pa_operation
|
|||
static void sink_callback(struct sink_data *d)
|
||||
{
|
||||
struct global *g = d->global;
|
||||
struct pw_node_info *info = g->info;
|
||||
struct pw_endpoint_stream_info *info = g->info;
|
||||
const char *str;
|
||||
uint32_t n;
|
||||
pa_sink_info i;
|
||||
|
|
@ -102,7 +102,7 @@ static void sink_callback(struct sink_data *d)
|
|||
i.name = str;
|
||||
else
|
||||
i.name = "unknown";
|
||||
pw_log_debug("sink %d %s monitor %d", g->id, i.name, g->node_info.monitor);
|
||||
pw_log_debug("sink %d %s monitor %d", g->id, i.name, g->stream_info.monitor);
|
||||
i.index = g->id;
|
||||
if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_NODE_DESCRIPTION)))
|
||||
i.description = str;
|
||||
|
|
@ -111,17 +111,17 @@ static void sink_callback(struct sink_data *d)
|
|||
|
||||
i.sample_spec.format = PA_SAMPLE_S16LE;
|
||||
i.sample_spec.rate = 44100;
|
||||
if (g->node_info.n_channel_volumes)
|
||||
i.sample_spec.channels = g->node_info.n_channel_volumes;
|
||||
if (g->stream_info.n_channel_volumes)
|
||||
i.sample_spec.channels = g->stream_info.n_channel_volumes;
|
||||
else
|
||||
i.sample_spec.channels = 2;
|
||||
pa_channel_map_init_auto(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
||||
i.owner_module = 0;
|
||||
i.volume.channels = i.sample_spec.channels;
|
||||
for (n = 0; n < i.volume.channels; n++)
|
||||
i.volume.values[n] = g->node_info.volume * g->node_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
i.mute = g->node_info.mute;
|
||||
i.monitor_source = g->node_info.monitor;
|
||||
i.volume.values[n] = g->stream_info.volume * g->stream_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
i.mute = g->stream_info.mute;
|
||||
i.monitor_source = g->stream_info.monitor;
|
||||
i.monitor_source_name = "unknown";
|
||||
i.latency = 0;
|
||||
i.driver = "PipeWire";
|
||||
|
|
@ -132,7 +132,7 @@ static void sink_callback(struct sink_data *d)
|
|||
i.proplist = pa_proplist_new_dict(info->props);
|
||||
i.configured_latency = 0;
|
||||
i.base_volume = PA_VOLUME_NORM;
|
||||
i.state = node_state_to_sink(info->state);
|
||||
//i.state = node_state_to_sink(info->state);
|
||||
i.n_volume_steps = PA_VOLUME_NORM+1;
|
||||
i.card = PA_INVALID_INDEX;
|
||||
i.n_ports = 0;
|
||||
|
|
@ -297,20 +297,20 @@ static void set_node_volume(pa_context *c, struct global *g, const pa_cvolume *v
|
|||
vols = channel_volumes;
|
||||
n_channel_volumes = volume->channels;
|
||||
|
||||
if (n_channel_volumes == g->node_info.n_channel_volumes &&
|
||||
memcmp(g->node_info.channel_volumes, vols, n_channel_volumes * sizeof(float)) == 0 &&
|
||||
mute == g->node_info.mute)
|
||||
if (n_channel_volumes == g->stream_info.n_channel_volumes &&
|
||||
memcmp(g->stream_info.channel_volumes, vols, n_channel_volumes * sizeof(float)) == 0 &&
|
||||
mute == g->stream_info.mute)
|
||||
return;
|
||||
|
||||
memcpy(g->node_info.channel_volumes, vols, n_channel_volumes * sizeof(float));
|
||||
g->node_info.n_channel_volumes = n_channel_volumes;
|
||||
memcpy(g->stream_info.channel_volumes, vols, n_channel_volumes * sizeof(float));
|
||||
g->stream_info.n_channel_volumes = n_channel_volumes;
|
||||
} else {
|
||||
n_channel_volumes = g->node_info.n_channel_volumes;
|
||||
vols = g->node_info.channel_volumes;
|
||||
if (mute == g->node_info.mute)
|
||||
n_channel_volumes = g->stream_info.n_channel_volumes;
|
||||
vols = g->stream_info.channel_volumes;
|
||||
if (mute == g->stream_info.mute)
|
||||
return;
|
||||
}
|
||||
g->node_info.mute = mute;
|
||||
g->stream_info.mute = mute;
|
||||
|
||||
pw_node_proxy_set_param((struct pw_node_proxy*)g->proxy,
|
||||
SPA_PARAM_Props, 0,
|
||||
|
|
@ -345,7 +345,7 @@ pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, c
|
|||
if (!(g->mask & PA_SUBSCRIPTION_MASK_SINK))
|
||||
return NULL;
|
||||
|
||||
set_node_volume(c, g, volume, g->node_info.mute);
|
||||
set_node_volume(c, g, volume, g->stream_info.mute);
|
||||
|
||||
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
||||
d = o->userdata;
|
||||
|
|
@ -374,7 +374,7 @@ pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name
|
|||
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SINK, name)) == NULL)
|
||||
return NULL;
|
||||
|
||||
set_node_volume(c, g, volume, g->node_info.mute);
|
||||
set_node_volume(c, g, volume, g->stream_info.mute);
|
||||
|
||||
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
||||
d = o->userdata;
|
||||
|
|
@ -534,7 +534,7 @@ static pa_source_state_t node_state_to_source(enum pw_node_state s)
|
|||
static void source_callback(struct source_data *d)
|
||||
{
|
||||
struct global *g = d->global;
|
||||
struct pw_node_info *info = g->info;
|
||||
struct pw_endpoint_stream_info *info = g->info;
|
||||
const char *str;
|
||||
uint32_t n;
|
||||
pa_source_info i;
|
||||
|
|
@ -557,20 +557,20 @@ static void source_callback(struct source_data *d)
|
|||
i.description = "unknown";
|
||||
i.sample_spec.format = PA_SAMPLE_S16LE;
|
||||
i.sample_spec.rate = 44100;
|
||||
if (g->node_info.n_channel_volumes)
|
||||
i.sample_spec.channels = g->node_info.n_channel_volumes;
|
||||
if (g->stream_info.n_channel_volumes)
|
||||
i.sample_spec.channels = g->stream_info.n_channel_volumes;
|
||||
else
|
||||
i.sample_spec.channels = 2;
|
||||
pa_channel_map_init_auto(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_OSS);
|
||||
i.owner_module = 0;
|
||||
i.volume.channels = i.sample_spec.channels;
|
||||
for (n = 0; n < i.volume.channels; n++)
|
||||
i.volume.values[n] = g->node_info.volume * g->node_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
i.mute = g->node_info.mute;
|
||||
i.volume.values[n] = g->stream_info.volume * g->stream_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
i.mute = g->stream_info.mute;
|
||||
if (g->mask & PA_SUBSCRIPTION_MASK_SINK) {
|
||||
i.monitor_of_sink = g->id;
|
||||
i.monitor_of_sink_name = "unknown";
|
||||
i.index = g->node_info.monitor;
|
||||
i.index = g->stream_info.monitor;
|
||||
} else {
|
||||
i.monitor_of_sink = PA_INVALID_INDEX;
|
||||
i.monitor_of_sink_name = NULL;
|
||||
|
|
@ -582,7 +582,7 @@ static void source_callback(struct source_data *d)
|
|||
i.proplist = pa_proplist_new_dict(info->props);
|
||||
i.configured_latency = 0;
|
||||
i.base_volume = PA_VOLUME_NORM;
|
||||
i.state = node_state_to_source(info->state);
|
||||
//i.state = node_state_to_source(info->state);
|
||||
i.n_volume_steps = PA_VOLUME_NORM+1;
|
||||
i.card = PA_INVALID_INDEX;
|
||||
i.n_ports = 0;
|
||||
|
|
@ -729,7 +729,7 @@ pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx,
|
|||
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE))
|
||||
return NULL;
|
||||
|
||||
set_node_volume(c, g, volume, g->node_info.mute);
|
||||
set_node_volume(c, g, volume, g->stream_info.mute);
|
||||
|
||||
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
||||
d = o->userdata;
|
||||
|
|
@ -758,7 +758,7 @@ pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *na
|
|||
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SOURCE, name)) == NULL)
|
||||
return NULL;
|
||||
|
||||
set_node_volume(c, g, volume, g->node_info.mute);
|
||||
set_node_volume(c, g, volume, g->stream_info.mute);
|
||||
|
||||
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
||||
d = o->userdata;
|
||||
|
|
@ -1481,7 +1481,7 @@ struct sink_input_data {
|
|||
static void sink_input_callback(struct sink_input_data *d)
|
||||
{
|
||||
struct global *g = d->global, *cl;
|
||||
struct pw_node_info *info = g->info;
|
||||
struct pw_endpoint_stream_info *info = g->info;
|
||||
const char *name;
|
||||
uint32_t n;
|
||||
pa_sink_input_info i;
|
||||
|
|
@ -1502,13 +1502,13 @@ static void sink_input_callback(struct sink_input_data *d)
|
|||
else
|
||||
name = "unknown";
|
||||
|
||||
cl = pa_context_find_global(d->context, g->node_info.client_id);
|
||||
cl = pa_context_find_global(d->context, g->stream_info.client_id);
|
||||
|
||||
spa_zero(i);
|
||||
i.index = g->id;
|
||||
i.name = name;
|
||||
i.owner_module = PA_INVALID_INDEX;
|
||||
i.client = g->node_info.client_id;
|
||||
i.client = g->stream_info.client_id;
|
||||
if (s) {
|
||||
i.sink = s->device_index;
|
||||
}
|
||||
|
|
@ -1529,7 +1529,7 @@ static void sink_input_callback(struct sink_input_data *d)
|
|||
else {
|
||||
i.sample_spec.format = PA_SAMPLE_S16LE;
|
||||
i.sample_spec.rate = 44100;
|
||||
i.sample_spec.channels = g->node_info.n_channel_volumes;
|
||||
i.sample_spec.channels = g->stream_info.n_channel_volumes;
|
||||
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);
|
||||
|
|
@ -1540,9 +1540,9 @@ static void sink_input_callback(struct sink_input_data *d)
|
|||
pa_cvolume_init(&i.volume);
|
||||
i.volume.channels = i.sample_spec.channels;
|
||||
for (n = 0; n < i.volume.channels; n++)
|
||||
i.volume.values[n] = g->node_info.volume * g->node_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
i.volume.values[n] = g->stream_info.volume * g->stream_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
|
||||
i.mute = g->node_info.mute;
|
||||
i.mute = g->stream_info.mute;
|
||||
i.buffer_usec = 0;
|
||||
i.sink_usec = 0;
|
||||
i.resample_method = "PipeWire resampler";
|
||||
|
|
@ -1697,7 +1697,7 @@ pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, cons
|
|||
set_stream_volume(c, s, volume, s->mute);
|
||||
}
|
||||
else if (g) {
|
||||
set_node_volume(c, g, volume, g->node_info.mute);
|
||||
set_node_volume(c, g, volume, g->stream_info.mute);
|
||||
}
|
||||
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
||||
d = o->userdata;
|
||||
|
|
@ -1780,7 +1780,7 @@ struct source_output_data {
|
|||
static void source_output_callback(struct source_output_data *d)
|
||||
{
|
||||
struct global *g = d->global, *l, *cl;
|
||||
struct pw_node_info *info = g->info;
|
||||
struct pw_endpoint_stream_info *info = g->info;
|
||||
const char *name = NULL;
|
||||
uint32_t n;
|
||||
pa_source_output_info i;
|
||||
|
|
@ -1802,13 +1802,13 @@ static void source_output_callback(struct source_output_data *d)
|
|||
if (name == NULL)
|
||||
name = "unknown";
|
||||
|
||||
cl = pa_context_find_global(d->context, g->node_info.client_id);
|
||||
cl = pa_context_find_global(d->context, g->stream_info.client_id);
|
||||
|
||||
spa_zero(i);
|
||||
i.index = g->id;
|
||||
i.name = name ? name : "Unknown";
|
||||
i.owner_module = PA_INVALID_INDEX;
|
||||
i.client = g->node_info.client_id;
|
||||
i.client = g->stream_info.client_id;
|
||||
if (s) {
|
||||
i.source = s->device_index;
|
||||
}
|
||||
|
|
@ -1828,7 +1828,7 @@ static void source_output_callback(struct source_output_data *d)
|
|||
else {
|
||||
i.sample_spec.format = PA_SAMPLE_S16LE;
|
||||
i.sample_spec.rate = 44100;
|
||||
i.sample_spec.channels = g->node_info.n_channel_volumes;
|
||||
i.sample_spec.channels = g->stream_info.n_channel_volumes;
|
||||
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);
|
||||
|
|
@ -1839,9 +1839,9 @@ static void source_output_callback(struct source_output_data *d)
|
|||
pa_cvolume_init(&i.volume);
|
||||
i.volume.channels = i.sample_spec.channels;
|
||||
for (n = 0; n < i.volume.channels; n++)
|
||||
i.volume.values[n] = g->node_info.volume * g->node_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
i.volume.values[n] = g->stream_info.volume * g->stream_info.channel_volumes[n] * PA_VOLUME_NORM;
|
||||
|
||||
i.mute = g->node_info.mute;
|
||||
i.mute = g->stream_info.mute;
|
||||
i.buffer_usec = 0;
|
||||
i.source_usec = 0;
|
||||
i.resample_method = "PipeWire resampler";
|
||||
|
|
@ -1991,7 +1991,7 @@ pa_operation* pa_context_set_source_output_volume(pa_context *c, uint32_t idx, c
|
|||
set_stream_volume(c, s, volume, s->mute);
|
||||
}
|
||||
else if (g) {
|
||||
set_node_volume(c, g, volume, g->node_info.mute);
|
||||
set_node_volume(c, g, volume, g->stream_info.mute);
|
||||
}
|
||||
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_ack));
|
||||
d = o->userdata;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue