fix(audio): HOS_AUDIO_MUTE silences the samples, not the device's volume #3225
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3225
Loading…
Reference in a new issue
No description provided.
Delete branch "ChloeNow/Longshot:fix/audio-mute-samples"
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?
Summary
The bug: once you have run the game tests on a build, every later normal launch of that same
longshot-game.exeplays no sound. The log of the silent launch still shows real output(
audio: ... loudest sample 9007 of 32767): nothing in the game says why.The cause:
HOS_AUDIO_MUTE=1is set by every game-test run (modtool'sgame_test.rs,scripts/devtools/gametests.py,scripts/devtools/ab.py).host/nn_audio.c'sau_opened()muted the run withwaveOutSetVolume(w, 0)(783c43100). Windows keeps that volume as the program's audio session volume and gives itback at the program's next start, so the mute meant for one test run stayed on every later launch of the exe (measured
below: the session volume of main's game-tested build is 0.00 on a normal launch).
How to see it on main (reproduced 2026-12-04 on Windows 11, RTX 4060 Laptop, a build of main's
nn_audio.c):dev.py game-tests <mod> --runtime <that game folder>on it (its log lists the switchHOS_AUDIO_MUTE=1).HOS_AUDIOswitch in its log): no sound, though its log reports anon-zero loudest sample.
The fix:
HOS_AUDIO_MUTE=1keeps the device opened and fed as for a player, andoutput_framewrites silenceinto the blocks it hands the device instead of the game's frame. The device's volume is never set anywhere, so a
normal launch keeps the player's own volume; nothing forces it to full.
HOS_AUDIO_DUMPand the log'sloudest samplestill hold what the game sent, as before, so a test run can still check that the game made sound.au_opened()is gone (setting the volume was all it did). The mute now also works on Linux, where the old call wasWindows-only.
A build already silenced stays silent after this fix until one launch sets its waveOut volume back to full
(
waveOutSetVolume(w, 0xFFFFFFFF)): this change stops making new silent builds but does not reset an exe's storedvolume, since doing that on every normal launch would override the player's own setting. Windows keeps the volume per
exe path: a fresh game folder starts at full volume, while a game folder rebuilt in place (
dev.py update,dev.py game) most likely keeps its 0 (not tested). If reviewers want those healed too, a test run could set the volume tofull when it opens the device (still silent, since it feeds silence); it is left out here so that no launch changes
the volume at all.
Read first:
host/nn_audio.coutput_frame(the block write),tests/audio_output_errors_test.c(themutecase).Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU. Built and run on
main@f359e2621plus this change;rebased onto
3a0f7d8f7(one commit, no audio file), where the three audio output and volume checks pass again.tests/test_audio_output_errors.py(the real output section compiled with device spies) gets amutecase:with
HOS_AUDIO_MUTE=1the device opens once, is fed 20 blocks over 40 frames as in thenormalcase, every blockit is given is silent, and the 10-second log line still reports a non-zero loudest sample. Fails on main @
f359e2621with the test commit alone (FAIL mute: blocks[b][i] == 0: the blocks carry the game's samples), passeshere. With the fix's
memsetline undone it fails again. All 32 cases pass with clang (llvm-mingw);mutewithllvm-mingw's gcc driver too.
tests/test_audio_output_devices.py: its order check (the channel guard before the copy into the blocks) now findsthe block write by its new text; passes.
host/nn_audio.c(audio_aux, biquad, deadline, in, mono, output_menu,output_recovery, speaker_layout, voice_biquad, volume, wave_buffer_release, hle_guest_ranges, host_guest_writes,
microphone_test_gain, pad_speaker, pause_background) pass.
test_pipeline_tour.pyfails the same way on a cleanorigin/maintree (the tour's run is not given --vk-profile): not this change.dev.py game, shaders prepared withlongshot-builder dev prepare), the bug'ssteps 2 and 3:
dev.py game-tests docs/modding/examples/first-mod, kokiri-start, headless): its log listsHOS_AUDIO_MUTE=1; the device opened as a player's (audio: output on the default device (3 devices), stereo) andwas fed (
1000 blocks played in the first 10 s). (That example's tests are fake-game ones and error in the realgame,
FakeOnlyError, as they do on main: the run served only as a muted test run.)longshot-game.exe(longshot_ctl.py launch, windowed, through the queue): noHOS_AUDIOswitch in its log;audio: output on the default device (3 devices), stereo,1000 blocks played in the first 10 s, loudest sample 255 of 32767.Windows' audio session of
longshot-gameread every second through Core Audio:ISimpleAudioVolume,IChannelAudioVolume, the session's peak meter):meter up to 0.145. Sound, heard.
longshot-rs-2783-play, game-tested before): session volume 0.00, channel volumes0.00 0.00 throughout, though the game played (meter up to 0.211, which is measured before the session's
volume; its log:
1001 blocks played in the first 10 s, loudest sample 10201). No sound, heard.Still to test:
dev.py game-testsrun with speakers on, expecting silence (the mute now worksthere too; before,
au_openedmuted only on Windows), then a normal launch of the same build, expecting sound.Measurements
Verdict: fixed: after a game-test run, a normal launch is at full volume and audible (main: volume 0, silent).
No performance cost to measure: one
memsetin place of onememcpyper frame, only in test runs; a player's frame iscopied as before.
Setup: Windows 11, RTX 4060 Laptop; one game-test run on each build, then one normal windowed launch of the same exe
from kokiri-start, ~45 s; Windows' audio session for
longshot-gameread every second through Core Audio(
ISimpleAudioVolume,IChannelAudioVolume). The "before" build is a local build on main @46ae5b43dwhosehost/nn_audio.cis main's (no diff tof359e2621). The numbers hold on main @3a0f7d8f7, this PR's base: no commitbetween
46ae5b43dand it changeshost/nn_audio.cor the game tests' switches.46ae5b43d6cc9ec01fafter the rebase)Risks
Only runs with
HOS_AUDIO_MUTE=1change (test runs,ab.py). They still open and feed the device and log the samelines; what the speakers get is silence instead of sound at volume 0. A revert is enough. Players notice nothing,
except that a build stops going silent after a test run on it. Builds silenced before this change need one launch that
sets the waveOut volume back to full (see Summary). #3116 (the sound out of the game's process, WIP) moves this output
code; whichever lands second keeps the mute in the samples.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (Windows,tests/run_all.py: 16 checksfail identically on
main@f359e2621and here, none audio: test_dlssg, test_game_features, test_helpers_extract,test_longshot_builder, test_no_game_title, test_no_map_reload, test_present_acquire_ahead,
test_present_geometry_trace, test_present_held_image, test_present_image_free, test_run_all_junit, test_seed_reader,
test_sync_watch_event, test_turf_budget, test_ui_renderer, test_utf8_paths. Everything else passes.)
main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.dev.py gamebuilt it, llvm-mingw. Linux: no Linux PC here; CI's game-free checks compile and run the changed output section on Linux with-Werror(test_audio_output_errors, test_linux_audio_output): ticked once they pass)docs/dev/reference/switches.md,HOS_AUDIO_MUTE; the switch list at the top ofnn_audio.c).Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU. This branch's game folder: a dev.py game-tests run (HOS_AUDIO_MUTE=1 in its log; the device opened and fed, 1000 blocks in the first 10 s), then a normal windowed launch of the same longshot-game.exe from kokiri-start: Windows' audio session for it at volume 1.00 (channels 1.00 1.00) throughout, the game's sound heard. main's game-tested build launched the same way: session volume 0.00 (channels 0.00 0.00), nothing heard, though its log reports a loudest sample of 10201.
@review
Recommendation: Approve. The code is ready: only testing is left. The Windows test shows that a game-test run no longer silences the next launch. Linux playback still needs an in-game check, and the pull request remains WIP with CI running. Recommend approval; not approved on the forge.
The mute switch now feeds silent samples to the output device instead of changing its persistent Windows volume. The game’s samples remain available to the dump and diagnostic log; builds already silenced by an earlier test run remain silent.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
host/nn_audio.c:1319: The new Linux mute behavior has not yet been checked with a real output device. (more on the line) Do: On Linux, run a game test with speakers enabled, then launch the same build normally and check that the first run is silent and the second has sound.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Windows setup: after a game-test run, the reported session volume was 1.00 and sound was heard, versus 0.00 and silence on main. The author reports that the game-free mute test fails with the key memset undone. Linux behavior remains unverified in game.
Other systems: The changed output path runs on Windows and Linux, including stereo and 5.1 output and device recovery. The synthetic output test covers device behavior on the reported Windows run; a Linux in-game run is still needed. Controller-speaker output has a separate path. Previously silenced Windows builds are not healed by this change.
Switches: HOS_AUDIO_MUTE remains off by default. When enabled, it now sends silent samples instead of setting the Windows device volume, and also mutes the main output on Linux. The switch reference and source comment are updated; leaving normal launches at the player’s existing volume is appropriate.
Reviewed:
6cc9ec01faagainst3a0f7d8f7f: Read the repository rules, pull request template, diff, commits, changed output code and its mixer and device paths, and the changed test fixture and runner. Skimmed the rest of the large audio source, switch reference and standards; Tooling’s adjacent AGENTS.md and docs/review-checklist.md were unavailable. No generated files or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during review. The author reports Windows game and game-free checks; the listed CI checks are still running.
Overlaps and merge order: The description identifies WIP pull request #3116 as moving this output code; whichever merges second must preserve the sample mute.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -1323,0 +1316,4 @@say what the game sent. tests/test_audio_output_errors.py */static int mute = -1;if (mute < 0) mute = env_on("HOS_AUDIO_MUTE");int16_t *block = blocks[fill_block] + fill_frames * FRAME * out_channels;L1 (should fix): The new Linux mute behavior has not yet been checked with a real output device.
When: On Linux, a game-test run now sends zeroed samples through SDL; the reported checks use device spies and do not show whether an actual device stays silent and a subsequent normal launch is audible.
Do: On Linux, run a game test with speakers enabled, then launch the same build normally and check that the first run is silent and the second has sound.
WIP: fix(audio): HOS_AUDIO_MUTE silences the samples, not the device's volumeto fix(audio): HOS_AUDIO_MUTE silences the samples, not the device's volume