alsa: add api.alsa.auto-link option

Add an option to automatically use snd_pcm_link when the follower clock
is matching the driver. Only set this to true in pro-audio and when
nodes are scheduled together.

See #3556
This commit is contained in:
Wim Taymans 2023-10-09 10:10:46 +02:00
parent 0dfa05117b
commit 896fea62c2
3 changed files with 6 additions and 1 deletions

View file

@ -390,6 +390,7 @@ static int add_pro_profile(pa_card *impl, uint32_t index)
pa_proplist_setf(m->output_proplist, "device.profile.pro", "true");
pa_proplist_setf(m->output_proplist, "node.group", "pro-audio-%u", index);
pa_proplist_setf(m->output_proplist, "node.link-group", "pro-audio-%u", index);
pa_proplist_set(m->input_proplist, "api.alsa.auto-link", "true");
pa_alsa_close(&m->output_pcm);
m->supported = true;
pa_channel_map_init_auto(&m->channel_map, m->sample_spec.channels, PA_CHANNEL_MAP_AUX);
@ -423,6 +424,7 @@ static int add_pro_profile(pa_card *impl, uint32_t index)
pa_proplist_setf(m->input_proplist, "device.profile.pro", "true");
pa_proplist_setf(m->input_proplist, "node.group", "pro-audio-%u", index);
pa_proplist_setf(m->input_proplist, "node.link-group", "pro-audio-%u", index);
pa_proplist_set(m->input_proplist, "api.alsa.auto-link", "true");
pa_alsa_close(&m->input_pcm);
m->supported = true;
pa_channel_map_init_auto(&m->channel_map, m->sample_spec.channels, PA_CHANNEL_MAP_AUX);

View file

@ -131,6 +131,8 @@ static int alsa_set_param(struct state *state, const char *k, const char *s)
state->multi_rate = spa_atob(s);
} else if (spa_streq(k, "api.alsa.htimestamp")) {
state->htimestamp = spa_atob(s);
} else if (spa_streq(k, "api.alsa.auto-link")) {
state->auto_link = spa_atob(s);
} else if (spa_streq(k, "latency.internal.rate")) {
state->process_latency.rate = atoi(s);
} else if (spa_streq(k, "latency.internal.ns")) {
@ -3034,7 +3036,7 @@ int spa_alsa_prepare(struct state *state)
spa_list_for_each(follower, &state->followers, driver_link) {
if (follower != state && !follower->matching) {
spa_alsa_prepare(follower);
if (!follower->linked)
if (!follower->linked && state->auto_link)
do_link(state, follower);
}
}

View file

@ -214,6 +214,7 @@ struct state {
unsigned int htimestamp:1;
unsigned int is_pro:1;
unsigned int sources_added:1;
unsigned int auto_link:1;
unsigned int linked:1;
uint64_t iec958_codecs;