A DualSense or DualSense Edge connected over USB appears as a standard CoreAudio input device, but its hardware mic mute and audio power-saving states are controlled by Sony vendor HID output report 0x02 (SetState), so capture can stay silent until SetState enables the built-in mic. When AUHAL prepares a USB DualSense audio input on Mac, correlate that AudioDeviceID to its own physical USB HID controller using CoreAudio's ModelUID (054C:0CE6 / 054C:0DF2), AudioBox BoxUID (@locationID) or AppleUSBAudioEngine DeviceUID, and SerialNumber, failing closed on mismatch or ambiguity rather than grabbing the first Sony pad. Skip synthetic GameController HID entries and non-gamepad interfaces, then open the matched HID device shared and send SetState 0x02 with only the mic volume, audio control, mute LED, and mute/power-save bits enabled. Label USB DualSense / DualSense Edge inputs "(USB)" in the Mac launcher using CoreAudio ModelUID directly (no IOKit import or link change). Document why Bluetooth DualSense mic capture is unusable on macOS in docs/reference/audio.md and add pure-C unit tests for the report and USB audio-to-HID matcher. Revises PR #2999. Co-authored-by: Adem Rosic <[email protected]>
102 KiB
Audio
The audio renderer (dm/host/hle_audren.c), AudioOut, audio devices and codecs. Each entry: symptom, cause, fix, the games it was found on. The symptom index lists every symptom.
Audio renderer
Running the SDK's own renderer on the CPU
Check whether the SDK carries the renderer: list the sdk module's exports for nn::audio::server:: and nn::audio::dsp::CommandListProcessor. If they are there (Super Mario Bros. Wonder, SDK 16), do not write a mixer:
- switch a copy of
AudioRendererParameterto rendering device = CPU (+0x2c = 1) and execution mode = manual (+0x30 = 1) inGetAudioRendererWorkBufferSizeand bothOpenAudioRendereroverloads; - call the SDK originals (
guest_symreturns the module's own code even for a forced symbol); - drive
ExecuteAudioRendererRenderingfrom a guest thread (dm_guest_thread_spawn).
The open then goes through CreateAudioRendererManagerByDfc; no IPC.
For a replaced DSP renderer the size query keeps the service's work-buffer contract; a larger local CPU representation is a backend cost. See A sound engine's heap too small for its renderer and players.
SDK 1: the renderer is the audren:u service
- Symptom: the host stops at boot with
[RED] sf: the game connects to service audren:u itself, which the host does not serve, undernn::audio::GetAudioRendererWorkBufferSizeorOpenAudioRenderer. - Cause: SDK 1.3.1 carries only the renderer's client: no
nn::audio::server::, noExecuteAudioRendererRendering, no DFC manager. Itsnn::audioconnects toaudren:u(CreateAudioRendererManagerByHipc,sdk+0x1641dc), as on Horizon, so the CPU renderer above has nothing to run. - Fix: the host serves
audren:u(hle_audren_sv.c, registered withSF_SERVICEinhle_sf.c's host sessions), andhle_audren.c's work size, open and close hooks hand an SDK withoutExecuteAudioRendererRenderingstraight to the SDK's own client. Every layout was read off SDK 1.3.1's client:- the manager: 0
OpenAudioRenderer(the 0x34-byte parameter, its revision at +0x30; the work buffer's transfer memory and the process as copied handles; the work size and applet resource user ID at +0x38 / +0x40; the process ID; the renderer comes back as a moved session), 1GetWorkBufferSize(the service budget,dm_audren_work_size), 2GetAudioDeviceService(zeroed answers; the device calls are taken over above the service). - the renderer: 0–3 sample rate, sample count, mix buffer count, state (0 started); 4
RequestUpdate(A: the update; B: the answer; B: performance frames); 5 / 6 start and stop; 7QuerySystemEvent(a copied read end of the renderer's kernel event); 8 / 9 the rendering time limit. - the update, revision REV2: a 0x40-byte header with each section's size (behaviour +4, memory pools +8, voices +0xc, channel resources +0x10, effects +0x14, mixes +0x18, sinks +0x1c, performance +0x20, splitters +0x24, total +0x3c), then behaviour (0x10), memory pools (0x20), channel resources (0x70: ID, 24 volumes, in use at +0x64), voices (0x170: the client's
VoiceInfofrom +0x40), effects (0xc0), splitters, mixes (0x930: volume, buffer count +8, in use +0xc, ID +0x10 with the final mix 0, 24 × 24 volumes from +0x24, destination +0x924), sinks (0x140: type +0, in use +1, the device's from +0x20 with its input count at +0x120 and six inputs at +0x124), performance (0x10). The answer: memory pools (0x10: a requested attach, 4, answers attached, 5; a requested detach, 2, answers detached, 3), voices (0x10: samples played, wave buffers consumed), effects (0x10: 3 enabled, 4 disabled), sinks (0x20), performance (0x10), behaviour (0xb0). The client aborts unless the answer's total equals its buffer, and fails the update when a section's size differs from what it reads back. - the renderer: voices (PCM8, PCM16 and DSP ADPCM; four wave buffers in a ring, consumed at their end unless they loop, the played count restarting at an end of stream; a stop consumes what is queued) resampled linearly, through their channel resources' volumes into their mix; sub mixes deepest first; Aux effects (type 2) through the game's send and return rings, whose DSP offsets are at +0x40 / +0x44 of each info; buffer mixers; the final mix through the first device sink to stereo (5.1 down-mixed). Delay, reverb and biquad effects pass the dry signal and splitters are not followed, each with a red line. A guest thread renders one frame per output block and signals the renderer's event while it is started.
svcCreateTransferMemorygives the client a typed kernel handle for the work buffer. The audio service keeps using its own renderer buffer. Transfer memory in the hostt_audren_svdrives the service throughhle_sf.cas SDK 1.3.1's client does.
- the manager: 0
- Found on: Rayman Legends: Definitive Edition (SDK 1.3.1). The renderer in PR #1540 (from the patch in issue #960) read the client's own structures at SDK 1.3.1's offsets instead, and took effect type 3 (delay) for Aux.
SDK 8's longer AudioRendererParameter
- Symptom: abort with Result 0x499 in
audio::GetAudioRendererWorkBufferSize. - Cause: SDK 8's
AudioRendererParameteris one word longer than SDK 16's: its revision sits at +0x38. The host copies the game's parameter before switching it to CPU rendering with manual execution, and copied only 0x38 bytes, soCheckValidRevisionread garbage. - Fix: it copies 0x40 now.
- Found on: The Legend of Zelda: Link's Awakening (SDK 8.2.0).
A renderer opened without an event
- Symptom: the game is silent; only the game's updates render (catch-up frames that nothing plays). The log has
audren: OpenAudioRenderer (no event)and norender thread started. - Cause: the game opens the renderer with
OpenAudioRenderer(handle, parameter, work, size), the form with no system event, and paces its own updates, but the renderer must still run every 5 ms. The host used to start its render thread only for the form with an event. - Fix: both forms go through one open that starts the thread (
hle_audren.car_open). - Found on: Balatro (SDK 18.3.2, LÖVE's OpenAL Soft; one boot).
A game with more than one renderer
- Symptom:
[RED] audren: a second renderer (the host drives only one)with different parameters from the first open; later,catch-up renders so farin the thousands (7,625 in 6 minutes), about 10% of the first renderer's frames. - Cause: a game may open several renderers, as on Horizon. The host kept one set of globals: the second renderer got no render thread, but
AudioRenderSystem::Updateis one hook for all of them, so each update of the second renderer found nothing rendered since the last, rendered a catch-up frame of the second renderer and queued it in the first one's output, in place of a frame of its own. - Fix:
hle_audren.ckeeps each renderer's state inar_t: its render thread, output, catch-up queue, counters and upsampler history. Two renderers play through two outputs, which the sound card mixes. An SDK call that names only theAudioRenderSystemfinds its renderer byar_of_sys. One lock still serializes all rendering, since the header layout is decided once, from the first list, by trying each layout in turn; a frame takes about 0.02 ms. Catch-up renders went from 7,625 to 0 or 1 in a run.dm/host/tests/t_audren_layout.cchecks the lookup and the upsampler's separate history. - Found on: Mario & Luigi: Brothership (SDK 12.3.2): one renderer at 48 kHz, which sounds during the movie, and Unreal's mixer at 32 kHz.
Two renderers overwriting each other's queued blocks
- Symptom: with two renderers open, one plays single 5 ms frames between silences and its sound effects are missing, while the other has an occasional all-zero 5 ms block; no underrun and no
[RED]line, and the AudioOutappendedandreleasedcounts stay balanced. Cross-correlating the outputs finds one renderer's waveform on the other. - Cause: AudioOut queues a block's pointer and copies its samples when the sound card asks (
h_au_Append,pullinhle_audio.c).render_mainkept its four blocks in function-level statics, left out when the renderer state moved intoar_t, so every render thread filled the same four. A block queued for one output could be rewritten by the other renderer's thread before it played. A second renderer's start also set the size of the blocks to 0 under the first one's output, whoseb->size - a->poscould then underflow on a part-played block. - Fix: the blocks are in
ar_t, one set per renderer. The slots are static andCloseAudioRendererjoins the render thread before a slot is reused, so a block outlives its output.t_audren_layoutqueues every block of one renderer, renders the other, and checks the first one's samples. - Found on: title
01007ED02424E000(not in the games table; issue #1336, on an iPad Pro M1). Mario & Luigi: Brothership also opens two renderers; it has not been run with the fix.
The SDK's open with an event calls the open without one (t_in_open)
- Symptom:
audren: OpenAudioRendererlogged twice right after the first open, with the same work buffer and "original device 1 mode 1", and a second render thread (until 2026-11-04 the second log line was[RED] audren: a second renderer, which now means more than one renderer). - Cause: not a second renderer: SDK 17.5.3's
OpenAudioRendererwith an event opens it by calling the form without one through the PLT (sdk+0x1e489c), which the loader binds to the host's hook since that form has one (A renderer opened without an event), soar_openran twice for one renderer. The inner call started the render thread before the outer one had created the event, and the outer call took the renderer for a second one. - Fix: a thread-local flag (
t_in_open) hands the inner call straight to the SDK with the host's CPU / manual copy of the parameter, and only the outer call starts the thread (hle_audren.c). - Found on: ROMANCE OF THE THREE KINGDOMS 8 REMAKE (SDK 17.5.3).
Explicit CPU / manual renderer
- Symptom: choppy, crackling audio with thousands of catch-up renders (
catch-up renders so farin the tens of thousands), heavyAudioOutunderruns, and[RED] audren: no DeviceSink (ID 0x14) in the command list, alongsideaudren: OpenAudioRenderer … (original device 1 mode 1 → CPU / manual). - Cause: a game may open
nn::audio::AudioRendererexplicitly in CPU + manual mode (renderingDevice = 1,executionMode = 1) with aCircularBufferSinkand driveExecuteAudioRendererRenderingitself from its own audio thread, feeding a directAudioOut. The host already kept the SDK's work buffer and event contract fordevice != 0, but still spawnedrender_main(opening a second unusedAudioOutand rendering every 5 ms alongside the game's thread), rancapture()looking for aDeviceSink(consuming the one-shot sink discovery), and ran catch-up renders and 50 mscq_cvwaits insideAudioRenderSystem::Update. - Fix:
hle_audren.crecordsmanual = (device == 1 && mode == 1)onar_t:h_ar_WorkSizeandar_openkeep the game's parameter unchanged and skip spawningrender_main,h_ars_Updateforwards straight to the SDK without catch-up frames, andh_ar_ImplExec/h_ars_Execforward straight to the SDK originals (resolving unbound manual slots separately from host-driven DSP renderers so a manual and a DSP renderer can coexist cleanly).t_audren_workchecks work size, event/buffer ownership, no thread spawn/join, direct SDK forwarding for update/exec and coexistence with an unbound DSP renderer. - Found on: METAL GEAR SOLID: Peace Walker – Master Collection Version (
0100C6F01C4F8000/ program 10100C6F01C4F8001, 1.3.0, SDK 19.3.11, not in the games table; issue #3212). Reported on M1 Max (no game files here).
The renderer event as the service gives it: a kernel event
- Symptom: the frame loop stops for good as a level loads while audio keeps rendering. The main thread waits in
os::WaitSystemEventunderCAudioMemoryPool::Shutdown, and a sound thread of higher priority waits on the same condition variable. - Cause: with the DSP service (device 0, what the game asks for)
OpenAudioRendererattaches the service's renderer event, a kernel readable event (AttachReadableHandleToSystemEvent, auto-clear). With CPU rendering and manual execution, which the host switches to (Running the SDK's own renderer on the CPU), it creates a local one instead (CreateSystemEvent(event, AutoClear, false), SDK 4:sdk+0x190b6c). Signalling a local auto-clear event wakes one waiter, the one of highest priority. A kernel event wakes every waiter, and each one triesResetSignal. Donkey Kong Country: Tropical Freeze waits on the event from two threads: its sound thread (priority 29,main+0x971e8) every frame, and the main thread while it detaches an audio memory pool (main+0x6fa8c:RequestDetachMemoryPool, then wait and update untilIsMemoryPoolAttachedis false). The sound thread took every wake, and the main thread never woke again. - Fix: when the game opened the renderer for the service, the host replaces the SDK's local event with an inter-process auto-clear one (
DestroySystemEvent, thenhle_bind_system_event(event, 1)inar_open), and the game's event waits on a copy of its read end. That event is the renderer's own, not the game's (The renderer event belongs to the renderer, not the game). The SDK's renderer signals throughos::SignalSystemEvent, which handles either kind. A game that opens a CPU renderer itself keeps the SDK's local event. - Found on: Donkey Kong Country: Tropical Freeze (SDK 4.4.0): the first level's load after the intro cinematic.
The renderer event belongs to the renderer, not the game
- Symptom: the game exits with 42 on its first rendered audio frame:
Break#1 reason=0inos::SignalSystemEvent, called from the publicExecuteAudioRendererRenderingon the host's render thread (render_main). - Cause: with the DSP service (what the game asks for), no SDK's
OpenAudioRendererkeeps a pointer to the game'sSystemEventType. It stores NULL in the handle's event slot and attaches the service's readable handle to the object, so the game may destroy the object or reuse its memory once the open returns. The slot ishandle[1]in SDKs 3, 5 and 12 (SDK 3sdk+0x17e004, SDK 12sdk+0x4d2b4) and*handle[1]in SDK 18. The CPU / manual open the host switches to (Running the SDK's own renderer on the CPU) stores the object in that slot instead (SDK 3sdk+0x17dffc, SDK 12sdk+0x4d274), andExecuteAudioRendererRenderingsignals it after every render. LEGO Star Wars: The Skywalker Saga passes an event on its stack, and Little Nightmares reuses the object's memory. The first render found a state byte (+0x28) that was no longer the event's, and the SDK aborted. - Fix:
ar_opengives the SDK's open an event of the renderer's own (g_revinhle_audren.c, alive untilCloseAudioRenderer, which destroys it), whatever slot the SDK keeps it in. The game's object gets a copy of that kernel event's read end (hle_dup_readable_handle), attached as managed and auto-clear, as the service's copied handle is. The renderer never touches the game's object again. The host's binding no longer sits at the game's address either, where a later service event at the same storage would have found it (hle_bind_system_eventreturns early for an address it already holds). Tests:t_audren_work(the game's event is overwritten after the open, including the SDK 3 to 12 slot) andt_system_event(the copied read end). - Found on: LEGO Star Wars: The Skywalker Saga (
010042D00D900000, 1.10.0, SDK 12.3.6; issue #632), Little Nightmares (01002FC00412C000, 1.0.4, SDK 3.5.1; PR #804), both from provisional profiles. DRAGON BALL FighterZ (0100A250097F0000, SDK 4.5.0; issue #771) aborts at the same place, and SDK 5.4's open andExecuteAudioRendererRenderingare the same code as SDK 3's and 12's. None of the three is here: the fix awaits their reporters' runs.
The renderer's update lock (update_lock)
- Symptom: none of its own; command generation races the game's
Updateon SDKs whose lock is not at SDK 16's offset. - Cause:
AudioRenderSystem::Updateholds a mutex inAudioRenderSystem;GenerateCommanddoes not take it, so the host does (the auto-mode system thread does the same inSendCommandToDsp). Which mutex depends on the SDK:nn::os::LockMutex(MutexType *)at +0x1d0 in SDK 4.4 and at +0x1d8 in 6.4–8.2,SdkMutexType::Lockat +0x1d8 in 10.4–11.4, +0x1f0 in 13.3–16.2, +0x1f8 in 17.5 and +0x208 in 18.3 (thesdkbuilds of the games on hand). From SDK 19Updatereads the system tick and callsUpdateImpl, which takes it (The update lock read offUpdateImpl). The host took SDK 16's for every SDK before 20, which wrote a lock word into another field and excluded nothing. - Fix:
update_lockinhle_audren.creads it off the SDK's ownUpdate: the register the prologue adds the offset to and moves into x0 before its firstbl, whose PLT slot must holdLockMutexorSdkMutexType::Lock. A miss inUpdategoes on toUpdateImpl; a miss in both keeps the layout's offset and logs a red line. Test:t_audren_layout. - Found on: Mario Kart 8 Deluxe (4.4), the first game it was plainly wrong for.
- Check: checked with sound on Big Brain Academy: Brain vs. Brain (11.4, +0x1d8), DRAGON QUEST XI S (7.3,
MutexType+0x1d8) and Super Mario Odyssey (7.3, which is silent for its first minute with either lock).
No SdkMutexType in SDK 3
- Symptom:
FATAL audren: missing SDK symbol _ZN2nn2os12SdkMutexType4LockEvright after the renderer's render thread starts. - Cause: the render path looked up
SdkMutexType::Lock/Unlockbefore reading which lock the SDK'sUpdatetakes (The renderer's update lock); SDK 3.5.1'ssdkhas noSdkMutexTypeand takesnn::os::LockMutexat +0x1f8. - Fix:
render_oncelooks up theSdkMutexTypefunctions only whenupdate_lockdoes not findLockMutex(hle_audren.c). - Found on: OCTOPATH TRAVELER (SDK 3.5.1), the first SDK 3 game through the audio renderer (Bayonetta 2's 3.6.0 plays through
AudioOut).
Where the AudioRenderSystem sits in AudioRendererImpl
- Symptom: the sound is choppy: about two of every three 5 ms blocks are silent (a
DM_AUDIO_DUMP), with no underruns. The log'scatch-up renders so fargrows by one for each rendered frame (2000 of every 2000), and every update logsno frame rendered before update N. - Cause: the host's takeover of
AudioRendererImpl::ExecuteAudioRendererRenderingfound theAudioRenderSystemat a fixed+0x60, where SDK 16 and 20 keep it. SDK 3.4 keeps it at+0x50(add x19, x0, #0x50in the prologue,sdk+0x188a10). With the wrong pointer, the execution mode and rendering device came from other fields, so each render on the 5 ms render thread failed with 0x40299 and played a silent block. Only the game's updates rendered: one catch-up frame each, at 60 Hz instead of 200. - Fix:
impl_sys_offinhle_audren.creads the offset from the SDK's own function: the firstadd xd, x0, #immbefore the first branch. If it finds none, it keeps+0x60. Every othersdkbuild on hand (18 games, SDK 4.5 to 21) reads+0x60. - Found on: SteamWorld Dig and SteamWorld Dig 2 (both ship the same SDK 3.4.0
sdkbuild). - Check: after the fix, the log has
audren: AudioRenderSystem at +0x50 in AudioRendererImpl, a few dozen catch-up renders per 2000 frames, and a dump with no silent blocks once the music starts.
The render thread's route through the public ExecuteAudioRendererRendering (SDK 20)
- Symptom:
CommandListProcessor::Processcrashes now and then (SIGSEGV underrender_main, once at 60 s and once at 134 s in the shrine); everyRequestUpdaterenders a catch-up frame. - Cause: the public
ExecuteAudioRendererRendering(sdk+0x221e90) reachesAudioRendererImpl::ExecuteAudioRendererRendering(sdk+0x22ca88,x0 += 0x60and a jump through the PLT) through the vtable, so the host's takeover of theImplfunction was never called. The SDK's ownAudioRenderSystem::ExecuteAudioRendererRenderingran instead (no update lock), everyRequestUpdaterendered a catch-up frame because the host's render counter never moved, and the two threads wrote the same command buffer. - Fix: the host also takes over
AudioRenderSystem::ExecuteAudioRendererRendering, the PLT target (hle_audren.c); catch-ups fell from one per update to 3 per run. - Found on: The Legend of Zelda: Breath of the Wild (SDK 20).
- Note: the same SDK's other
AudioRenderSystemlayout is in SDK 20'sAudioRenderSystemlayout.
A renderer below 48 kHz with no upsampler on the CPU
- Symptom: SIGSEGV at address 0x18 in
UpsamplerManager::Allocateon the render thread. - Cause: a DeviceSink below 48 kHz is upsampled by the SDK's upsampler, and
AudioRenderSystem::SetUpRenderResourceSetallocates theUpsamplerManageronly for the DSP (sdk+0x21eb6c: rate 0x7d00 and rendering device +0x48 == 0); with the host's CPU rendering the manager pointer (AudioRenderSystem+0x150, the render context's +0x20) is null. - Fix: the host answers
Allocateon a null manager with no upsampler, so the generator skips the upsample command (sdk+0x225b40), and resamples the DeviceSink's stereo downmix 3:2 itself (a 16-tap windowed sinc in three phases,up_3_2inhle_audren.c), 240 samples per 5 ms frame for the 48 kHz output. - Found on: DRAGON QUEST VII Reimagined: rate 32000, 160 samples per frame,
GenerateSinkCommandssdk+0x225a80. - Note: until then the output code assumed an upsampled buffer at 32 kHz that no game had produced.
A sound engine's heap too small for its renderer and players
- Symptom: the main thread spins at start-up in a resource wait (a
YieldThreadloop, no crash), right afterOpenAudioRenderer. - Cause: the DSP service and an application's local SDK server use different command/state representations. The host forwarded the local CPU server's work-buffer requirement as the guest's DSP-service requirement. Larger local command structures could then exhaust a fixed sound heap that fits the service's budget. Changing only the device / execution fields in the local sizing routine does not reveal this difference: it still sizes the same compiled structures. The game note records the comparison against Horizon's actual sizing code and the resulting allocation failure.
- Fix:
ar_service_work_sizeinhle_audren.ccomputes the Horizon service budget through renderer revision 15, with revision gates for graph/splitter storage, effect states, performance frames and command storage. A DSP caller receives that size. On open the host independently asks the SDK for its CPU/manual requirement and supplies a page-aligned, zeroed backend buffer if it exceeds the caller's capacity; a buffer below the declared service requirement is rejected. Both open forms share the allocation, including a nested no-event open. Failed opens free it; close joins the render thread, closes the SDK renderer, then frees it. Explicit CPU renderers keep their SDK contract. A sufficient caller buffer is reused; revisions beyond the verified service model retain the SDK size. No firmware is loaded or distributed at runtime, and no game's heap constants change. - Found on: Hyrule Warriors: Age of Calamity.
- Check:
make -C dm/host/tests GAME=<id> audren-workchecks independently obtained Horizon sizing fixtures, both public parameter layouts, uninitialized padding, unsupported revisions, nested opens, undersized buffers, failure cleanup, caller-owned storage and close lifetime. The sizing implementation also matched 360 seeded parameter sets executed through Horizon's original machine code across REV1–REV15. The game note records the original-heap reproduction and audio check.
Command lists by SDK
Incomplete startup lists must not select the command layout
- Symptom: no sound after boot;
audren: no DeviceSink (ID 0x13) in the command listand a malformed-command error persist even when later command lists are valid. - Cause: the host's render thread can generate commands before the game's first
RequestUpdate. Mario Kart 8 Deluxe's first list ended in a zeroed third command, so none of the supported header layouts could walk it.capturenevertheless latched the default layout and consumed the one-time sink scan. Later SDK 6 headers were read as SDK 8–20 headers, and SDK 4's DeviceSink was never found. Retrying only header detection still leaves the sink scan consumed. - Fix: select the header only when the whole list walks in a supported layout. Until then, return a silent frame before the sink scan; the first valid list can select both the header and its sink.
t_audren_layoutreproduces the failure and checks stereo PCM for SDK 4, 6, 16 and 21, with valid-first, empty and incomplete startup lists and SDK 21's short first list. - Found on: Mario Kart 8 Deluxe (SDK 4.4.0; PR #331).
Malformed later command lists and bounded histogram logging
- Symptom: ASan reports a stack-buffer-overflow in
capturewhile logging the first full command histogram; a malformed list can also consume sink discovery or return PCM before its invalid tail is checked. - Cause: a short valid list selected the header layout without running the histogram. A later malformed list entered the histogram scan, which stopped at its first invalid command but still logged an uninitialized string or adopted a sink from the valid prefix. Separately, accumulating
snprintf's untruncated return value advanced the next write past the 512-byte string. - Fix: validate the entire command list on every capture before histogram, sink discovery or PCM output. Keep discovery pending for rejected lists, initialize the histogram string, and stop appending at the last complete entry that fits.
- Check:
t_audren_layoutcovers malformed first, middle and trailing commands after layout selection, recovery to valid stereo PCM for SDK 4/5/6/16/21, and 64,000 synthetic commands whose histogram exceeds the log buffer. ASan reproduced both the uninitialized-string read and the truncated-append write before the fix. - Found on: synthetic command lists from the issue #313 static-analysis audit; no gameplay failure was attributed to these logging defects.
The final mix is taken from the DeviceSink's mix buffers
- Symptom: the CPU processor drops the final mix.
- Cause:
dsp::SendCommandBuffer,dsp::Waitanddsp::Signalare stubs in the application build, and DeviceSink (command 0x13) is a no-op inCommandListProcessor::Process. - Fix: take the output after
Processfrom the mix buffers the DeviceSink command names (layout inhle_audren.c).
SDK 4: DeviceSink is command 0xf of 0x130 bytes
- Symptom: no sound:
[RED] audren: no DeviceSink (ID 0x10) in the command list, 0 commands of 0x148 bytes. - Cause: SDK 4's command list has SDK 6's header, but its DeviceSink (
CommandBuffer::GenerateDeviceSinkCommand,sdk+0x19e690) is ID 0xf and 0x130 bytes: device name +0x14, upsample buffer +0x118, input count +0x120, input indices as bytes from +0x124. - Fix:
capturetakes the one 0x130-byte command with 1 to 6 inputs when there is no 0x148-byte one (g_sink4inhle_audren.c). - Found on: Mario Kart 8 Deluxe (4.0.0, SDK 4.4.0; one boot).
- Note: its
AudioRenderSystem::Update(sdk+0x19b77c) locks annn::os::MutexTypeat +0x1d0, not SDK 16'sSdkMutexTypeat +0x1f0; see The renderer's update lock (update_lock).
SDK 6: the DSP command header layout
- Symptom: no sound; red
audren: command 1 in the command list is malformed (magic 0 size 0). - Cause: SDK 6's DSP command header is +0x04 size (s16), +0x06 command ID (s16), +0x10 enabled, where SDK 8–20 have +0x04 enabled, +0x05 ID, +0x06 size (
CommandListProcessor::Process,sdk+0xaaa00); its DeviceSink is ID 0x10. - Fix:
captureinhle_audren.ctakes the layout whose walk finds the 0xcafebabe magic on every command of the first valid list; incomplete startup lists leave detection open. - Found on: Fire Emblem: Three Houses (SDK 6.5.0).
SDK 5: a startup list that walks in two layouts, and a 0x138-byte DeviceSink
- Symptom: no sound:
[RED] audren: no DeviceSink (ID 0x13) in the command list, 0 commands of 0x148 bytesand[RED] audren: command 2 in the command list is malformed (offset 0x3e, …), withfirst-frame commands 13, by command ID: 0×2. - Cause: SDK 5.4.0's command list has SDK 6's header. Its first list holds two commands, the first of ID 0x14 and 0x14 bytes, so it walks in the SDK 8–20 layout as well (the ID read as the size), and that layout was taken because it is tried first. Its DeviceSink (
CommandBuffer::GenerateDeviceSinkCommand,sdk+0x233890) is SDK 4's (ID 0xf, device name +0x14, upsample buffer +0x118, input count +0x120) but 0x138 bytes, with the input indices as s16 from +0x124. - Fix:
captureinhle_audren.ctakes a header layout only from a list that walks in exactly one; a list that walks in none or in several is a silent frame. The sink scan takes the one 0x130-byte (s8 indices) or 0x138-byte (s16 indices,g_sink5) command with 1 to 6 inputs.t_audren_layoutcovers SDK 5 and Bastion's first list. - Found on: Bastion (1.0.0, SDK 5.4.0).
Unaligned command headers during layout probing
- Symptom: UBSan reports a misaligned
uint32_tload incmd_okwhilet_audren_layoutprobes SDK 4/6 lists (issue #409). - Cause: interpreting the command ID as another layout's size can advance the candidate pointer off word alignment. Typed header loads then have undefined C behavior even though arm64 supports the machine load. A wrong size could also take the next header outside the generated list.
- Fix:
cmd_size,cmd_idand the magic check decode multibyte wire fields withmemcpy.cmd_okverifies that the complete header and command fit before consuming them; malformed-command diagnostics do not dereference a rejected header. All supported SDK layouts use the same readers, with no game gate. - Check:
t_audren_layoutchecks deliberately unaligned headers, every truncated header/body length, invalid signed sizes and stereo PCM for SDK 4/6/16/21, including recovery from incomplete startup lists. The shipped SDK 6 processor reads the enabled byte at +0x10 before dispatching any command, confirming the 0x11-byte minimum used by the parser. Its UBSan alignment suppression was removed. - Found on: the sanitizer audit's SDK 4/6 fixtures, representing Mario Kart 8 Deluxe and Fire Emblem: Three Houses; no game crash was attributed to this undefined load.
SDK 8: command IDs numbered differently
- Symptom: no music and no sound effects, only the movies' sound (the log repeats
audren: first-frame commands …every frame and never printsDeviceSink inputs). - Cause: SDK 8 numbers the DSP commands differently: its command list goes 4×6, 7×24, 11×2, 16×1, 21×1 where SDK 20's goes 7×6, 11×24, 15×2, 20×1, 25×1, and the output command (DeviceSink, the same 0x148-byte layout with device name
MainAudioOut, six inputs) is 0x10, not SDK 16's 0x13. The host never found it and played silence. - Fix: when the expected ID is missing from the first full command list,
captureinhle_audren.cnow takes the one 0x148-byte command with 1 to 6 inputs as the sink and logs the ID it adopted. - Found on: The Legend of Zelda: Link's Awakening (SDK 8.2.0).
SDK 20's AudioRenderSystem layout
- Cause: in SDK 20 the getters the host used (
GetExecutionMode,GetRenderingDevice,GetCommandBufferWorkBufferSize) are inlined away,GenerateCommandtakes and returns aSpan<std::byte>(the generated list comes back in x0 / x1), the device and mode are words at +0x48 / +0x4c, the command buffer is at +0xf8 / +0x100, andUpdateImpllocks the mutex at +0x2d0 instead of +0x1f0. The DeviceSink command became ID 0x14 (SDK 20 inserted a command before it) with the same layout. - Fix:
render_oncepicks the layout by whether the Span version ofGenerateCommandexists (hle_audren.c). - Found on: The Legend of Zelda: Breath of the Wild.
- Note: the render thread's call takes another route in this SDK too: see The render thread's route through the public
ExecuteAudioRendererRendering(SDK 20); the update lock at +0x2d0 is in The renderer's update lock (update_lock), and SDK 22 moved it (The update lock read offUpdateImpl).
The update lock read off UpdateImpl
- Symptom:
CRASH sig=11 addr=0x20atnn::audio::server::AddressInfo::GetReference(sdk+0x249874) on the render thread, underCommandGenerator::GenerateDataSourceCommandandrender_once, minutes into a movie. TheAddressInfothe crash register points at is all zeros, though the function had just read a non-null memory pool pointer from it. Or[RED] audren: no update lock read off AudioRenderSystem::Update or UpdateImpl, on an SDK whose code the scan does not recognize. - Cause: the Span layout took the lock at a fixed +0x2d0, which holds for SDK 19.3 to 21.4. SDK 22 moved it:
UpdateImplin 22.2.8 (sdk+0x238530) and 22.2.5 locks theSdkMutexTypeat +0x2d8 (add x19, x0, #0x2d8; …; mov x0, x19; bl SdkMutexType::Lock), asSendCommandToDsp,Start,StopandFinalizeImpldo. Locked at +0x2d0, the render excluded nothing, and the game'sRequestUpdaterewrote a voice while its commands were being generated. From SDK 19Updatereads the system tick first and callsUpdateImpl, so a scan ofUpdatefinds no lock. - Fix:
update_lock(hle_audren.c) readsUpdate, thenUpdateImpl, whatever the layout, and a miss in both is a red line. The start-up line names what it took:update lock SdkMutexType at +0x2d8. Test:t_audren_layout. - Found on: The Legend of Zelda: Ocarina of Time (Switch 2,
0400486024DEC000, update v131072; its profile is in pull request #1299): the second run through its opening movie crashed, and the run with the offset read offUpdateImplplayed the opening through to Kokiri Forest with sound. Checked statically on thesdkbuilds on hand: SDK 19.3 to 21.4 read +0x2d0, as before. SDK 22.2.0 (Fortune's Weave, EA SPORTS FC 27) is not on hand.
SDK 21 DSP command header without a magic
- Symptom: no sound; red
audren: command 0 in the command list is malformed (first word 0x181901 size 0). - Cause: SDK 21's DSP command header has no magic: +0x00 enabled (bit 0), +0x01 command ID, +0x02 size (s16), +0x04 estimated time, +0x08 node ID (
CommandListProcessor::Process,sdk+0x24fd50), and every command body moved 8 bytes forward. DeviceSink is still ID 0x14 but 0x140 bytes: input count +0x128, input indices +0x12c, upsample buffer +0x120 (written atsdk+0x23a7b0).AudioRenderSystemkeeps SDK 20's offsets (update lock +0x2d0). - Fix:
capture(hle_audren.c) tries this layout when neither magic walk works, bounded by the generated list's length. Its first lists hold 4 commands or fewer, so the layout is now chosen on the first non-empty list. - Found on: Rhythm Heaven Groove (SDK 21.4.0, one boot).
AudioOut and devices
An AudioOut opened at a rate other than 48 kHz
- Symptom: the game quits before its first frame with
FATAL AudioOut sample rate 44100 not supported (48 kHz only),CRASH sig=6inabortunderau_open_at/h_au_OpenDef, exit 134. Nothing is drawn. - Cause: audout takes only 0 (the default) or 48000 in
AudioOutParameter.sampleRateand refuses any other rate withResultInvalidSampleRate, 0x699 (module 153, description 3; yuzu'saudio_out_system.cppand Ryujinx'sAudioOutputSystem.csagree). A game written for that asks for its own rate first and opens again with the defaults when refused, then reads the output's rate back. The host stopped the game instead of refusing the open. - Fix:
au_open_atrefuses another rate as audout does: a[RED]line with the rate and the call site, and 0x699, before anything is allocated. The game then runs the path it runs on a console. Accepting the rate and converting it instead would run a path no console runs. - Found on: Mega Man Legacy Collection (SDK 3.7.0):
main+0x9a3c8opens at 44.1 kHz,main+0x9a3cctests the result and opens again with a zeroed parameter, then reads the output's properties for its buffer sizes; it plays at 48 kHz with 0 underruns. Reported in PR #2723, which accepted the rate. - Check:
t_audio'stest_rate_refused.
Periodic diagnostics outside the AudioUnit callback
- Symptom: RealtimeSanitizer reports stdio locking in
au_renderat its 2,000-callback diagnostic boundary. A busy log writer can block that callback even when its PCM queue is full. - Cause:
LOGtakesstderr's stream lock and formats its message on the calling thread. The callback previously called it directly for its frame-count, queue-depth and underrun statistics. - Fix: the callback publishes a bounded snapshot for the existing audio watchdog, which copies ready reports under the output-registry lock and writes them after unlocking. Its local copies own every log argument; a slow writer holds neither an output pointer nor the registry lock. The single-slot mailbox uses release/acquire ownership; a busy writer leaves the callback accumulating later windows instead of waiting or overwriting unread data. Reports retain the output ID, total callbacks, frame range, average queue depth and underrun/zero-padding counts, with the actual window length when several windows merge. The release-event notifier remains independent of diagnostics, so an event-driven game can keep refilling PCM while logging is blocked. Close stops the producer and takes any remaining snapshot under the same registry lock before freeing the output.
- Found on: the synthetic real-time audio audit in issue #313. No particular game's audible failure is attributed to this finding.
- Check:
t_audio_statscalls the real callback with synthetic PCM and traps callback-thread stdio, including its stream lock. With the watchdog's writer deliberately blocked, each PCM buffer still triggers its guest release event and is refilled correctly; queued and merged reports preserve their fields. Close drains a second pending snapshot while the watchdog holds only a local copy, which it logs after the output was freed. Statistics alone cause no guest event. The fixture needs no sound device or game files.
AudioOut release notification can sleep with pending work
- Symptom: PCM is consumed correctly and its buffer reaches the released queue, but the guest release event never arrives. The notifier is asleep with
notify_pending=1andnotify_armed=0. - Cause: the notifier cleared
notify_armedwith a release-only store before checkingnotify_pending. A producer could publish pending work and see the old armed value, leaving the notifier to wake itself; without acquiring that producer's exchange, the notifier could read stale pending state and sleep. Apple-silicon code generated a store-release followed by acquire-PC loads, which permit this ordering. - Fix: disarm with an acquire-release exchange. If the producer's armed exchange precedes it, the notifier acquires the pending publication. Otherwise the producer sees zero and posts, or finds the notifier already re-armed with its own semaphore post. No timeout, polling, callback logging or audio pacing changes are needed.
- Found on: shared CI's
t_audio_statsASan/UBSan fixture, reproduced locally without a sound device or game. This is a general AudioOut mechanism; no gameplay reproduction is claimed. - Check: the existing blocked-diagnostics cases remain intact. The fixture also renders and individually reclaims 100,000 event-driven PCM buffers, so releases cannot be hidden by bulk notification coalescing. The old notifier naturally strands a release in this case; diagnostics distinguish event delivery, PCM contents and returned-buffer identity without retrying the failed wait.
Stopping an AudioOut releases its pending buffers
- Symptom: FMOD waits for buffer release after stopping an AudioOut, hanging the game during a scene transition.
- Cause: the host stopped its backend but left unplayed and partially played buffers in the pending queue, so no callback could release them.
- Fix: after stopping a started backend,
au_release_pendingmoves the pending buffers to the released queue in order, resets the partial-buffer position and signals the client's release event and the host waiter. Calling Stop on an already stopped output preserves buffers queued for its next Start. - Found on: Pokémon Brilliant Diamond: reported on 1.0.0 in PR #190; the 1.3.0 bring-up passed that transition before this fix.
- Check:
t_audio_spsccovers a partially consumed buffer, queue wraparound, release notification, repeated Stop and buffers queued before Start, then runs its 100,000-buffer producer/consumer stress test.
RemoteIO's default I/O buffer duration
- Symptom: crackling on iOS only.
- Cause: RemoteIO asks for as many frames per callback as the audio session's I/O buffer duration, about 21 ms by default (1024 frames at 48 kHz), while the renderer keeps 4 blocks × 5 ms = 20 ms in flight. Every callback came up 1.3 ms short and was padded with zeros, about 47 gaps per second. Reproduced on the Mac by forcing 1024-frame callbacks (
DM_DBG_AU_FRAMES=1024withDM_AUDIO=1: 1999 underruns in 2000 callbacks). - Fix:
AVAudioSessionsetPreferredIOBufferDuration:0.005(and 48 kHz) before the game opens audio and again on return to the foreground (front_ios_audio_sessioninfront_ios.m); the device then calls back with 240 frames and nothing underruns. - Check: when checking a new device, read the host's
audio #N device callbacksline, normally reported every 2000 callbacks: frames per callback, queued blocks, underruns. A busy diagnostic writer can merge windows; the line states their actual callback count.
AudioOut crackle on a Bluetooth route
- Symptom: regular clicks in menus and races over Bluetooth on an iPhone. Built-in speakers play normally. In matched windows of 8,000 callbacks, the speaker route had 4 underruns at 240 frames per callback. The Bluetooth route had 669 at 278–279 frames.
- Cause: RemoteIO can grant a different duration from the requested 5 ms. On the tested route, 256 frames at 44.1 kHz become 278–279 at the host's 48 kHz. A guest with two short buffers in flight can enter a callback with one partial block and one full block. If their combined length is too short, the callback fills the gap with zeros before the guest can refill a released buffer.
- Fix: When a guest AudioOut callback requests more than 5 ms, copy the tail of its last guest block before releasing the descriptor, provided the tail is at most 480 frames (10 ms at 48 kHz) and fits the host buffer. The guest can refill between callbacks. The next consumer, including the silent sink, plays that copy first. The buffer count includes the staged block until it drains. Stop discards it along with queued audio.
- Found on: Need for Speed: Hot Pursuit Remastered, update 1.0.3 on iPhone with Nothing Ear earbuds.
- Check:
t_audio_statsreplays both callback sizes against two recycled 256-frame buffers through the real render callback. The Bluetooth replay goes from 666 underruns to zero in 8,000 callbacks and checks PCM order, the queue count and Stop/restart. Mono and stereo tests check that a 480-frame tail stages and still counts across a queue index wrap, and that a 481-frame tail stays in the guest queue. Playback on an iPhone with the upstream patch remains to be checked.
The Mac's default I/O buffer
- Symptom: clicks and dropouts on the Mac, heard as clipping; the log's
audio #N device callbackslines show hundreds of underruns per 2000 callbacks. Closing an output can also log[RED] audio device buffer: ... (status 560947818)(!obj). - Cause: the Mac's default output asks for 512 device frames per callback (10.7 ms at 48 kHz; 557 frames of the 48 kHz stream when the device runs at 44.1 kHz), more than a game that keeps only a few small blocks queued has ready every time. Unicorn Overlord on a MacBook Pro's speakers: 250–290 underruns in every 2000 callbacks at 48 kHz (0.1–0.2 s of zeros), about 1,000 at 44.1 kHz. Whether a game underruns depends on how much it queues: 13 Sentinels (2.8 blocks queued, like Unicorn Overlord's 3.0, but larger ones) had none at 512 frames.
- Fix: like iOS's session buffer, the Mac sets its output unit's device buffer to about 5 ms of device frames (
kAudioDevicePropertyBufferFrameSize, 240 at 48 kHz, 221 at 44.1 kHz), within the device's supported range (au_bufferinhle_audio.c). It reapplies this when the default output changes and when the same device's output sample rate changes;CurrentDevicealone does not notify a rate change. An unchanged buffer is not written again, since a write can itself notify the format listener. Both listeners are removed before uninitializing or disposing the unit, including a failed open: disposal otherwise calls the listener after the device has gone (!obj). The log reads back the actual frame count.DM_DBG_AU_FRAMES=Nasks N frames instead. - Found on: Unicorn Overlord (Asian release 1.05 on the Mac).
- Check: PR #262 reports Unicorn Overlord at 240 frames: 0 underruns in 10,000 callbacks; 13 Sentinels stays at 0. A silent Core Audio probe on a Mac mini reproduced the disposal error and the stale buffer after a rate change, then verified the fixes: default output switched between USB at 48 kHz and speakers at 44.1 kHz with callbacks continuing, and the same speakers at 44.1 / 96 / 48 kHz used 221 / 480 / 240 frames. The original default output and device rates were restored.
make -C dm/host/tests GAME=<id> audio-devicechecks setup, device and rate notifications, scope filtering, buffer limits, synchronous notifications, the diagnostic override, absent devices, close and failed-open listener cleanup without audio hardware. - Open: the listed HDMI output was not retained as the system default during the probe, so switching to it remains unvalidated. The probe verifies silent host playback; gameplay listening after these listener changes has not been repeated.
Underruns in a run without a window
- Symptom: a windowless Mac run logs intermittent audio underruns. A long frame can occur around the same time.
- Cause: macOS normally starts a shell-launched host with an unspecified task role. XNU caps interactive QoS at the legacy level for that role, even when the host requests interactive QoS for guest threads. Under CPU contention the thread that feeds AudioOut can miss the time it has to refill the game's queue. XNU task policy.
- Fix: when
DM_WINDOWis unset, the Mac front end requestsTASK_DEFAULT_APPLICATIONto lift the QoS ceiling. SetDM_WINDOWLESS_ROLE=0to keep the existing role for an A/B run. If macOS refuses the request, the host logs the Mach error and starts the guest. - Check:
t_front_rolealways checks the opt-out and the installed role. Thexcode-27runner on macOS 27.0.1 set the role but kept interactive priority at 20.taskpolicy -c utilityreproduced that result on an Apple M6 with macOS 27.2.1, where an ordinary launch went from 31 to 46. The test skips the priority increase assertion when both readings agree below the legacy ceiling. GitHub sanitizer job, NieR role comparison. - Found on: NieR:Automata The End of YoRHa Edition.
The ring / silent switch muted the game on iOS
- Symptom: a game is silent on an iPhone whose ring / silent switch is set to silent, though the volume is up; a game or video app plays through the switch.
- Cause: the audio session's category was
AVAudioSessionCategorySoloAmbient, which iOS silences with the switch. - Fix:
front_ios_audio_sessioninfront_ios.msetsAVAudioSessionCategoryPlayback: the switch no longer mutes the game, and it still interrupts other apps' audio, asSoloAmbientdid. The host still suspends its output when the app goes to the background (no background audio mode is declared). - Found on: The Legend of Zelda: Breath of the Wild (iPhone: reported by the player); also issue #155, whose commenter has to toggle the switch to hear any game.
- Check: open question, not run on a device: with the switch on silent, the game's sound should play; the log's
audio session:line shows the session came up.
Interruptions that stop RemoteIO callbacks
- Symptom: sound stays silent after Siri, an alarm, a call or another app's audio; a game whose audio thread waits for its buffers back (Wwise's poll-only output, FMOD) then waits forever.
- Cause: iOS stops calling the RemoteIO unit back without stopping it, so the host still thinks the output plays.
- Fix: three layers handle it:
front_ios.mobservesAVAudioSessionInterruptionNotification(began → the silent sink stands in, ended → session up again and resume; becoming active also ends an interruption whose "ended" never came);front_ios.malso observesAVAudioSessionMediaServicesWereResetNotification(dm_audio_resetrecreates every AudioUnit);- a watchdog in
hle_audio.cswitches any started output whose device has not called back for 200 ms in focus to the silent sink, retrying the AudioUnit after 1, 2, 4, 8 s. A start that fails (session still held by a call) falls back the same way instead of aborting.
- Check: the log shows
audio session: interrupted,the device has not called back for N msandAudioUnit restarted.tests/t_audio.c(indm/host) scenario 3 stops a playing AudioUnit behind the host's back.
Audio gap after switching stereo outputs
- Symptom: up to about a second of game audio is lost when switching between stereo output devices. On iPhone, PR #2863 reports a gap when AirPods connect during play.
- Cause: Core Audio can pause render callbacks while switching devices. The host checked the channel count on a route change, so a stereo-to-stereo move used the same 200 ms stall check as an output that failed on an unchanged route. On a Mac mini M6 with macOS 27.2.1, a switch from USB to HDMI that then reverted to USB hit the stall check at 212 ms. The watchdog stopped the AudioUnit and waited another second to retry. Callbacks resumed 1.31 s after the switch request on main
d2fd78b4. - Fix: the existing route handler tells the watchdog when the output moves. It lets Core Audio finish the handoff and keeps the queued PCM available while the unit is running. A callback gap of over 200 ms on a new route triggers an immediate restart once the route has had 250 ms to settle. Repeated changes can extend that wait to 500 ms of callback inactivity. If the silent sink has already taken over, the new route brings the next attempt forward. Failed attempts use the usual backoff and keep the game paced. On iOS the same session observer detects output changes by port type and UID and reapplies the channel preference. The channel-count path still replaces a unit when its input layout has to change.
- Check:
t_audio_deviceadvances the watchdog clock explicitly. It covers a callback gap longer than the usual stall interval that resolves with its PCM intact, a route that stays stalled, a second switch during a blocked start, and backoff after the prompt retry fails. - Live Mac check: on a Mac mini M6, macOS 27.2.1 and Xcode 27.2, the stereo USB output and built-in speakers switched in both directions and the AudioUnit followed without a host restart. With callbacks deliberately suppressed until the next AudioUnit start during those same hardware switches, callbacks resumed after 332–344 ms with this change, compared with 1,295–1,302 ms on main
d2fd78b4. Each run confirmed that the unit was on the requested device. - Found on: Persona 4 Golden, as reported from the NX18 fork in PR #2863. Physical iPhone and AirPods verification on the host revision is open.
A blocked audio device start freezes the game
- Symptom: a game stops advancing while the Mac's selected output refuses to play. A process sample shows
AudioOutputUnitStartwaiting in the HAL, with the game's audio renderer waiting for a released PCM buffer. - Cause: Start and the watchdog's retries stopped the silent sink and waited for the device while holding the output registry lock. A driver could block there for seconds or return success without delivering any callbacks.
- Fix: the silent sink paces the guest at 48 kHz while a host worker starts the device. Until the watchdog sees a callback after startup and joins the silent sink, the device returns silence. A device that fails to deliver its first callback within one second is stopped and retried with backoff. Each output can start independently. A Close during a start that the driver still holds returns at once: it unregisters the output, and the start's worker stops and disposes the unit and frees the output when the driver returns (waiting for it in Close held the game's thread as long as the driver blocked).
- Check:
tests/t_audio_device.c(indm/host) blocks the mock driver'sAudioOutputUnitStart: Start returns and the queued buffer is released, callbacks play silence until the handoff, and Stop / suspend / reset / Close each run while the start is still blocked. - Open:
AudioOutputUnitStopstill runs underg_aos_lock(Stop, suspend, the media services reset, the watchdog's stall path). A driver that blocked there as it does in Start would hold the lock; not seen so far. - Found on: Splatoon Raiders, with an unavailable HDMI audio output on the Mac (issue #1030).
AudioUnit construction before output publication
- Symptom: TSan reports
au_createwritinga->auwhileau_watchdogreads it underg_aos_lockwhen a second real output opens (issue #410). - Cause:
au_open_atput the output into the lifecycle/watchdog registry before joining its AudioUnit construction helper. The registry lock did not order the helper's writes. - Fix: construct and join while the output is private, then publish it under
g_aos_lock. Suspend, resume, reset and watchdog readers only discover the completed output. Construction remains outside that lock because joining the helper can yield the guest core. - Check:
t_audio_deviceasserts from inside AudioUnit creation that the pending output is absent from the registry; it failed before the fix.t_audioexercises real output lifetimes and watchdog recovery under TSan with theau_createsuppression removed. - Found on: host unit tests; no particular game's failure was attributed to this race.
Audio across a background round trip on the Mac
DM_AUDIO=1 DM_AUDIO_MUTE=1 takes the real Core Audio path with the output silenced, and DM_OE_SCRIPT="bg=1@60,bg=0@66" runs the same sequence as the iOS lifecycle callbacks (focus, audio take-over, guest clock freeze, graphics suspend). Send dmhost SIGSTOP / SIGCONT between the two to imitate iOS suspending the process. The silent sink that stands in while in the background does not make up the time the process was suspended (it used to pull seconds' worth at once and log hundreds of underruns).
Several outputs at once (audio #N)
- Symptom: combined numbers mislead: one fully fed output plus one fed by nobody look like "every other callback underruns, 2.0 blocks queued".
- Cause: a game may open several outputs. Engage opens one AudioOut from Wwise (
main+0x177d924, no release event, the game polls); on the phone it opened a second one later, and the Mac runs never did. Unity's FMOD also has an output (main+0x4aec0c/0x4aec4c). - Fix: the host logs each output as
audio #N: the open with its call site, Start / Stop / Close (the first 32 per output), and the callback statistics normally every 2000 of that output's callbacks, through the watchdog. - Found on: Fire Emblem Engage.
Checking audio without listening
DM_AUDIO_DUMP=file writes the PCM the host plays (16-bit, 48 kHz, stereo). RMS per second, clipping share, spectral flatness (music ≈ 0.1–0.5, white noise ≈ 0.85) and the strongest FFT peaks (they should land on musical notes) tell real music from noise or silence.
AudioOut volume kept per output
- Symptom: a null read at
sdk+0x1f2314as the first movie starts (the title menu's background, right after the first press), innn::audio::SetAudioOutVolume, called frommain+0x1c4fbc. - Cause: the call is on the AudioOut the game opens for the movie's AAC sound (
OpenDefaultAudioOutwithout an event,main+0x1c48c0). The SDK's version calls the audout session's virtual method, and the host never made the session. The game sets the volume every frame while a movie plays. - Fix: the host keeps the volume per output and scales the PCM16 it plays, saturating;
GetAudioOutVolumereads it back (hle_audio.c). - Found on: STEINS;GATE RE:BOOT (SDK 20.5.17, M2's ADV engine; the one call it needed).
AudioOut buffer count from the host queue
- Symptom: a null read in
audio::GetAudioOutBufferCounton Wwise's sink wakeup thread (sdk+0x1e7ed0, frommain+0x30faae8). - Cause: after every release event Wwise asks how many buffers are still queued and marks the sink starved at 0; the SDK's version read the audout session the host never made.
- Fix: it answers from the host queue: appended and not yet played to the end (
hle_audio.c). - Found on: Pokémon Legends: Z-A (19.3.11; one boot).
Audio device output volume and names
- Symptom: an abort in
sm::Initializeunderaudio::GetAudioDeviceOutputVolume(the game thread,main+0xee8edc). - Fix: the volume
SetAudioDeviceOutputVolumesets is now kept and read back (hle_audren.c).audio::GetAudioOutNameis hooked too. - Found on: DRAGON QUEST VII Reimagined (SDK 19.3.1, Unreal Engine 4.27:
GetAudioDeviceOutputVolume); 13 Sentinels: Aegis Rim (SDK 11:GetAudioOutName). - Note: older SDKs name some device calls differently (
ListAudioDeviceName/GetActiveAudioDeviceName,OpenDefaultAudioOutin SDK 12; Older SDK names for the same calls), and Super Mario Odyssey (SDK 7) aborted inaudio::AcquireAudioDeviceSwitchNotification(SDK calls that open a system service through sm).
The output device notification under its SDK 21 and 22 name
- Symptom: an
nn::diagabort with Result 0xe15 on an audio thread at start, inaudio::CreateUserClientSessionByHipcunderaudio::AcquireAudioOutputDeviceNotification, after the linesf: the game connects to service aud:u itself. - Cause: SDK 21 and 22 name the output device notification
AcquireAudioOutputDeviceNotification(older SDKs:AcquireAudioDeviceNotificationForOutput, and SDK 7'sAcquireAudioDeviceSwitchNotification). SDK 22.2.0's version (sdk+0x1f1e00) opens a user session withaud:u, which the host does not serve, asks it for a read end and attaches it AutoClear. It keeps no per-process flag (the service keys each acquire by its event) and returns a Result. - Fix:
hle_audren.ctakes the name over, first for SDK 21 (Splatoon Raiders); the same takeover serves SDK 22. The event is bound, signaled on a host output-route change, and the Result is 0. Signals use its binding lifetime, so destroying and reusing the same event storage cannot redirect an old audio subscription. The takeover keeps the older names' once-per-process flag, so a second acquire returns 0x499 where SDK 22.2.0's code would bind again. No game has been seen to acquire twice. - The release:
ReleaseAudioOutputDeviceNotification(sdk+0x1f2ac0in Nintendo Switch Sports Resort's sdk) asksaud:uthrough the device session coordinator, then destroys the event. The game destroys the event itself only if it is still initialized afterwards (main+0x3af11a0).hle_audren.ctakes it over: it destroys the event it bound (which drops the binding) and clears the flag, so a later acquire binds again. With nothing acquired it does nothing.t_audren_workcovers acquire, the refused second acquire, release and acquire again. - Found on: Fire Emblem Fortune's Weave (Switch 2, SDK 22.2.0,
main+0xe7b9c); Nintendo Switch Sports Resort (04008E001F098000: the release,main+0x3af119c).
No audio input devices
- Symptom: SDL3's audio driver lists the input devices (AudioIn) when its audio starts.
[RED] sf: the game connects to service audren:u itself, thennn::diag abort: Result 0xe15underaudio::AcquireAudioDeviceNotificationForInput(sdk+0x5633c). - Cause: the host has no microphone. The input device-change notification goes through the audio device service, like the output one the host answers.
- Fix:
ListAudioInsreports none, both opens fail, and the calls that need an open AudioIn answer without touching the game's object (hle_audio.c).AcquireAudioDeviceNotificationForInputbinds an event that is never signaled and returns 0x499 when acquired again, as the SDK does with a flag of its own (SDK 13.3.0sdk+0x56300:+0x851, the output's+0x852;hle_audren.c). - Found on: Absolum (SDK 18.3.2, FNA on .NET NativeAOT with SDL3; one boot each); Portal 2 (SDK 13.3.0: its audio thread at start,
main+0x19f37c).
Virtual audio input streams (SDK 21/22)
- Symptom:
[RED] sf: the game connects to service auddmg:u itself, which the host does not serve, thengame called nn::diag abort: Result 0xa99atsdk+0x1f61acunderaudio::ListVirtualInputDevices. On main before real input support, the safe empty list also kept the game from hearing a microphone. - Cause: the game lists virtual input devices when its audio starts (
main+0xf48124) and opens the first withaudio::OpenInputStreamif there is one. The host intercepts those SDK symbols because it has noauddmg:uservice. - Fix: the Mac app offers an off-by-default microphone setting when a packed module imports the supported polling open. If enabled, the app requests macOS consent before it starts the host, including when the settings window is hidden. When enabled and authorized, one AUHAL unit feeds bounded queues for the polling streams. The callback uses preallocated buffers (resetting
mDataandmDataByteSizebeforeAudioUnitRenderand reading the rendered buffer pointers), downmixes and resamples the device to 48 kHz mono PCM16, and appliesDM_MIC_GAIN(default1, unity, range1..8) and a soft limiter. A full queue drops incoming frames. Device changes rebuild capture off the callback thread, including returning from a missing device while streams stay open. If disabled, denied, or on iOS, the list is empty and opens fail. Legacy AudioIn, event-based streams, and guest stream statistics remain open. #2796 - Default gain:
DM_MIC_GAINoriginally defaulted to4(+12 dB), which raised realistic laptop room noise (-40 dBFSpeak /-44.8 dBFSRMS →-28.0 / -32.7 dBFS) above Ocarina of Time Humming mode's end-of-phrase silence floor so learned songs matched in DTW (23 hits) but never finalized or triggered in-game. At unity (DM_MIC_GAIN=1), the same-40 dBFS-noise phrase finalized (dtw=0.135) and triggered in-game playback, and quiet-36 dBFSsinging also passed (dtw=2.30), as the game runs its own AGC and adaptive floor tracking. End-to-end synthetic-backend checks inside Ocarina of Time on an M6 (macOS 27.2.1) verified48 kHzmono, resampled44.1 kHzmono, and stereo downmix with zero underruns or drops. Hardware retest on a MacBook built-in microphone and physical USB unplug/replug remain open. - Found on: The Legend of Zelda: Ocarina of Time (SDK 22.2.8). PR #1822 reports Mac gameplay with built-in and USB inputs, including resampling from 44.1 kHz. Star Fox imports the same calls.
A DualSense's microphone over Bluetooth
- Symptom: with a DualSense connected over Bluetooth and its microphone asked to stream, the game reads buttons and sticks no one touched. With the controller lying still, GameController reported about 1,300 button presses and 300 sticks past half in 5 s. Over Bluetooth the controller is in no input-device list (macOS's Sound settings, the launcher's picker). Over USB it is an input device, but its mic may stay silent: muted, or in power saving.
- Cause: over Bluetooth the DualSense carries its microphone in its own HID input reports. After output report
0x32asks for it (an audio-control packet0x11with bit 7 set, mask bit 0), input report0x31with byte 1 bit 1 set holds a mic frame in place of the pad's state: a frame counter at byte 2, then 71 bytes of Opus (10 ms). Two things make that unusable on a Mac:- GameController does not tell those reports from the state reports, and reads every mic frame as the pad's state.
- macOS polls the controller every 15 ms, 66 reports a second in all, while the mic alone makes 100 frames a second. With the mic on, 43 mic frames and 22 state reports arrived each second, every report in sequence: the controller drops the other frames itself (its frame counter steps by 1 to 3).
- Fix: none over Bluetooth; the host never asks for the mic there. Over USB the controller is a USB audio device that the AUHAL capture records like any microphone. The launcher identifies a DualSense or DualSense Edge on USB from CoreAudio's
kAudioDevicePropertyModelUID(054C:0CE6/054C:0DF2) and labels it "(USB)". When capture opens one, the host correlates the audio device to its own USB HID controller by USB VID:PID andlocationID(from itsAudioBox'sBoxUIDorAppleUSBAudioEngineDeviceUID) or unique serial—failing closed on mismatch or ambiguity—and sends output report0x02(SetState), selecting the built-in mic, unmuted, without power saving (dualsense_mic_mac.c,audio_input_dualsense_mac.m). The formats come from the controllers wiki's DualSense data structures and awalol/DS5Dongle (MIT). - Found on: The Legend of Zelda: Ocarina of Time's Ocarina Mic Input, on an M5 Pro Mac with macOS 27.2. A probe sent the same
0x32report and counted what arrived: 5 s with the controller lying still, then 12 s moved and hummed into (the hum decoded at about 120 Hz, from 43% of the frames). After the stop report, the phantom input ended. Over USB, on a USB-C cable: the log'sbuilt-in mic selected and unmuted, captures at 48 kHz stereo with no underruns, zero fill or drops, and a live hum taken for Zelda's Lullaby at gain 2. The input is hot: at macOS's input volume for it (0.10), a hum at the controller clips before the gain, so a low gain suits it. DualSense Edge and multi-DualSense hardware checks remain open. - Check:
make -C dm/host/tests GAME=<id> dualsense-micchecks the USB report byte for byte and the CoreAudio-to-HID USB matcher. When capture opens a DualSense's USB audio, the log showsaudio input: DualSense over USB ("…", loc=0x…): built-in mic selected and unmuted.
OpenAudioOut without a release event (SDK 22)
- Symptom:
game called nn::diag abort: Result 0xe15, call site sdk+0x1f8704, i.e. insidenn::audio::CreateAudioOutManagerByHipc+0xb4, before any audio device opened. - Cause: SDK 22 calls
nn::audio::OpenAudioOut(AudioOut*, const char*, const AudioOutParameter&)(sdk+0x1f7914,nn::audio::OpenAudioOut(AudioOut*, const char*, const AudioOutParameter&)'s failure path) — the overload without theSystemEventthe host implemented (_ZN2nn5audio12OpenAudioOutEPNS0_8AudioOutEPKcRKNS0_17AudioOutParameterEPNS_2os11SystemEventE). With no hook the SDK's own IPC path ran and the audout service is not there. - Fix:
hle_audio.cgained the 4-argument hook, which opens through the sameau_open_atand leaves the release event NULL (au_open_at(g, NULL, name, param, __builtin_return_address(0))), so the output polls its released buffers. The log then readsOpenAudioOut … , no release event (the game polls). - Found on: Well Dweller (SDK 22.2.0); the game's first
AudioOutis the "DeviceOut" form, the second its 48 kHz music output.
SDK 21's OutputStream on a virtual output device
- Symptom:
[RED] sf: the game connects to service auddmg:u itself, which the host does not serve, thengame called nn::diag abort: Result 0xa99undernn::audio::GetDefaultVirtualOutputDevice(sdk+0x221520,audio::detail::GetVirtualOutputDeviceProperties). - Cause: SDK 21 has a second output interface beside AudioOut:
GetDefaultVirtualOutputDevicenames a virtual device,OpenOutputStreamopens a stream on it with aStreamFormat{sample format, channels, sample rate} (5, float), a capacity in frames and, in one overload, a system event; the game writes a period at a time withWriteOutputStreamonceGetOutputStreamFreeFrameCountcovers it, waiting on the event with a short timeout between writes. States as games read them: 0 not open (the SDK's own answer for a null stream), 1 stopped, 2 started: a game's close path stops a stream in state 2 and purges and closes one in state 1, so a wrong answer leaves it open for good.GetOutputStreamStatisticsreturns a 24-byte struct through x8. Every call reaches the service. - Fix:
hle_audio.copens one AudioOut per stream, its release event the stream's: each write becomes a 16-bit interleaved block (float clamped and scaled), the free count is the capacity less the frames still queued,Purgedrops the queued blocks,SetOutputStreamGainis the AudioOut's volume (no fade),StartOutputStreamsstarts several, and the statistics report nothing. Input streams have their own capture path. The default virtual device isAudioVirtualOutput, a name of the host's. - The frames are interleaved:
WriteOutputStreamtakes L, R, L, R, although the game's code that zeroes an unfilled tail (main+0xad1684) steps by a period per channel. Read as planar, each 10 ms block's first half played as left and its second half as right, each at half speed: all sound an octave low (voices very deep) with a jump at every block (crackling). InDM_AUDIO_DUMPthat shows as a spectrum mirrored about 12 kHz (33-39 % of the energy above 20 kHz where 0.00 % belongs) and channels whose samples alternate between two signals (lag-1 autocorrelation 0.18, lag-2 0.99).t_output_streamchecks the order. - A larger statistics result ends the game: Star Fox keeps its 24 bytes at
spwith its stack canary right behind them (main+0xbce9b90), so a 32-byte result ended in__stack_chk_failon the audio thread (CRASH sig=4,lr=main+0xbce9f98). - Focus: Star Fox closes its stream when its window loses focus and opens a new one when it regains it; 14 rounds went by with the sound intact.
- Found on: Xenoblade Chronicles 2, Nintendo Switch 2 Edition (
0400E95004038001) (SDK 21.4.4, one or two 2-channel streams at 48 kHz, 10 ms periods, 40 ms capacity; the second when the active device isAudioExternalOutput); Star Fox (Wwise 2024.1, SDK 21.4.4).
The virtual output device's properties, and the OutputStream open without flags
- Symptom:
[RED] sf: the game connects to service auddmg:u itself, which the host does not serve, thengame called nn::diag abort: Result 0xa99, call site sdk+0x224d1c(audio::detail::GetVirtualOutputDeviceProperties), right afterGetDefaultVirtualOutputDevice. - Cause: before each OutputStream open the game asks for the default virtual output device's properties with
nn::audio::GetVirtualOutputDeviceProperties(main+0x5eda90,main+0x7a0414); the SDK's version asks the device manager service for the device's 0x228-byte profile. It then opens the stream with theOpenOutputStreamoverload that takes no flags (main+0x5edb34), which the host did not take over either. - The properties:
VirtualDevicePropertiesis 0x110 bytes, filled from the profile atsdk+0x224cd4: the name asked about (+0x00, 0x100 bytes); the profile's +0x218 at +0x100, the device's shortest stream as a duration in ns (OutputStreamImpl::Openrefuses a capacity under ceil(duration x rate / 1e9) frames with 0x899,sdk+0x225a94; the input stream open the same); and the profile's +0x108 at +0x108, a 32-bit word nothing in the sdk reads. Both of the game's callers, and Donkey Kong Bananza's two (main+0x57cadc,main+0x187cee4), only test the Result. - Fix:
hle_audio.canswers for its one device,AudioVirtualOutput: the name, a shortest stream of 10 ms (one period as Xenoblade Chronicles 2 and Star Fox write it; the host's own open sets no minimum) and 0 in the unidentified word. Any other name gets a red line and a failure. The overload without flags opens like the others.t_output_streamcovers both. - Open: what the +0x108 word means; no caller seen reads it.
- Found on: Nintendo Switch Sports Resort (
04008E001F098000; SDK 20+).
The AudioOutBuffer handed to the SDK is its own 40-byte object
- Symptom: a game that resamples its own audio plays, in one block of every four, the sound of four blocks earlier: Metro 2033 Redux (44.1 kHz to 48 kHz in the game's own resampler) re-appended 518 of its 2,095 loud 8192-byte blocks (24.7 %) still holding the contents of the block 4 appends back, so that audio left 170.6 ms behind; after the fix 0 of 1,989, with no block appended twice or lost and no underruns.
- Cause: the host declared
nn::audio::AudioOutBufferas 24 bytes, data at +0x00, capacity at +0x08, data size at +0x10. The SDK's object is 40 bytes,{next, buffer, buffer_size, data_size, data_offset}, the audout service's own buffer format: data at +0x08, capacity at +0x10, data size at +0x18 (SetAudioOutBufferInfo,sdk+0x80f80; the same in Hades's SDK,sdk+0x142ab0). The SDK'sAudioBufferListlinks buffers throughnextat +0x00, where the old layout wrote the data pointer. The host does not takeGetAudioOutBufferBufferSizeover, so the SDK's own (sdk+0x80fb0) read the host's data-size field as the capacity and answered with the previous block's: 2047 frames of the 2048 the resampler had room for. On every fourth block the resampler then wrote nothing, and the game appended that block at full length holding the earlier contents. - Fix: the host's buffer description is the SDK's object: one definition,
aout_bufindm/host/hle.h, five fields at the SDK's offsets with a_Static_asserton them, whichhle_audio.c's AudioOut and the blockshle_audren.cappends to it both use. The descriptor functions (SetAudioOutBufferInfoin both overloads,GetAudioOutBufferDataPointer,GetAudioOutBufferBufferSize,GetAudioOutBufferDataSize) run in the sdk, as AudioIn's do, so no accessor can read a layout of the host's; they are the same plain stores and loads in the SDKs of Metro 2033 Redux (SDK 8.2.0), Hades, Fire Emblem: Three Houses (which also has the overload without a buffer size, storing only +0x08 and +0x18) and PRAGMATA (Switch 2).GetAudioOutBufferBufferSizeanswers 8192 on every block. - Found on: Metro 2033 Redux (SDK 8.2.0, 4A Engine).
- Check:
t_audio's buffer-layout case hands the device callback an object written at the SDK's own offsets, itsnextlinked and its data size 4 bytes short of its capacity: the callback must play exactly the data size from the data pointer, release the buffer and leavenextalone. Under the 24-byte layout it would readnextas the data.
Output channels
The output route decides how many channels the device takes: six when the device's current stream format has six or more (dm_audio_output_channels, hle_audio.c; on iOS the audio session's output channels, front_ios.m), otherwise stereo. Games read it from GetActiveAudioDeviceChannelCountForOutput and the SDK 7 name, and each output AudioUnit follows it. The in-process renderer queues both its six channels and its original stereo fold (hle_audren.c).
Stereo only on a 5.1 system
- Symptom: on a Mac connected over HDMI to a 5.1 TV, receiver or soundbar, or an iPhone on such a route, a game that writes six channels plays in stereo: its center, LFE and back channels come out of the front pair as a downmix. The game is told the device has two channels.
- Cause:
GetActiveAudioDeviceChannelCountForOutputreported two channels on every route, and every six-channel output was downmixed to stereo before it reached Core Audio. - Fix: the host reports the route's count, and a six-channel output on a six-channel route goes to the unit as it is, with the unit's input layout set to
MPEG_5_1_A(front-left, front-right, center, LFE, back-left, back-right). Core Audio then maps each channel to its speaker in the device's own layout. On HDMI that order puts the LFE before the center (L R LFE C Ls Rs …), so six channels sent without a layout would play the center on the LFE. On a stereo route the host downmixes a six-channel output with the renderer's default coefficients; Core Audio's own 6 → 2 would keep only the front pair. Outputs with another channel count go as the guest writes them, and an output opened with a channel count of 0 is stereo.dm_audio_routereads a cache initialized on the calling host stack (all HLE takeovers already switch to it). The Mac listens to the system default output and that device's stream format, including when no AudioUnit is open; opens and resume also refresh it. A changed channel count or Mac device identity publishes the cache before scheduling the guest's output-device notification off the audio registry lock.- The Mac's route is the device's stream format: a device set to six or more channels (in Audio MIDI Setup, or by an HDMI sink's EDID) is a six-channel route. The host does not change a device's format.
- On iOS the session asks for
maximumOutputNumberOfChannels(up to six) at boot, on return to the foreground and on each route change. Headphones, AirPods included, are expected to report two channels and stay stereo (not yet seen on a device). - A route change while an output plays queues a check off the notifying thread. Each six-channel guest output, or host DeviceSink output, whose unit no longer fits the route gets a replacement through the same lifecycle path as an iOS media-services reset (
au_reopen). The silent sink paces queued audio meanwhile; a start still held by the driver retains its old unit until it returns. A failed replacement is tried again on the next route change or resume. iOS asks for the new route's channels before checking, and resume checks changes made during suspension. - The in-process renderer never freezes its format to the opening route. Each queued sample contains six channels followed by a stereo fold computed from the original int32 mix before resampling and clamping. The device callback selects six or two, even halfway through a queued block. This preserves current main's stereo PCM at both 48 kHz and 32 kHz: folding already clamped surround can destroy cancellation (front-left -30000 plus center 60000 gave -6834 instead of 12420). Guest AudioOuts retain the count the game opened; their device-change event lets the game query the new count and reopen when needed.
DM_AUDIO_DEVICEpins the Mac's output to a device by name, for tests. BlackHole 2ch reads as stereo; a six-channel virtual device needs BlackHole 16ch (its first six channels carry the 5.1 signal).
- Open: switching between BlackHole devices can pause callbacks about 230 ms before the route notification. See Audio gap after switching stereo outputs for the watchdog's recovery once the host sees the change. The system's binaural rendering of six-channel PCM over AirPods Pro 2 (
setSupportsMultichannelContent,isSpatialAudioEnabledon the route) remains untested. The route is the device's first output stream; a device whose first stream is stereo stays stereo. - Checked: the current-main rework adds route changes without an open unit, selecting both representations mid-block, and destroyed/rebound notification lifetimes. Stereo PCM hashes match the pre-surround output at 48 kHz and 32 kHz over three frames including clipping and resampler history.
t_audio_device(mock units: six channels reach the device unchanged with the layout set, the downmix values and its clamp, the route's count, a route change both ways, a failed new unit made again at the next change, stereo and mono outputs left as they are) andt_audren_layout(the six-channel resampler, the sink's six inputs in order, a mono sink on the front pair).dm/tools/audio_channel_check.pyplays test tones (440, 660, 880, 60, 1320, 1760 Hz for front-left, front-right, center, LFE, back-left, back-right) through the host on a named device and captures that device's input in-process (DM_AUDIO_CAPTURE): the check asks for each channel's own tone 12 dB above the others, and for the downmix within 1.5 dB of the host's coefficients (--stereo). PR #2234 author's measurements: on BlackHole 16ch each channel carried its tone at 0.200, with the others more than 100 dB down; on BlackHole 2ch the downmix came within 0.05 dB. With BlackHole 16ch set to HDMI's layout, the captured center tone came out on channel 4 and the LFE on channel 3.t_audio_livewithdefault=andswitch=moved the output between BlackHole 16ch and 2ch while it played: after each switch the new device carried the 5.1 signal or the downmix (center and back at 0.141, LFE at 0.050 for 0.2 tones). - Current-main rework validation: MacBook Pro M4 Pro, macOS 27.2.1, Xcode 27.2: audio/output-stream/SPSC/statistics/device/renderer fixtures pass, including ASan/UBSan on the changed frame and route boundaries. A real stereo AudioUnit consumed an eight-value 100 ms silent DeviceSink block in 101.7 ms. Only built-in stereo speakers were available: the rework has no new physical six-channel or iOS hotplug confirmation. Synthetic capture CPU time per 5 ms frame (median of three 10,000-frame batches,
-O1, compared with main2925d7af): 0.37 to 1.19 us at 48 kHz and 1.61 to 10.61 us at 32 kHz; these measure capture, not a game's total CPU. The four renderer slots and capture scratch reserve 566,688 more bytes (0.54 MiB); active resident memory depends on the renderers opened. Keeping both representations adds neither a polling thread nor per-frame allocation. - Found on: PR #2234's host probe on a Mac over HDMI to an LG TV, passed over eARC to a Sonos system (the TV reads as 8-channel 48 kHz PCM in HDMI's order):
t_audio_livewithDM_AUDIO_LIVE_PCM(a spoken name on each channel and a 45 Hz tone on the LFE) played each from its own speaker. Not yet checked in a game, or on an iPhone.
Codecs
Hardware Opus decoders built on the SDK's software decoders
- Symptom: an abort in
sm::Initializeunder the hardware Opus decoder's C interface; for the multi-stream one, undernn::codec::GetHardwareOpusMultiStreamDecoderWorkBufferSize(int, int, int, int, int)(atnnMain, CRI's Opus streams). An abort insf::hipc::InitializeHipcServiceResolutionundercodec::GetHardwareOpusDecoderWorkBufferSize(int, int)(main+0x31f8e8, early innnMain). A game that buildsHardwareOpusMultiStreamDecoderwith the imported constructor and then calls it through its vtable. - Cause: the hardware decoders are a service. The
HardwareOpusMultiStreamDecoderclass's 12 vtable slots match the SDK's softwareOpusMultiStreamDecoderone by one. SDK 11 has a work buffer size form without the option argument; the host had only the three-argument one. - Fix (
hle_codec.c):- the classes: the constructor binds to the software class's, which builds the software decoder in place (0x38 of the 0x48 bytes), as for the single-stream
HardwareOpusDecoder, and so do the members (A hardware Opus class's members called directly);GetHardwareOpusMultiStreamDecoderWorkBufferSizereturns the software size. Both destructors are a bareret. - the single-stream C interface (
GetHardwareOpusDecoderWorkBufferSize,InitializeHardwareOpusDecoder,DecodeOpusInterleavedWithHardware, …) is forwarded to thesdk's softwareOpusDecoderC interface with a host-held decoder state per game object. - the multi-stream C interface, including the SDK 12+ overload with an option argument, goes to the
sdk's softwareOpusMultiStreamDecoderC interface, with a host-held state per game object as for the single-stream decoder.GetHardwareOpusMultiStreamDecoderProcessingTimereports 0. - the two-argument
GetHardwareOpusDecoderWorkBufferSizeis hooked beside the three-argument one.
- the classes: the constructor binds to the software class's, which builds the software decoder in place (0x38 of the 0x48 bytes), as for the single-stream
- Found on: Hyrule Warriors: Age of Calamity (SDK 9.6: only the
HardwareOpusMultiStreamDecoderclass and the four-argument size); The Legend of Zelda: Tears of the Kingdom (1.4.3, the single-stream C interface); Big Brain Academy: Brain vs. Brain (SDK 11.4.3, the two-argument size); Unicorn Overlord (SDK 16.2.4, the multi-stream C interface; one boot).
A hardware Opus class's members called directly
- Symptom: an abort under
hwopus(or a second, uninitialized decoder) in movie or audio setup, from a game that callsnn::codec::HardwareOpusDecoder's members itself (Initialize,GetWorkBufferSize,Finalize,DecodeInterleaved, the destructors), not throughIOpusDecoder's vtable. - Cause: the host took over only the constructor, which builds the SDK's software
OpusDecoderin the object. Calls through the vtable then reach the software members, but a game that holds the decoder by value or by its own class calls the hardware members directly (the compiler devirtualizes them), and they ran on the software object. In Super Mario Party'ssdk,Initialize,DecodeInterleavedandGetWorkBufferSizego to the hardware C interface (which the host serves with a second decoder state beside the object), andFinalize,IsInitialized,GetSampleRate,GetChannelCountandResetread the hardware layout (Finalizecalls through+0x08,sdk+0x22ff10). The multi-stream class is the same. - Fix: each hardware member, both classes, binds to the software class's member of the same signature: a guest alias (
HLE_FORCE_ALIAS,hle.h), an entry in the forced take-over table that binds every reference to the loaded modules' definition of another name, with no host code and no restated signature. The constructor is one too (the option inw1has no software counterpart);C2andD2bind toC1andD1, the same code without virtual bases. Each SDK defines the same member set for both classes of a pair (Super Mario Party's hasResetand noDecodeorSetContext, ŌKAMI HD's the reverse); a target no module defines is logged as a red line and the reference keeps its binding.t_symbolschecks the alias binding. - Found on: Just Dance 2022 (
0100EA6014BB8000, SDK 11.4.0; PR #2746, not in the games table) and Rayman Legends: Definitive Edition (SDK 1.3.1; PR #1540). The bindings were checked against Super Mario Party's and ŌKAMI HD'ssdksymbols.
A hardware Opus class decoded through the C interface
- Symptom:
FATAL Opus decoder <addr> was not initialized by the hostinDecodeOpusInterleavedWithHardwarewhen playing an Opus track in a game that constructs and initializesnn::codec::HardwareOpusDecoderthrough the C++ class. - Cause: The C++
HardwareOpusDecoderandHardwareOpusMultiStreamDecoderconstructors andInitializemethods bind to the SDK's software classes. Those methods build the softwareOpusDecoderTypeorOpusMultiStreamDecoderTypein guest memory atthis + 0x08behind the vtable pointer, and register nothing inobjmap. Just Dance 2022 initializes its decoder withHardwareOpusDecoder::Initializeatmain+0x843498and passesthis + 0x08toDecodeOpusInterleavedWithHardwareatmain+0x843738.opus_softchecked onlyopus_mgr_dec_softandobjmap_get, and the multi-stream C functions calledopus_softinstead of checkingOpusMultiStreamDecoder. - Fix: When
objmap_getfinds no host block,opus_class_memberinhle_codec.creads the word athw - 8withvm_read_overwriteand compares it against the software class vtable,_ZTVN2nn5codec11OpusDecoderE + 0x10or_ZTVN2nn5codec22OpusMultiStreamDecoderE + 0x10. When it matches,opus_soft_forandopus_fini_forpasshwdirectly to the SDK's software C functions without freeing guest memory.t_codec_opustests both the C path and the mixed C++ and C path for single-stream and multi-stream decoders, plus null, low, unmapped, wrong-vtable, and uninitialized pointers. - Found on: Just Dance 2022,
0100EA6014BB8000v0, SDK 11.4.0, follow-up to PR #2746, not in the games table.
SDK 21's hardware Opus decoder manager
- Symptom:
game called nn::diag abort: Result 0xe15undernn::codec::GetHardwareOpusDecoderManagerWorkBufferSize(sdk+0x323180), the game's sound setup. - Cause: SDK 21's asynchronous interface to the hardware decoder: a manager (
HardwareOpusDecoderManagerType, with a system event, a decoder count and an I/O buffer count) owns decoders (InitializeHardwareOpusDecoderwith a manager). The game enqueues one packet per call (EnqueueOpusDataToHardwareOpusDecoder, Nintendo's 8-byte header and the packet, asDecodeOpusInterleavedtakes it; it expects all of it consumed), callsExecuteHardwareOpusDecoderDecodingonce per audio frame, dequeues finished frames (DequeuePcmInterleavedDataFromHardwareOpusDecoder) as many as the completed count, and reads the waiting / executing / completed counts and the free I/O buffers. It tells an initialized manager by the struct's first word. - Fix:
hle_codec.ckeeps the manager in host state (its pointer in that first word) and decodes with thesdk's softwareOpusDecoder: Enqueue queues the packet and takes an I/O buffer, Execute decodes every waiting packet on the caller's thread and signals the event, Dequeue hands back a frame and its buffer. So a request is never "executing". A packet the decoder refuses completes as 20 ms of silence, with a red line.ResetHardwareOpusDecoderandFinalizeHardwareOpusDecoderserve both interfaces. - Found on: Xenoblade Chronicles 2, Nintendo Switch 2 Edition (
0400E95004038001) (SDK 21.4.4: a mono manager of 128 decoders and 255 I/O buffers, a stereo one of 72 and 160, 48 kHz, 20 ms frames); Star Fox (the same figures).
One key for the two forms of the Opus decoder
- Symptom:
CRASH sig=11 addr=0inh_codec_HwOpusFini, the first time the game finalizes a decoder. - Cause: the older interface keeps the software state in
objmapunder the game's decoder object, and SDK 21's manager form its own record under the same key.opus_mgr_dec_finitold them apart by a field at +0x10, 0 in the software state as far as Star Fox had shown, but the work buffer's size in this one. It read the state as a record, so a pointer in it became the manager. - Fix: a manager's decoder is kept under the object + 1 (
OPUS_MGR_KEY), so the look-up itself says which form it is;GetHardwareOpusDecoderSampleRateandChannelCountnow also read a manager's decoder correctly. - Found on: Kirby Air Riders (SDK 20.5.26, 48 kHz stereo, the older form).
Timing and catch-up
At least one rendered frame between two updates
- Symptom: the light limiter crashed on a null state pointer (
ApplyLightLimiterEffect,sdk+0x228494). - Cause: an effect's "needs init" parameter state is set only in the update where the game flags it new; the next update copies the game's value over it. Mario updates twice in a row at start-up; with a real audio device the first frame came after both.
- Fix: the
AudioRenderSystem::Updatehook renders a catch-up frame first when nothing was rendered since the last update. - Found on: Super Mario Bros. Wonder.
- Check:
DM_AUDREN_TRACE=1logs every update with the number of frames rendered since the previous one.
A sound driver that never waits on the renderer event
- Symptom: the sound runs about 50 times faster than the output; the loop runs 11,000 updates a second on one core.
- Cause: Square Enix's
SQEX::Sd::Driver::Core::CoreAudioOut(its loop atmain+0x442c5c0) appends a wave buffer, mixes the next block on the same thread, callsRequestUpdateand takes the next released buffer. It waits on the renderer event only when no buffer is released. Every update there finds no frame rendered since the last one and renders a catch-up frame, which releases the buffer just appended, so the loop never waits. When a full catch-up queue discarded the frame, the loop ran unchecked. - Fix: an update with a full queue waits (at most 50 ms) for the render thread to play one queued frame, so catch-up frames keep real time (
hle_audren.c). The render thread then only plays queued frames, and the driver's updates render every frame. A queued frame does not signal the renderer event (the SDK signals it in each render): signalled, an ordinary game woke, updated with nothing rendered since and rendered the next catch-up frame, so every frame became one (Big Brain Academy: Brain vs. Brain, about 38,000 catch-up renders instead of 37). - Found on: DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition.
- Check:
audren: rendered 12000 frames, N of them not silentshows whether a game's sound reaches the output.
Burst renders when a device callback releases multiple blocks
- Symptom: villager dialogue crackles while music and sound effects play cleanly. On a 44.1 kHz / 256-frame device,
catch-up renders so fargrows by about 277 per 2,000 renders.DM_AUDREN_TRACE=1shows two renders between updates or two updates 0.02 ms apart followed by an 11.6 ms gap. - Cause: a CoreAudio callback can return several 5 ms blocks together.
render_mainrefilled them back to back, so the game's audio thread could coalesce two renderer event signals or wake twice before it could update between renders. - Fix: after prefill,
render_mainspaces fresh renders at least 4.5 ms apart, using the output's returned blocks to set the number due. The timed wait releases the catch-up queue lock. A catch-up published during the wait takes priority over a fresh render, and its slot stays occupied until the PCM is copied into the output block. - Found on: Animal Crossing: New Horizons. The reporter confirmed clean dialogue on an M4 with 44.1 kHz Bluetooth audio using the original pacing patch. Issue #2981 · PR #2983
- Check:
t_audren_layout --cadencepublishes a catch-up from a concurrentRequestUpdateduring the paced wait and checks 2,000 ordered PCM blocks at each of 44.1 kHz / 256 frames and 48 kHz / 512 frames. At 48 kHz / 512 frames, The Binding of Isaac: Rebirth on an M6 had one catch-up in the first 6,000 renders, down from 1,227 on main, with zero underruns in the first 2,000 device callbacks on both builds.
Late audio producer wakeups despite fast rendering
- Symptom: constant static behind otherwise clean sound; the output settles near one queued block, with 12–38 underruns per 2,000 callbacks on speakers and up to 275 on AirPods, although rendering averages about 0.07 ms of each 5 ms block.
- Cause:
render_mainhad ordinary time-sharing policy. Its guest-thread startup already requests interactive QoS, and AudioOut already signals a host semaphore when a block is released, but neither declares the audio producer's real-time scheduling requirement. Aggregate performance-core usage in the report does not establish the render thread's core placement. - Fix: after output setup, the in-process renderer's worker requests
THREAD_TIME_CONSTRAINT_POLICYwith a 5 ms period/deadline and a requested 1 ms computation budget, and restores standard policy before teardown. A rejected request is logged and playback continues with its existing policy.DM_AUDREN_RT=0retains ordinary scheduling for A/B measurements. This is host-bound for every in-process renderer; the separate SDK 1audren:uworker and guest-created audio threads are unchanged. The 4.5 ms fresh-render spacing remains necessary for burst refills. - Found on: The Legend of Zelda: Ocarina of Time, issue #3059. Two reporters observed underruns. On an M4, macOS 27.0.1, nichq50 reported four queued blocks and zero underruns across 16,000 callbacks on speakers and AirPods after applying only the policy patch; the attached text file is the patch, not a post-fix log.
- Check:
t_audren_layoutsets, reads and resets a real pthread's Mach policy, checks setup/teardown scope, and verifies intact PCM with policy rejection and opt-out. Its cadence fixtures retain 2,000 ordered blocks without simulated underruns at 44.1 kHz / 256 frames and 48 kHz / 512 frames; these do not simulate OS wakeup delay. On an M6 with macOS 27.2.1, XNU raised the requested 1 ms computation to 2.5 ms (half the constraint), consistent with XNU's policy implementation. This is a budget, not CPU time consumed. - Live validation: Isaac's audio scheduling checks cover real 48 kHz USB output and 44.1 kHz built-in speakers on an M6, including the limits of its CPU/energy samples. Breath of the Wild's scheduling validation covers SDK 20 and isolates a screenshot-associated frame-time flag with a matched policy-off/on comparison.
- Open: iOS device behavior and power impact, and power on the affected M4. The 44.1 kHz crackle reported in issue #2796 was independently reproduced on
Mac mini Speakers(M6, macOS 27.2.1): at 44.1 kHz (221-frame callbacks periodically releasing two blocks),79f28b06's 4.5 ms pace wait overshot under non-RT scheduling (DM_AUDREN_RT=0: 322 underruns in a 5 s matrix, 1,183–1,255 per 2,000 callbacks in Ocarina of Time), while2edad182(DM_AUDREN_RT=1) reduced both to 0 underruns and 4.0 queued blocks; confirmation on the reporter's MacBook speakers at 44.1 kHz remains open.