mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pulse: Use the right conversion functions for volumes
PulseAudio uses cubic volumes and PipeWire uses linear volumes so use the right conversion functions from one to the other.
This commit is contained in:
parent
9c0ff170f9
commit
f3dda8e57b
3 changed files with 14 additions and 14 deletions
|
|
@ -128,7 +128,7 @@ static int sink_callback(pa_context *c, struct global *g, struct sink_data *d)
|
|||
i.owner_module = g->id;
|
||||
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] = pa_sw_volume_from_linear(g->node_info.volume * g->node_info.channel_volumes[n]);;
|
||||
i.mute = g->node_info.mute;
|
||||
i.monitor_source = g->node_info.monitor;
|
||||
snprintf(monitor_name, sizeof(monitor_name)-1, "%s.monitor", i.name);
|
||||
|
|
@ -145,7 +145,7 @@ static int sink_callback(pa_context *c, struct global *g, struct sink_data *d)
|
|||
i.flags |= PA_SINK_HW_MUTE_CTRL;
|
||||
i.proplist = pa_proplist_new_dict(info->props);
|
||||
i.configured_latency = 0;
|
||||
i.base_volume = g->node_info.base_volume * PA_VOLUME_NORM;
|
||||
i.base_volume = pa_sw_volume_from_linear(g->node_info.base_volume);
|
||||
i.n_volume_steps = g->node_info.volume_step * (PA_VOLUME_NORM+1);
|
||||
i.state = node_state_to_sink(info->state);
|
||||
i.card = g->node_info.device_id;
|
||||
|
|
@ -315,7 +315,7 @@ static int set_stream_volume(pa_context *c, pa_stream *s, const pa_cvolume *volu
|
|||
|
||||
if (volume) {
|
||||
for (i = 0; i < volume->channels; i++)
|
||||
channel_volumes[i] = volume->values[i] / (float) PA_VOLUME_NORM;
|
||||
channel_volumes[i] = pa_sw_volume_to_linear(volume->values[i]);;
|
||||
vols = channel_volumes;
|
||||
n_channel_volumes = volume->channels;
|
||||
} else {
|
||||
|
|
@ -345,7 +345,7 @@ static int set_node_volume(pa_context *c, struct global *g, const pa_cvolume *vo
|
|||
|
||||
if (volume) {
|
||||
for (i = 0; i < volume->channels; i++)
|
||||
channel_volumes[i] = volume->values[i] / (float) PA_VOLUME_NORM;
|
||||
channel_volumes[i] = pa_sw_volume_to_linear(volume->values[i]);
|
||||
vols = channel_volumes;
|
||||
n_channel_volumes = volume->channels;
|
||||
|
||||
|
|
@ -394,7 +394,7 @@ static int set_device_volume(pa_context *c, struct global *g, struct global *cg,
|
|||
|
||||
if (volume) {
|
||||
for (i = 0; i < volume->channels; i++)
|
||||
channel_volumes[i] = volume->values[i] / (float) PA_VOLUME_NORM;
|
||||
channel_volumes[i] = pa_sw_volume_to_linear(volume->values[i]);
|
||||
vols = channel_volumes;
|
||||
n_channel_volumes = volume->channels;
|
||||
|
||||
|
|
@ -861,7 +861,7 @@ static int source_callback(pa_context *c, struct global *g, struct source_data *
|
|||
i.owner_module = g->id;
|
||||
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] = pa_sw_volume_from_linear(g->node_info.volume * g->node_info.channel_volumes[n]);;
|
||||
i.mute = g->node_info.mute;
|
||||
if (monitor) {
|
||||
i.index = g->node_info.monitor;
|
||||
|
|
@ -882,7 +882,7 @@ static int source_callback(pa_context *c, struct global *g, struct source_data *
|
|||
i.driver = "PipeWire";
|
||||
i.flags = flags;
|
||||
i.configured_latency = 0;
|
||||
i.base_volume = g->node_info.base_volume * PA_VOLUME_NORM;
|
||||
i.base_volume = pa_sw_volume_from_linear(g->node_info.base_volume);
|
||||
i.n_volume_steps = g->node_info.volume_step * (PA_VOLUME_NORM+1);
|
||||
i.state = node_state_to_source(info->state);
|
||||
i.card = g->node_info.device_id;
|
||||
|
|
@ -2089,7 +2089,7 @@ static int sink_input_callback(pa_context *c, struct sink_input_data *d, struct
|
|||
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] = pa_sw_volume_from_linear(g->node_info.volume * g->node_info.channel_volumes[n]);
|
||||
|
||||
i.mute = g->node_info.mute;
|
||||
i.buffer_usec = 0;
|
||||
|
|
@ -2492,7 +2492,7 @@ static int source_output_callback(struct source_output_data *d, pa_context *c, s
|
|||
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] = pa_sw_volume_from_linear(g->node_info.volume * g->node_info.channel_volumes[n]);
|
||||
|
||||
i.mute = g->node_info.mute;
|
||||
i.buffer_usec = 0;
|
||||
|
|
|
|||
|
|
@ -899,7 +899,7 @@ static int create_stream(pa_stream_direction_t direction,
|
|||
s->disconnecting = false;
|
||||
if (volume) {
|
||||
for (i = 0; i < volume->channels; i++)
|
||||
s->channel_volumes[i] = volume->values[i] / (float) PA_VOLUME_NORM;
|
||||
s->channel_volumes[i] = pa_sw_volume_to_linear(volume->values[i]);
|
||||
s->n_channel_volumes = volume->channels;
|
||||
} else {
|
||||
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
|
||||
|
|
|
|||
|
|
@ -815,7 +815,7 @@ static void set_volume(pa_alsa_device *dev, const pa_cvolume *v)
|
|||
uint32_t i, n_volumes = new_soft_volume.channels;
|
||||
float volumes[n_volumes];
|
||||
for (i = 0; i < n_volumes; i++)
|
||||
volumes[i] = ((float)new_soft_volume.values[i]) / PA_VOLUME_NORM;
|
||||
volumes[i] = pa_sw_volume_to_linear(new_soft_volume.values[i]);
|
||||
impl->events->set_soft_volume(impl->user_data, &dev->device, volumes, n_volumes);
|
||||
}
|
||||
}
|
||||
|
|
@ -899,7 +899,7 @@ static void mixer_volume_init(pa_alsa_device *dev)
|
|||
pa_log_info("Using hardware volume control. Hardware dB scale %s.",
|
||||
dev->mixer_path->has_dB ? "supported" : "not supported");
|
||||
}
|
||||
dev->device.base_volume = (float)dev->base_volume / PA_VOLUME_NORM;
|
||||
dev->device.base_volume = pa_sw_volume_to_linear(dev->base_volume);;
|
||||
dev->device.volume_step = 1.0f / dev->n_volume_steps;
|
||||
|
||||
if (!dev->mixer_path || !dev->mixer_path->has_mute) {
|
||||
|
|
@ -1457,7 +1457,7 @@ int acp_device_set_volume(struct acp_device *dev, const float *volume, uint32_t
|
|||
|
||||
v.channels = d->mapping->channel_map.channels;
|
||||
for (i = 0; i < v.channels; i++)
|
||||
v.values[i] = volume[i % n_volume] * PA_VOLUME_NORM;
|
||||
v.values[i] = pa_sw_volume_from_linear(volume[i % n_volume]);;
|
||||
|
||||
pa_log_info("Set %s volume: %d", d->set_volume ? "hardware" : "software", pa_cvolume_max(&v));
|
||||
for (i = 0; i < v.channels; i++)
|
||||
|
|
@ -1486,7 +1486,7 @@ int acp_device_get_volume(struct acp_device *dev, float *volume, uint32_t n_volu
|
|||
if (v.channels == 0)
|
||||
return -EIO;
|
||||
for (i = 0; i < n_volume; i++)
|
||||
volume[i] = ((float)v.values[i % v.channels]) / PA_VOLUME_NORM;
|
||||
volume[i] = pa_sw_volume_to_linear(v.values[i % v.channels]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue