ALSA: fall back to nearest available buffer-size

The warning "samples per period does not match." never triggered.
Previously not being able to set the requested buffersize was a
fatal error.

This adds support for soundcards that only support msec.
e.g. recent HDA Intel via SOF (Sound Open Firmware)
This commit is contained in:
Robin Gareus 2021-01-22 16:01:41 +01:00
parent cff58bd9da
commit 0b97175d49
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 2 additions and 2 deletions

View File

@ -935,7 +935,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
if (_pcmi->fsize() != _samples_per_period) {
_samples_per_period = _pcmi->fsize();
PBD::warning << _("AlsaAudioBackend: samples per period does not match.") << endmsg;
PBD::warning << string_compose (_("AlsaAudioBackend: samples per period does not match, using %1."), _samples_per_period) << endmsg;
}
if (_pcmi->fsamp() != _samplerate) {

View File

@ -772,7 +772,7 @@ int Alsa_pcmi::set_hwpar (snd_pcm_t *handle, snd_pcm_hw_params_t *hwpar, const
sname, *nchan);
return -1;
}
if (snd_pcm_hw_params_set_period_size (handle, hwpar, _fsize, 0) < 0)
if (snd_pcm_hw_params_set_period_size_near (handle, hwpar, &_fsize, 0) < 0)
{
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't set %s period size to %lu.\n",
sname, _fsize);