Repository navigation
alsa: restart non-MMAP capture after XRUN recovery - #1194
whatisyourname0 wants to merge 4 commits into
Conversation
|
Hi @RossBencina, could you please approve the CI runs for this PR and take a look when you have a chance? It fixes non-MMAP capture stalling after XRUN recovery and includes a standalone reproducer. Thank you! |
|
We think there is value in this PR. But we do not know how it relates to other Issues. Also we cannot merge a PR that adds dependencies on Docker and Python. Do "patest_underflow.c" or "patest_toomanysines.c" recreate this error? |
|
Hi Phil, Thanks for reviewing this. I'll prepare a standalone C reproducer with clear steps I checked patest_underflow.c and patest_toomanysines.c. Both open The failure I've reproduced is specific to non-MMAP capture:
Issue #930 has a similar symptom, but I haven't established that it has the I'll follow up with the C reproducer and the baseline/fixed results. |
|
Hi @philburk, Thanks for the guidance. I opened #1195 with the standalone C reproducer, build steps and baseline/fixed results. The PR now uses the C test without Docker or Python dependencies. With MOTU input through Apple VZ, the baseline stopped at five callbacks after an overrun. The fixed version recovered in all three trials and passed close/reopen checks. A separate signal check also confirmed audio after recovery. These tests use an experimental virtio-snd guest kernel; direct Linux USB audio testing is still pending. The issue also explains the distinction from #930 and #1038. I'd appreciate your feedback when you have a chance. Thank you! |
| than claiming recovery was tested. The new C mode 4 has not yet been validated | ||
| on physical input. |
There was a problem hiding this comment.
Do not use modes 0 through 3 as hardware proof. For physical tests, use mode 4 with an explicitly selected ALSA PCM (e.g.
hw:0,0) and the normal ALSA configuration.
The new C mode 4 has not yet been validated on physical input.
Does this mean that this test and the fix have not actually been validated on real hardware?
There was a problem hiding this comment.
Hi Ross,
Thanks for catching that. I missed updating the README after the VZ tests.
I tested the audio interface (MOTU UltraLite-mk5) connected directly by USB to a Linux machine, using the standard USB audio driver and kernel 6.8.0-136-generic. The unchanged C reproducer reproduced the stall through plughw. Repeated the comparison directly on hw, changing only the test's channel count and sample format to match the MOTU: 20 channels, packed 24-bit, 48 kHz. The PCM used RW_INTERLEAVED access.
The baseline stopped at five callbacks after the overrun and remained PREPARED. The fixed version passed three overrun/close/reopen trials, and both versions passed normal recording before and after the test. A separate sample check also confirmed nonzero audio after recovery.
These new tests use eiter no VZ nor virtio-snd. updatD the README with the exact setup and results. Thank you for pointing out the stale wording.
Fixes #1195.
A non-MMAP capture stream can stop delivering callbacks after an overrun while PortAudio still reports it as active.
snd_pcm_recover()prepares the capture PCM, butPaAlsaStream_HandleXrun()returns without starting it. The callback thread then waits for input from a PCM that remains PREPARED.Start the recovered capture PCM when it is PREPARED, unlinked, and no full ALSA restart is already pending. If that start fails, use the existing full restart path. Persistent start failures retain the existing error handling. Playback, linked PCM startup and MMAP recovery policies are unchanged; there is no public API change.
The optional
qa/alsa-xrunreproducer is now a single C executable. It uses shared PortAudio and ALSA with a test-only symbol-interposition fixture to exercise non-MMAP capture on a null PCM. The README includes native compile commands and expected baseline/candidate outcomes. It needs no Docker, Python, separate preload library or audio hardware. The previous Docker/Python harness was removed in response to review.Validation
Base:
7c45fed9322bd86b5dd0da4547b15d9ac3b9b0ac(master at preparation time).The callback block size was 4,096 frames at 48 kHz; this is not a fixed hardware buffer size. Synthetic XRUN reports and real overruns are separate tests. The physical tests used an experimental guest driver and short recordings, so they do not establish USB-device, linked-duplex, hot-unplug or long-duration coverage. Audio lost during an overrun is not restored.
Related reports
#930 has a similar symptom, but its root cause has not been established. #1037 / #1038 addressed error-handler loops; this change addresses successful recovery leaving capture PREPARED. I am not marking those reports as fixed by this PR.
A separate application report showed
snd_pcm_start()itself failing duringAlsaRestart(). Injected EIO can produce the same call chain, but the original report lacks the ALSA errno and device details. This patch does not establish a fix for that incident.The original fix and reproducer commits are preserved. A follow-up commit replaces the Docker/Python harness with the standalone C reproducer. The commits may be squashed on merge.