mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-09 03:01:53 -04:00
acp: add min and max volume properties
This way, the min/max volume can be updated and saved in the same way as the volume is updated. Also add support for this in audioconvert channelmix.
This commit is contained in:
parent
fb74ab9054
commit
1a534cd907
6 changed files with 71 additions and 0 deletions
|
|
@ -2339,6 +2339,41 @@ int acp_device_set_port(struct acp_device *dev, uint32_t port_index, uint32_t fl
|
|||
return res;
|
||||
}
|
||||
|
||||
int acp_device_get_volume_limit(struct acp_device *dev, float *min, float *max)
|
||||
{
|
||||
pa_alsa_device *d = (pa_alsa_device*)dev;
|
||||
pa_card *impl = d->card;
|
||||
pa_device_port *p;
|
||||
float *volume_range;
|
||||
|
||||
if ((p = d->active_port) != NULL)
|
||||
volume_range = p->volume_range;
|
||||
else
|
||||
volume_range = impl->volume_range;
|
||||
|
||||
if (min)
|
||||
*min = volume_range[0];
|
||||
if (max)
|
||||
*max = volume_range[1];
|
||||
return 0;
|
||||
}
|
||||
int acp_device_set_volume_limit(struct acp_device *dev, float min, float max)
|
||||
{
|
||||
pa_alsa_device *d = (pa_alsa_device*)dev;
|
||||
pa_card *impl = d->card;
|
||||
pa_device_port *p;
|
||||
float *volume_range;
|
||||
|
||||
if ((p = d->active_port) != NULL)
|
||||
volume_range = p->volume_range;
|
||||
else
|
||||
volume_range = impl->volume_range;
|
||||
|
||||
volume_range[0] = min;
|
||||
volume_range[1] = max;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int acp_device_set_volume(struct acp_device *dev, const float *volume, uint32_t n_volume)
|
||||
{
|
||||
pa_alsa_device *d = (pa_alsa_device*)dev;
|
||||
|
|
|
|||
|
|
@ -303,6 +303,8 @@ int acp_device_get_soft_volume(struct acp_device *dev, float *volume, uint32_t n
|
|||
int acp_device_get_volume(struct acp_device *dev, float *volume, uint32_t n_volume);
|
||||
int acp_device_set_mute(struct acp_device *dev, bool mute);
|
||||
int acp_device_get_mute(struct acp_device *dev, bool *mute);
|
||||
int acp_device_get_volume_limit(struct acp_device *dev, float *min, float *max);
|
||||
int acp_device_set_volume_limit(struct acp_device *dev, float min, float max);
|
||||
|
||||
typedef void (*acp_log_func) (void *data,
|
||||
int level, const char *file, int line, const char *func,
|
||||
|
|
|
|||
|
|
@ -710,6 +710,20 @@ static int apply_device_props(struct impl *this, struct acp_device *dev, struct
|
|||
changed++;
|
||||
}
|
||||
break;
|
||||
case SPA_PROP_volumeMin:
|
||||
acp_device_get_volume_limit(dev, &volumes[0], &volumes[1]);
|
||||
if (spa_pod_get_float(&prop->value, &volumes[0]) == 0) {
|
||||
acp_device_set_volume_limit(dev, volumes[0], volumes[1]);
|
||||
changed++;
|
||||
}
|
||||
break;
|
||||
case SPA_PROP_volumeMax:
|
||||
acp_device_get_volume_limit(dev, &volumes[0], &volumes[1]);
|
||||
if (spa_pod_get_float(&prop->value, &volumes[1]) == 0) {
|
||||
acp_device_set_volume_limit(dev, volumes[0], volumes[1]);
|
||||
changed++;
|
||||
}
|
||||
break;
|
||||
case SPA_PROP_latencyOffsetNsec:
|
||||
{
|
||||
int64_t latency_ns;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue