alsa: Add a mechanism to bind ALSA controls as prop params

This adds an api.alsa.bind-ctls property to alsa-pcm sink and source
nodes, to bind a property to an ALSA PCM ctl. The property is an array
of ctl names that should be bound.

This can be handy, for example, to bind the Playback/Capture Rate
controls on a USB gadget, in order to track the PCM's state via a node
param.

This is currently wired to be read-only, but it should be easy enough to
make it writable.
This commit is contained in:
Arun Raghavan 2023-11-07 14:02:26 -05:00
parent 6bae812ce0
commit 2871a65b1f
3 changed files with 300 additions and 7 deletions

View file

@ -92,6 +92,12 @@ struct rt_state {
unsigned int following:1;
};
struct bound_ctl {
char name[256];
snd_ctl_elem_info_t *info;
snd_ctl_elem_value_t *value;
};
struct state {
struct spa_handle handle;
struct spa_node node;
@ -240,11 +246,19 @@ struct state {
struct spa_pod *tag[2];
/* Rate match via an ALSA ctl */
/* for rate match and bind ctls */
snd_ctl_t *ctl;
/* Rate match via an ALSA ctl */
snd_ctl_elem_value_t *pitch_elem;
double last_rate;
/* ALSA ctls exposed as params */
unsigned int num_bind_ctls;
struct bound_ctl bound_ctls[16];
struct spa_source ctl_sources[MAX_POLL];
int ctl_n_fds;
struct spa_list link;
struct spa_list followers;