UCM profiles can use the same ports, but with different priorities. One
good example is a phone, having an earpiece and a speaker:
- the default profile will put a higher priority on the speaker
- the "voice call" profile will put a higher priority on the earpiece
When switching to the "voice call" profile, we want pipewire to take
into account the priority change, so that the earpiece gets the highest
priority and is selected by default.
As the ports have the same name in both profiles, we have a single
instance of each port in memory, and therefore need to trigger a port
update when the profile is changed, so that the priority set by the new
profile is used.
Moreover, the UCM code updates only the priority inside the
`pa_device_port` structure, so this commit also makes sure we reflect
this value into the `acp_port` structure when enabling a device.
The codepath `pa_alsa_ucm_add_ports` -> `probe_volumes` ->
`pa_alsa_path_probe` was never called leading to no HW volume being set
up when loading a card through UCM. PulseAudio calls this from
`card_set_profile` -> `pa_alsa_{sink,source}_new`.
When a port is plugged/unplugged, first update all the profile states
and then emit a profile change only for the current profile. This way
the device can look at all the updated profiles to select the best one.
When we have accurate enough hardware volume, set the software volume to
1.0. Also fixes the issue of going to 0 volume and then staying silent
until we raise the volume above 1.0.
It is not clear if the port index is in the card or device port array
and it doesn't work when many ports are active. So simply iterate the
device ports and find the ones with the active flag set.
Add the list of possible ports for a device.
Pass the allowed devices in the routes.
Store the active port in the device.
Fixes enumeration of ports on devices with UCM.
Add a READONLY property flag to makr properties READONLY
Set the base_volume and volume_step in the acp device
Send the base volume and step as REAONLY properties. Use these
in pulse layer.
libacp is a port and wrapper around the pulseaudio card profile code.
It uses a set of templates for construct a card profile and mixer port
settings. It also has support for UCM when available for the hardware.