Skip to content

switch: fix audio thread hanging forever in SWITCHAUDIO_PlayDevice() - #135

Closed
leleletus wants to merge 1 commit into
devkitPro:switch-sdl-2.28from
leleletus:switch-audio-no-hang
Closed

leleletus wants to merge 1 commit into
devkitPro:switch-sdl-2.28from
leleletus:switch-audio-no-hang

Conversation

@leleletus

@leleletus leleletus commented Oct 19, 2026 •

Copy link
Copy Markdown

LLM-generated content removed

…ying

SWITCHAUDIO_PlayDevice() queued a wave buffer and then waited for it to
reach AudioDriverWaveBufState_Playing. libnx marks every buffer consumed
since the previous audrvUpdate() as Done in one step, so when the audio
thread fell one to two buffer periods behind, the buffer went from Queued
straight to Done and the loop never exited: permanent silence while the
device kept reporting SDL_AUDIO_PLAYING.

PlayDevice() now only queues the buffer. WaitDevice() waits until any
buffer is Free or Done, polling every 2 ms instead of audrenWaitFrame()
(which has no timeout), returns on shutdown, and restarts the voice if no
buffer completes within 1 s plus two buffer periods.

Fixes libsdl-org#134
@fincs fincs closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants