alsa: keep track of rate in card object

Expose the card object and always obtain one per pcm.

Keep the configured format in the card object.

Add a api.alsa.multi-rate property. When multi_rate is disabled,
only allow the last configured card rate on all PCMs.

This works around drivers that can't handle multiple samplerates
on their PCMs.

With this patch it should be mostly safe to configure multiple
sample rates in pipewire.conf

See #1547
This commit is contained in:
Wim Taymans 2021-11-23 11:28:41 +01:00
parent e7f9046bb8
commit 13923416e0
4 changed files with 75 additions and 51 deletions

View file

@ -586,6 +586,8 @@ static int port_set_format(void *object,
if (!this->have_format)
return 0;
spa_log_debug(this->log, "clear format");
this->card->format_ref--;
spa_alsa_pause(this);
clear_buffers(this);
spa_alsa_close(this);
@ -960,6 +962,8 @@ impl_init(const struct spa_handle_factory *factory,
this->disable_batch = spa_atob(s);
} else if (spa_streq(k, "api.alsa.use-chmap")) {
this->props.use_chmap = spa_atob(s);
} else if (spa_streq(k, "api.alsa.multi-rate")) {
this->multi_rate = spa_atob(s);
}
}
return spa_alsa_init(this);