-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alsa_snd_pcm_hw_params() on Ubuntu 20.04 started returning an unexpected -ENOMEM #125
Comments
Hi, I can regenerate the same bug in Ubuntu 20.04 (amd64). With
I guess that the issue is specific to ALSA Intel HDA driver, at least. I write another test program, referring to source of PortAudio19 (portaudio19-19.6.0):
The
In the hardware parameter, the size of buffer is decided to 34176000 bytes (34MB). This is too large and seems to be a bug of ALSA Intel HDA driver since usually drivers should limit the maximum size of buffer to avoid allocation error. I'll contact to developer of Intel HDA driver in alsa-devel. The request to limit the maximum size of buffer from userspace application is better workaround at present:
Thanks |
Does the kernel set CONFIG_SND_HDA_PREALLOC_SIZE to non-zero? If it's set to zero, it means unlimited, hence such a problem can occur. The default value is 2048 for x86. |
Oh, exactly... It seems to be an issue in distro side. I'll report it to the project. (I miss David Henningsson...) |
@philburk In the above message I propose a patch to portaudio as workaround, however we have another workaround. The preallocation size can be confgured via procfs node and we can suppress the issue by configure non-zero value. In my environment, your test runs:
Applying the workaround:
Then your test runs successfully:
Regards |
Great work. Thanks for the quick analysis and workaround. I will ask the PortAudio developer to try that procfs trick. It may not be practical to ask all the affected users to apply that procfs command. Most are just using apps and are not programmers. Do you think it might be worth calling alsa_snd_pcm_hw_params_set_buffer_size_near() in PortAudio as a workaround? I think it just sets the upper limit so should not have any effect in most cases. |
In my opinion, yes. The TestParameters() function in Regards |
The workaround works on my test system (tested 15 frequent sample rates with all supported channel combinations, input and output). I first got a core dump after applying the fix. Apparently the 3rd arg in The procfs solution works too. Maybe one should only set this for [sub]devices that have a current prealloc size of 0. |
Oops. I'm sorry for the bug. My original patch is cleared once I note that just for limitation of maximum size of PCM buffer
|
I note that fix is proposed[1] for ALSA Intel HDA driver. [1] https://mailman.alsa-project.org/pipermail/alsa-devel/2021-March/182424.html |
The fix is now applied, and goes to Linux kernel v5.13. https://mailman.alsa-project.org/pipermail/alsa-devel/2021-March/182480.html |
It seems all resolved now. |
…13+ again. The relevant bug has been fixed in Linux 5.13 and later, so the issue is resolved for Ubuntu 21.10 (Linux 5.13), and future Ubuntu 20.04.4-LTS (Linux 5.13) with eta around Jan/Feb 2022, and future Ubuntu 22.04-LTS and other autumn 2021 and later distributions. While it would be possible to also add a workaround to a future Portaudio v19.8.0 release, implementing the following linked proposal, which would be identical to the fix i had in mind... alsa-project/alsa-lib#125 (comment) ... it probably doesn't make much sense wrt. distro release timing. A portaudio 19.8 release would end up in Ubuntu 22.04-LTS the earliest, but that one will ship with Linux 5.14 or later, so the workaround would not be needed. And even 20.04.4-LTS will be released early 2022 before a fix could be backported the earliest. Therefore, we let time solve this problem for us soon. If running on Linux 5.13+ we enable the check again, otherwise we skip the check, just as in the past. -> Tested on Linux 5.13 and Linux 5.11 on Ubuntu 20.04.3-LTS.
This is apparently fixed in Linux kernel 5.13 alsa-project/alsa-lib#125
This seems to be a regression in a recent release.
It was reported on the PortAudio GitHub repo. See here for more details:
PortAudio/portaudio#526
The text was updated successfully, but these errors were encountered: