alsa: remove existing hardware config before setting a new one

In Linux 5.11, a behavior change for USB audio devices was introduced[0]
that prevents changing parameters such as sample rate or period
size once they are initially set without a snd_pcm_hw_free in
between. This causes sndio to get forced to 48000 Hz and and a
period size of 4800, since those are the parameters set during
sio_open.

To fix this, call snd_pcm_hw_free at the start of sio_alsa_setpar_hw
to remove any previous configuration before setting a new one.

[0] https://bugzilla.kernel.org/show_bug.cgi?id=211941
This commit is contained in:
Michael Forney 2021-02-26 15:20:19 -08:00 committed by Alexandre Ratchov
parent ae7637d044
commit 7551d499a8
1 changed files with 5 additions and 0 deletions

View File

@ -554,6 +554,11 @@ sio_alsa_setpar_hw(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwp,
req_rate = *rate;
err = snd_pcm_hw_free(pcm);
if (err < 0) {
DALSA("couldn't reset hw configuration", err);
return 0;
}
err = snd_pcm_hw_params_any(pcm, hwp);
if (err < 0) {
DALSA("couldn't init pars", err);