Commit 31f3647
committed
fix(alsa): skip drain() on non-Running PCM to prevent USB kernel deadlock
After a write error, try_recover() leaves the PCM in the Prepared state.
Calling drain() on a Prepared-state USB PCM can deadlock the kernel driver,
causing a full system freeze that requires a physical power cycle to recover.
This has been confirmed on Raspberry Pi 3 with the dwc_otg USB controller
and a Focusrite Scarlett 2i4 USB audio interface. Certain tracks trigger
an audio key error which causes an ALSA underrun during stop(); try_recover()
succeeds but leaves the PCM in Prepared state, and the subsequent drain()
call never returns.
Dropping the PCM instead of draining is sufficient to release resources
when the PCM is not actively running.1 parent 33bf3a7 commit 31f3647
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
446 | 453 | | |
447 | 454 | | |
448 | 455 | | |
| |||
0 commit comments