fix(audio): Auto counts 5.1 speakers, not channels #1167
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1167
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:fix/audio-auto-speakers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: fix · Risk: low · Tested on: Linux, RTX 4070 Ti (game-free checks) · Needs: Windows, an audio interface or a 5.1 system
Why
On Windows with Speaker layout on Auto, an audio interface such as a Focusrite Scarlett (8 outputs, no speakers named) was counted as 5.1, so voices, the ocarina and Link's own sounds went to outputs with nothing connected and were silent.
Restored from Hookshot 3044, by David B, and split out of #286 so it can be reviewed and merged on its own.
How to reproduce
Seen on: Windows, a Focusrite Scarlett 18i8 as the default output (reported on Hookshot)
Settings and switches: Speaker layout: Auto
Steps: play the ocarina or watch a cutscene with voices
Expected: every sound plays
Actual: voices, the ocarina and Link's sounds are silent
What changed
au_device_channelsinhost/nn_audio.creads the mix format's channel mask through a newau_layout_channels: a device is 5.1 only when its mask names a centre and a pair behind or beside the player, else stereo. Stereo, 5.1, Mono andHOS_AUDIO_CHANNELSwork as before; Linux is unchanged (SDL gives only a count).Commits, each with its original author and message:
e11c1945fix(audio): Auto counts 5.1 speakers, not channels (David B)Fixes https://github.com/NotRexed/Hookshot/issues/2182 (one of the reports collected in https://github.com/NotRexed/Hookshot/pull/2503).
With Audio output on Auto, Hookshot told the game 5.1 whenever the
default output device had 6 or more channels. An audio interface
reports all of its outputs as channels without naming them as speakers.
A Focusrite Scarlett 18i8, for example, has 8 channels and a channel
mask of
0. The game then mixed for 5.1, and everything it puts in thecentre or behind the player went to outputs with nothing connected. That
includes voices (Saria in the ocarina cutscene), the ocarina and Link's
own sounds. Those sounds were silent while the rest of the game played
normally.
The readme already says Auto follows the device's speakers. The code
counted channels.
host/nn_audio.c:au_device_channelsnow reads the mix format'schannel mask through a new
au_layout_channels. A device counts as 5.1only when its mask names a centre and a pair of speakers behind or
beside the player (5.1 back, 5.1 side, 7.1). Everything else is stereo:
mask
0, no mask, quad, or 5.1 without a centre. The log says why, forexample:
audio: the default output has 8 channels but not 5.1 speakers (channel mask 0): counted as stereo. As stereo, the game's own downmixkeeps every sound.
The Stereo and 5.1 menu choices and
HOS_AUDIO_CHANNELSwork asbefore. Real 5.1 and 7.1 systems still get 5.1.
Linux is unchanged: SDL2 reports only a channel count, not speaker
positions.
readme.md: one sentence on what Auto counts.New game-free check,
tests/test_audio_speaker_layout.py. It compilesthe real
au_layout_channelsand tests it against 13 mix formats(stereo, mono, 5.1 back and side, 7.1, 7.1 wide, interfaces with mask 0,
quad, 5.1 without a centre, formats with no mask). It also checks that
au_device_channelsgoes through the new function. It passes locallywith MSVC;
run_all.pypasses{cxx}on CI.The changed
au_device_channelswas compiled on its own and run onthe reporting PC (Windows 11, Scarlett 18i8 as the default output, RTX
3080). It reads the live mix format (8 channels, mask
0) and returnschange, choosing Stereo in the menu works around the problem.
Co-authored-by: Claude Opus 5.5 [email protected]
Restored-from: https://github.com/NotRexed/Hookshot/pull/3044
Measurements
Verdict: nothing to measure: a correctness fix off the frame path, covered by game-free checks.
Flags and settings
None.
Testing
Tested: On Linux (kernel 7.0), RTX 4070 Ti,
main@71b1edd8, this PR @e11c1945:tests/test_audio_speaker_layout.py,tests/test_audio_output_menu.py,tests/test_audio_mono.py,tests/test_readme_menu_rows.pypass.tests/test_audio_output_devices.pyfails here onmaintoo (it looks forLONGSHOT_SHADER_STAMPin the build script). The full suite (tests/run_all.py) has not been run on this branch yet; a comment will follow when it has.Not tested: The game on Windows with an audio interface or a 5.1 system (I am on Linux). Opened as work in progress until it runs in the game.
Must be tested:
Risks
What could break: Auto's speaker count on Windows.
Turning it off: revert the commit.
Compatibility: A player on Auto with an audio interface hears stereo instead of 5.1, which is the fix; nothing else changes.
Checklist
Everyone
type(scope): description) of the status line's type.main.third_party/untouched (a new folder with aPROVENANCE.mdinstead).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).When it applies
mainand passing here.Assisted-by:/Co-Authored-By:trailers.Tested in game: Linux (Ubuntu 26.04.1, kernel 7.0.0-43), RTX 4070 Ti 12 GB, NVIDIA 595.99.02, Ryzen 7 9800X3D: this branch built together with the other 18 split from #218 and #284-#288, merged onto main @
71b1edd8(make_game.py --update, build v3.0.0-rc.5-82-g5952bb3d), then played by a scripted tour through the control bridge (scripts/memtour.py: a save loaded, Zora's Domain, the Market, Hyrule Field and Death Mountain Trail, 40 s each with walking and camera swings). All 4 stops reached, a clean quit, and no device loss or Vulkan error in the log. Auto chose stereo for this PC's 2-channel output (log: "audio: stereo for the game (the selected/default output has 2 channels)"). A 5.1 output was not available here.Possibly related, for context:
WIP: fix(audio): Auto counts 5.1 speakers, not channelsto fix(audio): Auto counts 5.1 speakers, not channels