mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-22 08:56:59 -05:00
acp: remove the soft volume/mute events
Remove the soft mute/volume events, add a new method to get the soft volume and use the volume_changed event to emit the changed soft and monitor (real) volumes event for the node. Make sure the monitor ports always uses the monitor volume, which is the real volume unaffected by the mixer volumes. This configures the soft and real volume on the sink/source in all cases and makes the monitor port follow the real volume of the sink. See #897
This commit is contained in:
parent
3bce026d67
commit
5cddd61c6c
4 changed files with 42 additions and 54 deletions
|
|
@ -1043,7 +1043,6 @@ static int read_volume(pa_alsa_device *dev)
|
|||
|
||||
static void set_volume(pa_alsa_device *dev, const pa_cvolume *v)
|
||||
{
|
||||
pa_card *impl = dev->card;
|
||||
pa_cvolume r;
|
||||
|
||||
dev->real_volume = *v;
|
||||
|
|
@ -1083,18 +1082,7 @@ static void set_volume(pa_alsa_device *dev, const pa_cvolume *v)
|
|||
if (accurate_enough)
|
||||
pa_cvolume_reset(&new_soft_volume, new_soft_volume.channels);
|
||||
|
||||
if (!pa_cvolume_equal(&dev->soft_volume, &new_soft_volume)) {
|
||||
dev->soft_volume = new_soft_volume;
|
||||
|
||||
if (impl->events && impl->events->set_soft_volume) {
|
||||
uint32_t i, n_volumes = new_soft_volume.channels;
|
||||
float volumes[n_volumes];
|
||||
for (i = 0; i < n_volumes; i++)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
dev->soft_volume = new_soft_volume;
|
||||
} else {
|
||||
pa_log_debug("Wrote hardware volume: %d", pa_cvolume_max(&r));
|
||||
/* We can't match exactly what the user requested, hence let's
|
||||
|
|
@ -1823,8 +1811,6 @@ int acp_device_set_volume(struct acp_device *dev, const float *volume, uint32_t
|
|||
} else {
|
||||
d->real_volume = v;
|
||||
d->soft_volume = v;
|
||||
if (impl->events && impl->events->set_soft_volume)
|
||||
impl->events->set_soft_volume(impl->user_data, dev, volume, n_volume);
|
||||
}
|
||||
if (!pa_cvolume_equal(&d->real_volume, &old_volume))
|
||||
if (impl->events && impl->events->volume_changed)
|
||||
|
|
@ -1832,17 +1818,26 @@ int acp_device_set_volume(struct acp_device *dev, const float *volume, uint32_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_volume(pa_cvolume *v, float *volume, uint32_t n_volume)
|
||||
{
|
||||
uint32_t i;
|
||||
if (v->channels == 0)
|
||||
return -EIO;
|
||||
for (i = 0; i < n_volume; i++)
|
||||
volume[i] = pa_sw_volume_to_linear(v->values[i % v->channels]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int acp_device_get_soft_volume(struct acp_device *dev, float *volume, uint32_t n_volume)
|
||||
{
|
||||
pa_alsa_device *d = (pa_alsa_device*)dev;
|
||||
return get_volume(&d->soft_volume, volume, n_volume);
|
||||
}
|
||||
|
||||
int acp_device_get_volume(struct acp_device *dev, float *volume, uint32_t n_volume)
|
||||
{
|
||||
pa_alsa_device *d = (pa_alsa_device*)dev;
|
||||
pa_cvolume v;
|
||||
uint32_t i;
|
||||
v = d->real_volume;
|
||||
if (v.channels == 0)
|
||||
return -EIO;
|
||||
for (i = 0; i < n_volume; i++)
|
||||
volume[i] = pa_sw_volume_to_linear(v.values[i % v.channels]);
|
||||
return 0;
|
||||
return get_volume(&d->real_volume, volume, n_volume);
|
||||
}
|
||||
|
||||
int acp_device_set_mute(struct acp_device *dev, bool mute)
|
||||
|
|
@ -1860,8 +1855,6 @@ int acp_device_set_mute(struct acp_device *dev, bool mute)
|
|||
d->set_mute(d, mute);
|
||||
} else {
|
||||
d->muted = mute;
|
||||
if (impl->events && impl->events->set_soft_mute)
|
||||
impl->events->set_soft_mute(impl->user_data, dev, mute);
|
||||
}
|
||||
if (old_muted != mute)
|
||||
if (impl->events && impl->events->mute_changed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue