feat(audio): the game's sounds on a DualSense's own speaker and headphones #1545
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1545
Loading…
Reference in a new issue
No description provided.
Delete branch "duducs9/Longshot:feat/controller-speaker"
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
On the console, Navi, the menus and other close sounds come out of the controller, and headphones in it take all the
sound. On PC a DualSense's own speaker and its headphone jack stayed unused. This PR plays chosen kinds of the game's
sounds on the controller's speaker, from a Controller speaker page under Audio (Navi's voice and her flight,
Z-targeting, the ocarina, pick-ups, items, fairies, the menus, the Stone of Agony, the low-health alarm, fishing and
bottles, each Off, Controller only or Controller + TV), with a volume, a sync between the controller and the TV, and
headphones in the controller's jack taking the whole game as on the console.
Read first:
host/pad_speaker.c: the controller's output report (speaker or headphones), the ring that follows the pad's clock, thespeaker's high-pass and limiter, headphone detection. The speaker's two channels ride on the vibration's stream from #405
(
host/rumble_renhdrum.cusb_pullcallshos_pad_speaker_fill) while it plays the pad, so the pad's sound card has onestream; otherwise the speaker opens its own through
hos_sdl_audio_open. Thehos_sdlaudio-endpoint functions werereused from #405, by Stellarznith.
host/audio_source.c,.h: the game's sounds classed by the archive and asset a wave buffer plays from, read asynchronously from theplayer's own sound archives at the start. Nothing of the game is in the source or the build.
host/nn_audio.c: the classed sounds to the pad, left out of the TV's mix for Controller only; a Controller sync below 0holds only the TV's copy of the Controller + TV sounds back (a delay line per mix); the whole mix to the headphones.
host/pad_sdl.c: the Vibration strength at half on the speaker's controller while an ocarina sound plays there (the motors shook it intocrackling).
gpu/vk/menu/controller_speaker.cpp: the page as a menu module (HOS_OPT_PAD_SPEAKER_*140 to 155), itspad_speaker_*keys, the texts in all 13 languages (
menu_i18n.h).See #405, #752 (the request for RenHD Rumble on a DualSense, which that endpoint serves) and #1433 (binaural 3D headphone
audio: this PR routes the game's sound to the DualSense's jack, without HRTF processing).
Testing
Tested: Windows 10 Pro 19045, RX 7800 XT (driver 26.10.1), RenHDrum 0.5, in play on
5d8a060e(this branch beforeits rebases onto
main(now @8aa74983), which only mergesmainand moves the speaker's option numbers): a DualSense on aplain USB cable (Navi and the ocarina on its speaker; HD Haptics' taps with them; Mute in background silences the
controller too on alt-tab; headphones in its jack take the whole game and give the speaker back when pulled), and the
same through a Raspberry Pi Pico 2 W running DS5Dongle v0.8.0 (https://github.com/awalol/DS5Dongle, by awalol), which
exposes the controller's speaker and microphone over USB. Earlier heads, in play on the same PC: through the dongle,
the Controller speaker page, Navi, targeting, items, the ocarina and the menus from the controller as chosen,
headphones in its jack, and the voice coils and the speaker on one stream with RenHDrum (0 under-runs, 0 trims, 20.0 ms
buffered on average); a wired DualSense with RenHDrum 0.5's HD Haptics on and off (Navi and the ocarina on the speaker
together with the taps, and alone with HD Haptics off).
Checks on
1e24c461(Windows): the speaker fixture (tests/test_pad_speaker.py: mixing with the taps, an unmatchedvibration endpoint not shared, route changes), Volume and Mute in background on the controller's sounds
(
tests/test_audio_volume.py), the jack reader with a reused SDL pointer (tests/test_pad_headphones_reader.py), thearchive fixture (
tests/test_audio_source_load.py, standard library only, non-ASCII path), the settings table and ruffpass.
tests/test_menu_i18n.py,test_menu_ini_keys.py,test_menu_keys.py,test_menu_modules.py,test_vibration_menu.pyandtest_renhdrum.pyfail the same way onmain@8aa74983(grass_distancenot frozen, afixture's undeclared names, a Graphics text no longer in the menu, RenHDrum's escaped opus version), and
scripts/check_guide_screenshots.py --review-sourcesreports the same 22 inputs there as here. On5d8a060e, of thechecks
tests/run_all.py --changedpicked, none failed only on the branch (each also failed onmain@9dd41326orpassed alone).
Still to test:
main(itsendpoint found by name) and the Controller speaker staying off, as nothing matches a pad to its endpoint there yet (by
hand)
Measurements
Verdict on
5d8a060e: no measurable cost in these measurements. Frame time, startup and memory are the same asmainwith no controller, and with awired DualSense with the speaker on (its stream shared with RenHDrum's voice coils) or off (
HOS_PAD_SPEAKER=0). The current head changes the audio routing and archive loading and has not been measured again.Setup: Windows 10 Pro 19045, RX 7800 XT (driver 26.10.1), 3440x1440 at 180 Hz; the title screen, untouched, 90 s a run
with
HOS_PROFILE=1;main@9dd41326against this PR @5d8a060e(its base then), the same game folder and settings,the shaders prepared before; runs interleaved, the builds checked by hash before each. Startup: the process's start to
the first frame in the profile's
frames.csv. Frame time: that file's last 60 s. Memory: the process's private bytes atthe end and its peak working set. No controller: 5 runs each (the median); a wired DualSense: 2 runs each (both).
9dd413265d8a060emainran first)mainran first)HOS_PAD_SPEAKER=0): startupThe title screen plays at the game's 60 fps cap in every case, so a frame-time cost below that cap would not show here;
the classed-sound path's cost in play is not measured. In the first three no-controller rounds the PR ran first and its
startup was about 0.3 s longer and its peak working set about 600 MB higher; in two more rounds with
mainfirst (thevalues in brackets) the two match, so that was the order, not the PR. The speaker-off runs compare with the same
mainruns as the speaker-on ones. Onemainrun (not the PR) crashed after 33 s while measuring (0xc0000005 in ntdll,a heap call from the host); it is recorded but not investigated here. The rebases changed no code these
runs exercise (main's changes and the speaker's option numbers). The later audio changes have not been measured again.
Switches and defaults
The settings' defaults were chosen by ear in the in-game test: the speaker's volume 100% (twice the mixer's level, for a
small speaker; 0 to 200%), the Controller sync 0 ms, headphones in the controller on All sound at 80%, and each kind of
sound Controller only or Controller + TV (
vk_menu.h,pad_speaker[12]). The switches (rows ingpu/vk/switches.def,docs/dev/reference/switches.md, "The controller speaker"):=0turning its part back for a run:HOS_AUDIO_SOURCE(the sounds classed from the player'sown sound archives),
HOS_PAD_SPEAKER(the endpoint opened while a kind of sound plays there),HOS_PAD_SPEAKER_HPF(a 250 Hz high-pass: bass the small speaker cannot play is left out),
HOS_PAD_SPEAKER_LIMITER(a look-ahead limiter: noclipping at 200%),
HOS_PAD_SPEAKER_LOW_LATENCY(a 20 ms buffer that follows the pad's clock: fewer crackles thanthe earlier 40 ms),
HOS_PAD_SPEAKER_TV_DELAY(a sync below 0 holds the TV's copy back).HOS_PAD_SPEAKER_GAIN4 (the pad's preamp: louder withoutdistortion),
HOS_PAD_SPEAKER_BUFFER_MS20,HOS_PAD_SPEAKER_OCARINA_RUMBLE50 (the motors shook the speaker intocrackling during the ocarina),
HOS_PAD_SPEAKER_PATH3 (the speaker alone).HOS_AUDIO_SOURCE_TRACE,HOS_PAD_SPEAKER_TEST,HOS_PAD_SPEAKER_HEADPHONES(unset: what the pad's input report says).
HOS_PAD_SPEAKER_VOLUME,HOS_PAD_SPEAKER_HEADPHONE_MODE,HOS_PAD_SPEAKER_NAVI_VOICE,HOS_PAD_SPEAKER_NAVI_SOUND,HOS_PAD_SPEAKER_TARGET,HOS_PAD_SPEAKER_OCARINA,HOS_PAD_SPEAKER_PICKUP,HOS_PAD_SPEAKER_ITEM,HOS_PAD_SPEAKER_FAIRY,HOS_PAD_SPEAKER_UI,HOS_PAD_SPEAKER_AGONY,HOS_PAD_SPEAKER_LOW_HEALTH,HOS_PAD_SPEAKER_FISHING,HOS_PAD_SPEAKER_BOTTLE.Risks
With the controller's endpoint open, a Controller only sound leaves the TV's mix and headphones in the controller silence
the TV (both by design, and logged). The controller's sounds follow Volume and Mute in background, as the TV's. A pad that
says headphones are in when they are not would silence the TV:
HOS_PAD_SPEAKER_HEADPHONES=0overrides it. The wiredvibration finds its endpoint by name as on
main; only the speaker's sharing of that stream needs the endpoint matched tothe pad (Windows, by device container), checked again at every reopen.
HOS_PAD_SPEAKER=0leaves the controller alone, and each part has its own switch(
docs/dev/reference/switches.md, "The controller speaker"); or revert. After updating,longshot_options.inigains thepad_speaker_*keys; saves and caches are unchanged.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.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 10 Pro 19045, RX 7800 XT, DualSense through a Raspberry Pi Pico 2 W running DS5Dongle v0.8.0: played with Navi, Z-targeting, items, the ocarina and the menus on the controller's speaker (HOS_AUDIO_SOURCE_TRACE=1: 932 sounds classed from 40 archives; pad speaker: 0 under-runs, 0 trims), no crackle on bombs and ocarina notes, the Controller sync lining the TV up, and headphones in the controller taking all the sound with the TV silent.
Possibly related, for context:
Full
tests/run_all.pyon this PC (Windows 10, llvm-mingw on PATH): this branch 596 passed, 129 failed, 46 skipped; main @4b68c42b584 passed, 138 failed, 46 skipped. Every test that failed here and not on main passed when run again alone (Windows held a test's temporary .exe: WinError 32), excepttest_linux_audio_output, which failed in that run and passes in the pushed commit (64424b37: the pad's endpoint calls moved out of the sound section it compiles). These fail on main too, on this PC:test_audio_in,test_auto_handheld,test_auto_settings,test_bug_report,test_bug_report_defaults,test_commit_room,test_compute_pin,test_compute_warm_apart,test_cpu_report,test_crash_dialog,test_crash_dump_policy,test_crt_options,test_damage_debug_menu,test_dev_packs,test_display_startup_failure,test_dlss_feature_size,test_draw_binds,test_draw_stream_visibility,test_failed_compile_keeps_objects,test_frame_overlap,test_fsr_image_retirement,test_fsr_uniform_ownership,test_fullscreen_monitor_platform,test_guest_imported,test_hd_rumble,test_hud_layout_row,test_import_reach,test_invalidate_quick,test_invalidate_vcore,test_job_queue,test_libc_hooks,test_linux_preflight,test_linux_pressure,test_lower_tld_ms,test_memory_priority,test_mirror_budget,test_mirror_inherit,test_missing_nup,test_oot_shadow,test_pads_after_menu,test_parallel_init_order,test_pending_guest_import,test_pipeline_play_cache,test_portable_builder_home,test_portable_builder_startup,test_prepare_workers,test_present_aspect,test_present_thread,test_profiling_mode,test_psychov35_fsr3_fg,test_psychov35_off,test_reactive_mask,test_readback_timeout_source,test_recorder_sync,test_reflex_swapchain_lifetime,test_replay_write_order,test_rumble_mapping,test_run_all_changed,test_run_all_junit,test_sdiv_overflow,test_seed_cs_pointers,test_seed_kept_loaded,test_shadow_mask_guard,test_share_message_i18n,test_slow_frames,test_sparse_bind_failure,test_sparse_spare,test_staging_burst,test_switch_table,test_target_image_pool,test_task_mesh_fallback_devices,test_tested_configurations,test_ub_gap,test_upscaler_rows,test_utf8_paths,test_vcore_escape,test_vk_occlusion_queries,test_walk_keyWIP: feat(audio): the game's sounds on a DualSense's own speaker and headphonesto feat(audio): the game's sounds on a DualSense's own speaker and headphones64424b37ed265079da35Rebased onto main @
10de79fb(57 new commits) and pushed as 265079da. Two conflicts, both small:nx2/build.py'sZSTD_HOST(both sides added a file: both kept,oot_heart_containers.clast, astests/test_heart_containers.pyreads it) andhost/nn_audio.c'sAppendWaveBuffer(main now hands the command the checked wave buffer: kept, the sound's class added on it). The option numbers 100 to 115 are still free.Description: Why now links #405 (the
hos_sdlaudio-endpoint functions were reused from it, by Stellarznith), #752 and #1433.Checks, as
mise.tomldefines them (mise is not installed on this PC, so each task's own command was run with Python 3.14 and llvm-mingw):mise run ci:smoke(python -I -B tests/test_run_all_junit.py):Ran 6 tests ... OK.mise run test(python -I -B tests/run_all.py --strict), on 020d2c68:610 passed, 164 failed, 49 skipped in 775 s. 85 of the failures were not in the earlier main run; run again one at a time, 72 passed (Windows holding a test's temporary .exe: WinError 32). Of the 13 left, 11 fail on main @10de79fbtoo (test_alt_enter,test_capture_read_once,test_capture_readback_visibility,test_fsr3fi_hudless_colour,test_game_menu_mouse_buttons,test_host_guest_writes,test_hud_layout,test_prepare_cache_save,test_present_source_crop,test_song_note_cue,test_vertex_bind),test_nvn_tex_builder_guardpasses when run again, andtest_heart_containerswas this branch's (theZSTD_HOSTorder): fixed in 265079da, it passes now.mise run lint: not run yet: it needs pre-commit and actionlint, which are not on this PC. It follows in a comment once they are.User-guide screenshot review (
python -I -B scripts/check_guide_screenshots.py --review-sources):Guide screenshot check failed: 23 issue(s), all forsettings-graphics.png, and main @10de79fbgives the same 23, none from this PR's files alone (gpu/vk/device_policy.h,vk_dlss.h,vk_vendor.hmissing, the fixturescripts/screenshots/menu.cpp, and others). This PR changes the Audio tab's Controller speaker page, not the Graphics tab the image shows. The review's recapture (scripts/screenshots/capture_menu.py) needs Linux, which this PC does not have, so the manifest is left as it is: refreshing its hashes without a capture is what the guide's README says not to do.265079da35c3ee73ab51Main moved 4 more commits while this was posted; rebased again onto main @
10fab152and pushed asc3ee73ab. One trivial conflict: tests/crash_record_test.c, where main and this branch each added a stub at the same place (both kept). Rechecked: the 15 checks this PR touches pass (test_pad_speaker, test_audio_source, test_audio_source_load, test_heart_containers, test_crash_record, test_windows_stop, test_menu_i18n, test_option_ids, test_menu_keys, test_readme_menu_rows, test_linux_audio_output, test_sdl_pad_diagnostics, test_audio_biquad, test_audio_wave_buffer_release), and the changed host files compile (llvm-mingw, syntax). Mergeable again.miseis installed on this PC now (2026.11.9, withmise install's pinned tools), and the three tasks ran as asked, onc3ee73ab:mise run ci:smoke:Ran 6 tests in 11.814sOK.mise run test:652 passed, 124 failed, 49 skipped in 808 s (windows, 16 at once). 55 of the failures were not in main's run; run again one at a time with mise's Python, 46 passed (Windows' temporary-file lock), and the other 9 fail on main @10de79fbtoo:test_capture_read_once,test_capture_readback_visibility,test_fsr3fi_hudless_colour,test_game_menu_mouse_buttons,test_host_guest_writes,test_prepare_cache_save,test_present_source_crop,test_song_note_cue,test_vertex_bind. The rest also fail on main on this PC (the list in the earlier comment).mise run lint: every pre-commit hook passes (check yaml and json: no files; end of files, trailing whitespace, gitleaks: Passed; ShellCheck: no files). actionlint then reports one finding, in a file this PR does not change, so main has it too:mooki referenced this pull request2026-11-19 02:05:59 +00:00
mooki referenced this pull request2026-11-19 02:34:02 +00:00
c3ee73ab51814c8db200Rebased onto current
main(@702a57a4), as one commit. Main had reworked three things this PR touched, so it is ported rather than replayed:hos_sdlaudio-endpoint functions (credit Stellarznith). While RenHDrum plays the pad's voice coils, the speaker's two channels ride on that same stream (host/rumble_renhdrum.cusb_pullcallshos_pad_speaker_fill), so the pad's sound card has one stream; when the vibration is off the speaker opens its own. The ocarina's half strength goes through main's Vibration strength.gpu/vk/menu/controller_speaker.cpp, with the samepad_speaker_*keys and the texts in all 13 languages;vk_menu.cppgets the page's tab (Back returns to Audio).docs/dev/reference/switches.md("The controller speaker"), the player's rows indocs/user/graphics-and-controls.md, and the description in the short template.Tested in play on Windows with a DualSense through DS5Dongle: the page, the speaker, headphones, and the voice coils together with the speaker on one stream (log lines in Testing). The checks' results are in Testing: no failure comes from this PR.
814c8db200e76e344e6a@review
Recommendation: Request changes. Queued sounds can be routed using the wrong sound’s settings, and a rejected controller output report can leave sounds missing from the TV. The change also adds unmeasured work for players without a usable controller speaker.
The feature routes selected sounds to a DualSense speaker and the full mix to its headphone jack. The reported dongle run demonstrates the feature in that setup, but the buffer classification and output-report failure paths need fixes, the ring counters need safe wraparound, and the cost on ordinary setups needs measurement.
Does it help: Unproven overall. The author reports successful speaker and headphone playback on Windows through DS5Dongle, but provides no before/after frame-time, startup-time or memory measurements. The code reads and decompresses archives and classifies wave buffers even without an available speaker.
Other systems: Linux and Steam Deck behavior, plain USB on Windows, other Tier 1 hardware, multiple controllers, rejected output reports and long sessions remain unverified. RenHDrum shares the endpoint and changes the output-report path; the author reports it working with the dongle. The renderer interface itself was not extended.
Switches: The PR adds HOS_AUDIO_SOURCE and HOS_PAD_SPEAKER feature kill switches, HPF, limiter, low-latency and TV-delay switches, gain 4, buffer 20 ms, ocarina rumble 50%, path 3, diagnostic trace/test/headphone overrides, and per-run menu overrides. Their rows and documentation are present, but the defaults were chosen by ear on one setup and are not supported by the measurements required by the project’s switch rules. The menu defaults are volume 100%, sync 0, headphones All sound at 80%, and class-dependent Controller only or Controller + TV.
Reviewed:
e76e344e6aagainsta104182b40: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the commit and diff statistics, controller_speaker.cpp, audio_source.c and audio_source.h. Read the changed audio, SDL, rumble, menu, build and interface hunks and relevant mixer queue and endpoint code; skimmed the switch tables and test coverage. I did not read every changed code file or test in full, nor all translations. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Suggestions (the author may take or leave)
Testing: Read-only review; no code, scripts, builds or tests were run. The author reports six smoke checks passing on head, with parallel test failures attributed to Windows file locks or reproduced on main; plain USB and Linux runs are still outstanding.
Overlaps and merge order: The description identifies #405 as the merged RenHDrum endpoint dependency and #1433 as related headphone processing. No open-PR overlap search was possible in the closed network.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -1303,6 +1417,7 @@ static void apply(const Cmd *k) { /* (with the lock held) */break;case OP_VOICE_APPEND:if (v->pending_wb > 0) v->pending_wb--;if (k->i0 >= 0) v->source = k->i0; /* (an asset's start; a buffer that continues a streamed one keeps its class) */Could the class travel with the queued buffer and become active when that buffer starts? If two different assets are queued on one voice, appending the second currently changes the routing of the first, potentially removing the wrong sound from the TV.
@ -1505,6 +1624,7 @@ HLE(_ZN2nn5audio17OpenAudioRendererEPNS0_19AudioRendererHandleEPNS_2os11SystemEvhos_system_event_init(renderer_event, 1);au_lock();au_unlock();hos_audio_source_load();This loads and decompresses the sound archives even without a usable controller speaker, and buffer appends also scan for headers. Please avoid or defer that work where possible and measure startup and frame-time cost against the base, including a no-controller setup.
@ -0,0 +223,4 @@float *f = ring[(unsigned)(w + i) & (RING - 1)];f[0] = f[1] = shape_sample(mono[i] * scale);}InterlockedExchange(&ring_w, w + frames);These signed free-running counters overflow after about 12.4 hours at 48 kHz. Please use unsigned wrap-safe arithmetic for both counters and their differences, with a test crossing the wrap boundary.
@ -0,0 +422,4 @@stream = own, stream_pad = pad;InterlockedExchange(&riding, own == NULL);InterlockedExchange(&route_all, all_route());pad_route(pad, to), stream_to = to;Please handle a rejected output report before marking this route active. An endpoint can open while the pad or bridge rejects the report; Controller-only sounds are then removed from the TV even though the requested speaker route was not established.
@fix
I changed this pull request where the review's points could be done here: the new head is
40d7234735.Changed
Left for the author
a104182b40, including a no-controller setup; measurements require running the game.a104182b40, including without a controller, because the game cannot be run here.Nothing was built or run: check the change. It will be reviewed again.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@rebase
Recommendation: Request changes. The checked-out head still has the defects identified in the previous review, and controller selection can overlook a usable wired DualSense. The reported fix commit is not available in this checkout, so its changes cannot be verified.
The feature sends selected game sounds to a DualSense speaker and can route the full mix to its headphone jack. The reported dongle test shows it working on one Windows setup, but the current head has unresolved routing and long-session defects, and adds unmeasured work to ordinary setups.
Does it help: Unproven overall. The author reports successful speaker, headphone and shared vibration playback through DS5Dongle, but provides no base-versus-PR startup, frame-time or memory measurements. Plain USB and Linux runs remain outstanding.
Other systems: Linux, Steam Deck, plain USB on Windows, multiple controllers and other Tier 1 hardware remain unverified. RenHDrum shares the endpoint; the reported dongle run covers that combination. With multiple DualSense controllers, selection can miss a usable wired pad or pair a pad with another pad's endpoint.
Switches: The PR adds HOS_AUDIO_SOURCE and HOS_PAD_SPEAKER controls, HPF, limiter, low-latency and TV-delay controls, gain 4, buffer 20 ms, ocarina rumble 50%, path 3, diagnostic trace, test and headphone overrides, and per-run menu overrides. Feature processing defaults on; diagnostics default off. The menu defaults to volume 100%, sync 0 ms, headphones All sound at 80%, and class-dependent Controller only or Controller + TV. Rows and documentation are present, but one setup's listening test does not establish the defaults across supported setups or measure their costs.
Reviewed:
e76e344e6aagainsta104182b40: This is a re-review ofe76e344e6aagainsta104182b40, the same head as review 1899. The comment claims fixes at40d7234735, but that object is unavailable locally; none of those fixes can be assessed. Read AGENTS.md, CONTRIBUTING.md, the PR template, the commit, audio routing and controller-selection changes. Skimmed other menu, build and interface hunks; did not read every changed code file or test in full, all translations, or all generated material. docs/review-checklist.md and the adjacent Tooling checkout are absent.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Questions
Testing: No code, scripts, builds or tests were run. The author's recorded Windows results were considered; the requested plain USB and Linux tests have not been reported.
Overlaps and merge order: The PR identifies #405 for the shared vibration endpoint and #1433 for related headphone audio. No duplicate was established from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -498,0 +500,4 @@void *dualsense = NULL;for (int i = 0; i < MAX_PADS && !dualsense; i++) {const char *name = pads[i].gc ? hos_sdl_pad_name(pads[i].gc) : NULL;if (name && pads[i].vendor == 0x054c && (strstr(name, "DualSense") || strstr(name, "PS5"))) dualsense = pads[i].gc;Could selection prefer an eligible wired DualSense? If a Bluetooth DualSense occupies an earlier slot, this stops there and never tries the wired pad, so its speaker remains unused.
@ -0,0 +371,4 @@const int n = hos_sdl_output_count();for (int i = 0; i < n; i++) {if (!hos_sdl_output_info(i, id, (int)sizeof id, name, (int)sizeof name)) continue;if (!strstr(name, "DualSense") && !strstr(name, "Wireless Controller")) continue;Could the endpoint be matched to the selected pad? With two DualSense controllers, the first matching endpoint can belong to the other pad, while the output report is sent to the selected one.
@fix
I changed this pull request where the review's points could be done here (the rest needs runs, measurements or decisions): the new head is
1b75d6dc60. I rebased it ontomain(3df5c13ed2).Conflicts resolved
Changed
Already done
40d7234735, and its fixes and focused tests are present.Left for the author
Nothing was built or run: check the change. It will be reviewed again.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
40d72347351b75d6dc60Recommendation: Request changes. Controller audio can fail for players whose game path contains characters outside the Windows system code page. The endpoint can also be paired with the wrong controller, and the feature’s runtime and loading costs remain unmeasured.
The feature routes selected sounds to a DualSense speaker and the full mix to its headphone jack. The reported dongle run shows it working on one Windows setup; the current head adds the previously reported queue, report-failure and counter fixes, and prefers a wired pad. The previously identified multiple-controller endpoint mismatch remains unresolved.
Does it help: Unproven overall. The author reports successful speaker, headphone and shared-vibration playback through DS5Dongle, but provides no base-versus-PR startup, frame-time or memory measurements. The latest fixes have not been run.
Other systems: Plain USB on Windows, Linux, Steam Deck, other affected Tier 1 hardware and two-controller operation remain unverified. The author reports the shared RenHDrum stream working through the dongle.
Switches: The PR adds HOS_AUDIO_SOURCE and HOS_PAD_SPEAKER, HPF, limiter, low-latency and TV-delay controls, all on by default; gain 4, buffer 20 ms, ocarina rumble 50% and path 3; diagnostic trace, test and headphone overrides; and per-run menu overrides. The menu defaults to volume 100%, sync 0 ms, headphones All sound at 80%, and class-dependent Controller only or Controller + TV. Rows and documentation are present, but listening on one setup and the missing cost measurements do not establish the defaults for supported setups.
Reviewed:
1b75d6dc60against3df5c13ed2: Re-review of1b75d6dcagainst3df5c13e: read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the commit list, audio_source.c and the main controller-speaker and mixer changes; inspected the endpoint, queue, SDL, vibration, menu, interface, build and relevant test hunks. Skimmed translations and recorded runs. I did not read every changed code file or test in full. docs/review-checklist.md and the adjacent Tooling checkout are absent.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Testing: No code, scripts, builds or tests were run. The author’s recorded Windows results were considered; the current head’s fixes, plain USB and Linux runs remain unverified.
Overlaps and merge order: The PR identifies #405 for the shared vibration endpoint and #1433 for related headphone audio. No duplicate was established from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -0,0 +111,4 @@char pattern[MAX_PATH], path[MAX_PATH], archive[MAX_PATH];snprintf(pattern, sizeof pattern, "%s/Sound/Resource/*.bars.zs", hos_romfs_dir);WIN32_FIND_DATAA fd;HANDLE find = FindFirstFileA(pattern, &fd);This uses a narrow Windows path for the UTF-8 RomFS directory; the fopen calls above do too. An install path outside the system code page can leave every sound unclassified even though the speaker opens. Please use UTF-8-safe directory and file APIs and cover a non-ASCII path.
@fix
I changed this pull request where the review's points could be done here (the rest needs runs, measurements or decisions): the new head is
ae2276df20.Changed
Already done
136f89efand1b75d6dc.Left for the author
3df5c13ewith an active speaker and with no controller, then reduce or move the work if its cost is material.Nothing was built or run: check the change. It will be reviewed again.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Recommendation: Request changes. The previously identified endpoint mismatch and unmeasured audio-loading and runtime costs remain unresolved. The UTF-8 archive-path fix is present, but has not been run.
The feature sends selected sounds to a DualSense speaker and can send the full mix to its headphone jack. The reported dongle run demonstrates it on one Windows setup; the gain is a new audio option, at the cost of added routing and mixing complexity and costs that have not yet been measured. Since review 1906, archive reads and enumeration use Windows wide APIs, with a non-ASCII path added to the fixture. The earlier endpoint-matching and measurement points remain open; they are not repeated as new comments.
Does it help: Unproven overall. The author reports successful speaker, headphone and shared vibration playback through DS5Dongle, with 0 underruns and 0 trims in the reported run. There are no base-versus-head frame-time, startup-time or memory numbers for the active and no-controller paths.
Other systems: Plain USB on Windows, Linux, Steam Deck and two-controller routing remain unverified. The shared RenHDrum stream worked in the reported dongle run. The endpoint selection still cannot reliably associate an audio endpoint with the selected controller.
Switches: HOS_AUDIO_SOURCE, HOS_PAD_SPEAKER, HPF, limiter, low latency and TV delay default on; gain defaults to 4, buffer to 20 ms, ocarina rumble to 50% and path to 3. Trace and test default off; the headphones override is unset. Volume, headphone mode and the twelve class overrides default to their menu settings. The menu defaults to volume 100%, sync 0 ms, headphones All sound at 80%, and class-dependent Controller only or Controller + TV. Rows and documentation are present; one listening setup and the missing cost measurements do not establish that these defaults are right across supported setups.
Reviewed:
ae2276df20against3df5c13ed2: Re-review ofae2276dfagainst3df5c13eand review 1906. Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, commit list, audio_source.c, the latest UTF-8 diff and its fixture changes; inspected the mixer, endpoint, routing, menu, interface, build and switch changes. Skimmed translations, tests and recorded runs. I did not read every changed code file or test in full. docs/review-checklist.md and ../Tooling/AGENTS.md are absent.; nothing run (a code review).Checked and fine:
Testing: No code, scripts, builds or tests were run. The author's recorded Windows results were considered; the latest fixes, plain USB and Linux runs remain unverified.
Overlaps and merge order: The PR identifies #405 for the shared vibration endpoint and #1433 for related headphone audio. No duplicate was established from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@fix
I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here).
Left for the author
Nothing was pushed.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@fix
I changed this pull request where the review's points could be done here (the rest needs runs, measurements or decisions): the new head is
bac384e567.Changed
Left for the author
Nothing was built or run: check the change. It will be reviewed again.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Recommendation: Request changes. The new Windows matching can still send audio and vibration to the wrong DualSense because the per-pad cache keeps a boolean while the endpoint token is shared. The change also disables wired RenHDrum on Linux and can play buffered headphone audio through the controller speaker after unplugging.
The feature adds per-sound DualSense speaker routing, full-game audio through the controller’s headphone jack, and a shared stream with RenHDrum. Since review 1913, the PR matches Windows devices by container and rejects ambiguous endpoint names. That improves the speaker’s direct lookup, but the cached vibration path can lose the association. The existing measurement request remains open.
Does it help: Unproven on
bac384e56. The earlier Windows 10 DS5Dongle run demonstrated speaker, headphone and shared vibration playback, with 0 underruns, 0 trims and 20.0 ms buffered on average. It predates the new matcher. There are no matched base-versus-head startup, frame-time or memory measurements with controller audio active and with no controller. Archive loading is now deferred, but the ordinary mixer still does per-sample routing work when the speaker is inactive.Other systems: The matcher changes the existing wired RenHDrum path even with HOS_PAD_SPEAKER=0. Linux and Steam Deck fall back from that path. Plain USB, DS5Dongle and two-controller operation need current-head Windows runs. The audio mixer changes also reach players using ordinary desktop output, including the 5.1 path. The renderer callback structs, save handling and cache formats are unchanged.
Switches: HOS_AUDIO_SOURCE, HOS_PAD_SPEAKER_HPF, HOS_PAD_SPEAKER_LIMITER, HOS_PAD_SPEAKER_LOW_LATENCY and HOS_PAD_SPEAKER_TV_DELAY default on. HOS_PAD_SPEAKER defaults to automatic, with 0 disabling and 1 forcing it. GAIN defaults to 4, BUFFER_MS to 20 ms or 40 ms with low latency off, OCARINA_RUMBLE to 50%, and PATH to 3. AUDIO_SOURCE_TRACE and PAD_SPEAKER_TEST default off, and PAD_SPEAKER_HEADPHONES defaults to detection. The volume, headphone-mode and twelve sound-class overrides default to the saved menu values. The menu defaults are speaker volume 100%, sync 0 ms, headphones All sound at 80%, and class routes {1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 1} in menu order, where 1 is Controller only and 2 is Controller + TV. The low-latency path also sets and clears the existing SDL_AUDIO_DEVICE_SAMPLE_FRAMES hint. The rows and docs are present. The listening run does not establish the defaults required by the switch rules, and the player overrides duplicate saved settings.
Reviewed:
bac384e567against3df5c13ed2: Reviewedbac384e567against3df5c13ed2and compared it with review 1913. Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, standards, commit messages, the archive reader and classifier, and the archive test sources. Inspected the speaker, SDL endpoint enumeration and open, pad selection, RenHDrum ownership, mixer, menu, build, shutdown and fixture changes with their relevant callers. Skimmed translations and recorded runs. Existing modified files and some fixtures were read in excerpts, without a full-file pass. The standalone review checklist and adjacent Tooling rules were absent.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
host/rumble_renhdrum.c:363The stream opens with the last globally looked-up token. If pad A finds its endpoint but fails to open, pad B can overwrite the token and later lose ownership. A can then retry using its cached positive result and open B’s endpoint. The speaker can ride that stream while its HID report goes to A. Cache the actual token per pad and pass it into the open call, or resolve it for that pad at open time. Cover failed open and ownership handoff with two pads.host/hos_sdl.c:726The non-Windows branch now rejects every endpoint for existing wired RenHDrum as well as for the new speaker. A Linux player whose four-channel endpoint was selectable on the base loses wired haptics even with controller speaker disabled. Preserve the existing vibration backend in this change or provide equivalent Linux matching. Keep the new speaker disabled wherever the owner cannot be established reliably.host/pad_speaker.c:427Changing from All sound headphones to the speaker keeps the ring’s queued samples and primed state. Unplugging during music can send the buffered full-game mix through the speaker before class routing takes over. Quiesce the producer and consumer and clear queued samples and filter history at the route change. The fixture currently clears the ring manually, so it should exercise the production transition instead.host/pad_speaker.c:469The requested 256-frame SDL3 hint is overwritten by the shared opener’s 480-frame default when the environment variable is unset. If the player set the variable, the speaker still replaces its hint and clears it afterward. Pass the buffer request to the shared opener, respect an explicit override, and verify what SDL actually opens.Suggestions (the author may take or leave)
host/rumble_renhdrum.c:363: This opens the last globally looked-up token, while the poll caches only a per-pad boolean. After a failed open and another pad’s lookup, the first pad can retry on the second pad’s endpoint. Pass the matched token with the pad and test the ownership handoff.Testing: Read-only review. git diff --check returned no findings. No build, script, test or game run was performed. The reported smoke, lint, suite and in-game results cover earlier revisions. Current-head Windows and Linux builds, the UTF-8 archive fixture on Windows, Tier 1 fallback checks and CI remain unverified.
Overlaps and merge order: #405 is in the base and supplies the vibration path this PR changes. The port already accounts for #1774 and #1802. #1433 covers related headphone audio and has no demonstrated merge-order dependency.
Automated code review by BeanBot (gpt-6.2-sol), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -628,0 +723,4 @@#else(void)pad;return -1;#endifThis also disables existing wired RenHDrum on Linux, even with HOS_PAD_SPEAKER=0. Preserve the existing vibration path or provide equivalent Linux matching. Require reliable ownership for the new speaker.
@ -0,0 +424,4 @@InterlockedExchange(&stream_on, 0);InterlockedExchange(&route_all, all_route()); /* (plugged, pulled, or the menu's rows moved: the pad told again) */if (!pad_route(pad, to)) { close_endpoint("output report rejected"); return; }stream_to = to;Unplugging in All sound leaves queued full-mix audio in the ring when the speaker takes over. Synchronize and clear the old route’s buffered audio before re-enabling playback. Test the switch with a populated ring.
@ -0,0 +466,4 @@if (device < 0) {if (!said++) hos_log("pad speaker: no matching four-channel audio endpoint for the DualSense");return;}The shared SDL3 opener sets 480 frames when the environment variable is unset, overwriting this 256-frame hint. Pass the request through the opener and preserve any explicit override.
@fix
I changed this pull request where the review's points could be done here (the rest needs runs, measurements or decisions): the new head is
3640f7ba94.Changed
Left for the author
Nothing was built or run: check the change. It will be reviewed again.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Recommendation: Request changes. Controller-routed sounds bypass the game's background mute, and the new endpoint matcher disables existing wired RenHDrum on Linux even with the speaker feature off. The Windows dongle run demonstrates the feature on an earlier build, while the current head's routing and cost remain unverified.
Adds per-sound DualSense speaker routing, full-game headphone output, and a shared stream with vibration. Since review 1935, the endpoint token is cached per pad, route changes clear the ring and reopen the SDL stream, and both openers receive the requested buffer size. These changes address the shared-token bug and the queued-audio case in the new unplug fixture. The shared reopen still needs to verify endpoint ownership.
Does it help: Unproven on
3640f7ba94. The earlier Windows 10 DS5Dongle run reported working speaker, headphone and shared vibration playback, with 0 underruns, 0 trims and 20.0 ms buffered on average. There are no matched, interleaved base and head runs for startup, frame times, RAM or audio dropouts with the feature active, off, and with no controller. The first active append still loads and decompresses archives under the mixer lock, and the inactive mixer still does per-sample routing work.Other systems: The mixer changes affect ordinary desktop output and 5.1. The headphone fixture checks the 5.1 center downmix. Linux and Steam Deck lose access to wired RenHDrum where the base could open a four-channel endpoint. Plain USB, DS5Dongle and two-pad Windows operation need current-head runs. The renderer callback structs, saves and cache formats are untouched. The build adds one host source to the existing zstd path.
Switches: HOS_AUDIO_SOURCE and HOS_PAD_SPEAKER_HPF, LIMITER, LOW_LATENCY and TV_DELAY default on. HOS_PAD_SPEAKER defaults to automatic, with 0 disabling and 1 forcing the route. GAIN defaults to 4, BUFFER_MS to 20 ms or 40 ms with low latency off, OCARINA_RUMBLE to 50%, and PATH to 3 on the standalone stream. HOS_AUDIO_SOURCE_TRACE and HOS_PAD_SPEAKER_TEST default off, and HOS_PAD_SPEAKER_HEADPHONES defaults to detection. The HOS_PAD_SPEAKER_ volume, headphone mode and twelve class overrides inherit saved settings. Menu defaults are speaker 100%, sync 0 ms, headphones All sound at 80%, and class routes {1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 1}, where 1 is Controller only and 2 is Controller + TV. SDL_AUDIO_DEVICE_SAMPLE_FRAMES keeps its environment override. Otherwise the shared stream now requests 256 frames by default even with speaker routing disabled. The switches have table rows and docs. The listening run does not establish the defaults across supported setups, and the player environment overrides duplicate saved settings without an A/B or rollback purpose stated in the PR.
Reviewed:
3640f7ba94against3df5c13ed2: Reviewed3640f7ba94against3df5c13ed2and compared the latest fixes withbac384e567and review 1935. Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, standards, the guide screenshot rules, the commit messages, both audio_source files, both pad_speaker files, and the controller_speaker menu module. Read the changed hunks and relevant surrounding code in the existing mixer, SDL, vibration, menu, renderer, shutdown, build and fixture files. Existing modified files were read in excerpts. Skimmed translations, recorded runs and screenshot manifest entries. The standalone review checklist and adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Suggestions (the author may take or leave)
Testing: Read-only review. The author reports six smoke passes, a lint invocation error also seen on main, and 283 test passes with 59 failures on the earlier Windows checkout. The author reports that 29 failures passed alone and 30 reproduced on main. No current-head build, CI result or in-game run was supplied. Verify the UTF-8 fixture on Windows and exercise speaker, headphone and shared vibration routing on plain USB, DS5Dongle and two-controller setups. Compare Linux and Steam Deck vibration with the base.
Overlaps and merge order: #405 supplies the shared vibration endpoint and is already in the base. #1774 and #1802 are incorporated in the rebase. #1433 covers binaural headphone processing, a separate feature. No pending merge order was established.
Automated code review by BeanBot (gpt-6.2-sol), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -394,3 +395,3 @@/// The model's page for each MenuTab: the strip's tabs, then the pages a row opensconst char* const kTabIds[TAB_PAGE + 1] = {"graphics", "audio", "gameplay", "controls", "nfc","mods", "debug", "motion", "fps_details", "controls_page"};"mods", "debug", "motion", "controller_speaker", "fps_details",This changes a recorded guide screenshot input. Complete the required source review and update the recorded revision and hashes, recapturing if the pictured menu differs.
@ -7721,0 +7722,4 @@if (id == HOS_OPT_PAD_SPEAKER_SYNC) return opts.pad_speaker_sync;if (id == HOS_OPT_PAD_SPEAKER_HEADPHONES) return opts.pad_speaker_headphones;if (id == HOS_OPT_PAD_SPEAKER_HEADPHONE_VOLUME) return opts.pad_speaker_headphone_volume;if (id >= HOS_OPT_PAD_SPEAKER_CLASS && id < HOS_OPT_PAD_SPEAKER_CLASS + 9) // (HOS_OPT_PAD_SPEAKER_OF: 63 to 71, then 73 on)The option IDs in this comment are stale. The class IDs now form a contiguous range from 101 through 112.
@ -628,0 +722,4 @@return matches == 1 ? token : -1;#else(void)pad;return -1;Returning -1 here now also disables base's wired RenHDrum path on Linux, even with HOS_PAD_SPEAKER=0. Preserve the existing vibration path separately from verified speaker sharing, or provide a verified Linux match.
@ -1104,0 +1215,4 @@int hos_sdl_pad_headphones(void *pad) {static void *dev, *dev_pad;static int failed, last = -2;if (!f.HidReadTimeout || !f.HidOpenPath || !f.HidClose || !pad) return -1;The cached HID reader survives pad removal. SDL can reuse a controller pointer on reconnect, leaving the new pad with stale jack status or a latched read-open failure. Close and reset the reader as part of the pad's removal.
@ -600,2 +710,4 @@for (int i = 0; i < MAX_VOICES; i++)if (voices[i].used) render_voice(&voices[i]);tv_delay_frame();if (speaker_on) hos_pad_speaker_write(speaker_frame, FRAME); /* (every frame, silence too: the pad's stream runs on) */This write bypasses the gain and background mute applied after render_frame. Alt-tab with Mute in background on and a Controller-only sound can still play. Apply the existing mute and gain policy to this output and cover it in the mixer fixture.
@ -357,0 +383,4 @@AcquireSRWLockExclusive(&life);if (usb_stream) {hos_sdl_audio_close(usb_stream);usb_stream = hos_sdl_audio_open((unsigned)usb_token, 48000, 4, 0, hos_pad_speaker_frames(), usb_pull, NULL);Revalidate ownership before reopening. If another audio endpoint takes the old endpoint's SDL name before the next liveness check, this cached token can open the replacement while output reports still go to usb_pad.
@fix
I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here).
Left for the author
Nothing was pushed.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
3640f7ba945d8a060eedThanks for the review. Since 1938 (now at
5d8a060e, rebased on main9dd41326):render_frameand before they're handed to the pad.tests/test_audio_volume.pycovers Controller only and Controller + TV.rh_usb_findis back to main's name-based lookup, so wired RenHDrum works as before everywhere. Only the speaker sharing that stream requires the endpoint matched to the pad (rh_usb_token, checked when sharing starts).rh_usb_restart_audiore-checks the pad-to-endpoint match on every reopen. If the endpoint changed, it refuses it and lets the stream go, and the poll finds it again.hos_sdl_pad_close.tests/test_pad_headphones_reader.pycovers a reused SDL pointer.settings-graphics.pngwith the 8 changed inputs. The Controller speaker page is under Audio, not a tab, and nothing pictured changed. I kept the image and updatedreviewed_source(revision and hashes) with a note. The checker passes.Also: the archive fixture is stdlib-only now (raw-block zstd frames written by the test), and the option ID comment is fixed. The "Website build" failure came from main at the time and passes on current main.
Measurements against main (with and without a wired DualSense, speaker on and off) and the in-game results on this head (plain USB cable and the dongle) are in the description. No measurable cost. Linux and Steam Deck are still untested on my side.
Screenshots on this head: the Audio tab with the new Controller speaker row (on main the tab is the same without that row), and the Controller speaker page with my own settings, not the defaults.
5d8a060eeded190769b4@review
Recommendation: Request changes. The feature works in the reported Windows play sessions, but its shared routing state has data races and shutdown can proceed without owning the endpoint. The first sound can also block the audio mixer while archives are read and decompressed.
Adds configurable DualSense speaker and headphone routing, sharing the controller’s audio stream with RenHDrum when possible. It adds useful output options, but also adds work to the game’s audio path and changes vibration buffering, including when the speaker is disabled.
@fixwill do (12)host/pad_speaker.c:117: The pad polling thread writes mode while the mixer reads it in hos_pad_speaker_mode without a lock or atomic access. (more on the line)host/pad_speaker.c:520: The mixer reads stream_on and route_all as plain volatile values while the poll thread changes them with Interlocked operations; the other shared route and setting flags have the same issue. (more on the line)host/pad_speaker.c:543: After 500 failed attempts to acquire gate, shutdown proceeds as if it owned it. (more on the line)host/nn_audio.c:2078: The first wave buffer after the speaker opens reads and decompresses the dictionary and all selected archives while holding au_lock, which the 5 ms mixer also needs. (more on the line)host/audio_source.c:183: hos_mem_region checks the logical heap range, not whether Windows heap pages are committed. (more on the line)host/pad_sdl.c:532: The ocarina reduction is applied to the common strength before processing every pad. (more on the line)host/audio_source.c:117: The fixed 1024-byte pattern and path buffers silently truncate long RomFS paths; Windows also limits conversion to 1024 wide characters. (more on the line)tests/test_audio_source_load.py:218: The fixture inherits HOS_AUDIO_SOURCE from the caller. (more on the line)tests/test_audio_source.py:189: This fixture and test_audio_source_load.py default directly to gcc, and their RUN_ALL_ARGS also force gcc. (more on the line)host/nn_audio.c:632: Read a voice’s mode once per stable source segment instead of looking it up for every sample, and avoid per-sample routing work when the speaker is inactive.host/rumble_renhdrum.c:375: Keep the previous vibration buffer size when the speaker is disabled or cannot share the stream.Before merging, for the author (3) (a run, a measurement or a decision; it doesn't hold the recommendation)
host/nn_audio.c:632: Measure the new per-sample classification and routing work in an uncapped representative gameplay scene, with the speaker on and off, against the base. (more on the line)host/rumble_renhdrum.c:375: The existing wired vibration stream now requests 256 frames even with HOS_PAD_SPEAKER=0, instead of its previous SDL default. (more on the line)@fixor@rebasetry first).Checks: Still running:
CI / Conventional Commit title (pull_request),CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request),CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request),CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request),CI / Workflow lint (actionlint) (pull_request),CI / Website build and checks (pull_request),Guide screenshots / Guide images and local UI source review (pull_request),Third-party parts / As their notes say (pull_request),Third-party parts / The same as upstream (pull_request),Website / Website on Cloudflare (pull_request).More: does it help, other systems, switches, what was read
Does it help: Yes for the feature on the reported Windows DualSense setups: the author heard controller sounds and headphone output in play. The performance cost is unproven in play: the reported capped title-screen medians were 16.66 ms on both sides, and p99 was 17.80–17.83 ms with a controller; the author notes that the cap hides smaller costs and the classed-sound path was not measured.
Other systems: Linux and Steam Deck cannot currently match the speaker endpoint and have not been tested in play; wired vibration still uses the existing name lookup but now requests a different SDL buffer size. The changes also affect mixer timing, normal TV output during route changes, headphone output, and vibration on other connected pads. No other GPU, driver, or OS play results were supplied.
Switches: HOS_AUDIO_SOURCE, HOS_PAD_SPEAKER, HOS_PAD_SPEAKER_HPF, HOS_PAD_SPEAKER_LIMITER, HOS_PAD_SPEAKER_LOW_LATENCY and HOS_PAD_SPEAKER_TV_DELAY default on; gain defaults to 4, buffer to 20 ms, ocarina rumble to 50%, and path to 3. HOS_AUDIO_SOURCE_TRACE and HOS_PAD_SPEAKER_TEST default off; HOS_PAD_SPEAKER_HEADPHONES defaults to detection. Volume, headphone mode and the 12 class overrides default to their menu values. Rows and documentation were added; the buffering default’s effect on existing vibration remains unverified, including with the speaker disabled.
Reviewed:
ed190769b4againste7579b0a4f: Read AGENTS.md, CONTRIBUTING.md, the PR template, applicable standards and commit messages; docs/review-checklist.md is absent. Read the new speaker, source, menu and principal audio integration code and the source and speaker test fixtures; inspected changed SDL, vibration, menu, build and test diffs and relevant callers. Translations, switch tables, documentation and remaining fixture changes were skimmed; not every changed code file was read in full.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no project code, scripts, builds or tests were run. The author reports Windows play tests and fixture results; Linux and Steam Deck play testing remains outstanding.
Overlaps and merge order: None found in the supplied material; the network was unavailable for checking open pull requests.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +114,4 @@if (!as_on() || !hos_romfs_dir || InterlockedExchange(&started, 1)) return;ZSTD_DDict *dict = as_dictionary(); /* (none: the archives are tried as plain frames) */char pattern[1024], path[1024], archive[MAX_PATH];snprintf(pattern, sizeof pattern, "%s/Sound/Resource/*.bars.zs", hos_romfs_dir);L7 (minor): The fixed 1024-byte pattern and path buffers silently truncate long RomFS paths; Windows also limits conversion to 1024 wide characters. A valid deeply nested game folder can consequently play normally but never classify its sounds. Allocate paths and wide conversions to the required length and check formatting failures.
@ -0,0 +180,4 @@int hos_audio_source_of(uint64_t data, uint32_t *crc) {if (!as_ready || !data) return -1;size_t before = BWAV_MAX_BEFORE; /* (as far as the game's memory is mapped before it) */while (before >= BWAV_ALIGN * 2 && (data < before || !hos_mem_region(data - before, before))) before >>= 1;L5: hos_mem_region checks the logical heap range, not whether Windows heap pages are committed. Scanning up to 64 KiB before a wave buffer can therefore fault in previously untouched reserved heap pages just to search for a header, increasing commit use and potentially waiting for memory under pressure. Limit the search to committed readable pages, or track the archive bounds instead of probing preceding heap memory.
@ -534,6 +629,8 @@ static void render_voice(Voice *v) {if (!next_source_frame(v)) memset(v->cur, 0, sizeof v->cur);else any = 1;}pad[i] = speaker_on && v->source > AUDIO_SOURCE_NONE ? hos_pad_speaker_mode(v->source) : HOS_PAD_SPEAKER_OFF;L10 (minor): Measure the new per-sample classification and routing work in an uncapped representative gameplay scene, with the speaker on and off, against the base. The supplied title-screen runs are capped and do not establish the in-play cost.
@ -1947,1 +2076,3 @@const Cmd k = {.op = OP_VOICE_APPEND, .idx = (int)(v - voices), .wbp = ARG(1), .wb = checked}; /* (as checked) */Cmd k = {.op = OP_VOICE_APPEND, .idx = (int)(v - voices), .wbp = ARG(1), .wb = checked}; /* (as checked) */uint32_t crc = 0;if (hos_pad_speaker_active()) hos_audio_source_load();L4: The first wave buffer after the speaker opens reads and decompresses the dictionary and all selected archives while holding au_lock, which the 5 ms mixer also needs. A slow disk or cold cache can stall all game audio and the calling game thread on first use, including after connecting a controller during play. Load the table away from the mixer lock and publish it once complete, keeping sounds on the normal output until it is ready.
@ -512,1 +529,4 @@if (strength <= 0) mode = VIB_MODE_OFF, strength = 100;/* (longshot) eased while the ocarina plays on a DualSense's speaker, which the vibration otherwise shakes intocrackling (host/pad_speaker.c): every backend's strength, the voice coils' too */strength = strength * hos_pad_speaker_rumble_percent() / 100;L6 (minor): The ocarina reduction is applied to the common strength before processing every pad. With a DualSense playing an ocarina sound and a second controller connected, that other controller’s vibration is halved too, although it cannot shake the DualSense speaker. Apply the reduction only to the pad whose speaker is playing.
@ -0,0 +114,4 @@int any = 0;for (int i = 1; i < AUDIO_SOURCE_CLASSES; i++) {const int menu = rx_option(HOS_OPT_PAD_SPEAKER_OF(i - 1), class_default[i]);mode[i] = (signed char)env_int(class_env[i], menu < 0 ? 0 : menu > 2 ? 2 : menu, 0, 2);L1: The pad polling thread writes mode while the mixer reads it in hos_pad_speaker_mode without a lock or atomic access. Changing a class while audio is playing is a C data race, so routing can be inconsistent or undefined. Publish the settings as an atomic snapshot or protect both readers and writers with a lock.
@ -0,0 +517,4 @@start(pad, to, s, "its own stream");}int hos_pad_speaker_active(void) { return stream_on && !route_all; }L2: The mixer reads stream_on and route_all as plain volatile values while the poll thread changes them with Interlocked operations; the other shared route and setting flags have the same issue. Volatile does not provide atomic synchronization in C. Use atomic loads and stores consistently, and publish a coherent route to the mixer.
@ -0,0 +540,4 @@void hos_pad_speaker_shutdown(void) {InterlockedExchange(&closing, 1);for (int i = 0; i < 500 && InterlockedCompareExchange(&gate, 1, 0); i++) Sleep(1); /* (the poll's turn ends) */L3: After 500 failed attempts to acquire gate, shutdown proceeds as if it owned it. If endpoint enumeration or reopening holds the gate longer than 500 ms, shutdown and the poll can concurrently route and close the same stream or use the pad as it is closed. Only access the endpoint after acquiring the gate, with a safe timeout path if shutdown must remain bounded.
@ -337,3 +373,3 @@usb_dsp = dsp;ReleaseSRWLockExclusive(&lk);usb_stream = hos_sdl_audio_open((unsigned)usb_token, 48000, 4, 0, usb_pull, NULL);usb_stream = hos_sdl_audio_open((unsigned)token, 48000, 4, 0, hos_pad_speaker_frames(), usb_pull, NULL);L11 (minor): The existing wired vibration stream now requests 256 frames even with HOS_PAD_SPEAKER=0, instead of its previous SDL default. Check vibration continuity and callback cost on Linux and Steam Deck as well as Windows; the supplied runs do not cover those systems.
@ -0,0 +186,4 @@def main():parser = argparse.ArgumentParser()parser.add_argument("--cc", default="gcc")L9 (minor): This fixture and test_audio_source_load.py default directly to gcc, and their RUN_ALL_ARGS also force gcc. A supported setup that selects Clang through CC but has no gcc cannot run them. Honor CC and avoid forcing gcc in the test runner arguments; make the same adjustment to the new speaker and headphone fixtures.
@ -0,0 +215,4 @@command += ["-I", str(ROOT / "host/posix"), "-D_GNU_SOURCE"]sources.append(str(ROOT / "host/posix/win32_posix.c"))subprocess.run(command + sources + ["-o", str(exe)] + ([] if os.name == "nt" else ["-lpthread", "-lm", "-ldl"]), check=True)subprocess.run([str(exe), str(tmp), str(tmp / "navi.bars"), "full"], check=True)L8 (minor): The fixture inherits HOS_AUDIO_SOURCE from the caller. With HOS_AUDIO_SOURCE=0, its expected six classified sounds are never loaded and the test fails for an unrelated developer setting. Run the fixture with the relevant audio switches removed from its environment.
@fix
ed190769b41e24c4616dRecommendation: Approve. Representative gameplay cost and wired vibration continuity on Linux and Steam Deck remain unmeasured. The Windows play reports show the feature working on an earlier head, but the later audio changes have not been measured. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
What
@fixchangedThe branch moved while I worked (someone pushed
1e24c4616d), so I did it again on top of that. I changed this pull request: the new head isc0e4e39b40. I edited its description to match the change.Changed
Changed in part (the rest is for the author)
Nothing was built or run: the checks run again on the new head.
Routes selected sounds to a DualSense speaker and can send the full mix to headphones connected to it. It adds configurable routing and audio processing, with platform and performance costs still to verify.
Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)
host/nn_audio.c:632: Measure representative uncapped gameplay against the base with the speaker on and off. The title-screen runs cannot show the in-play cost.host/rumble_renhdrum.c:375: Check wired vibration continuity and callback cost on Linux and Steam Deck. The default buffer is now retained when the speaker cannot share, but those systems have not been checked.Checks: they run again on this head; a failure shows on the pull request.
More: does it help, other systems, switches, what was read
Does it help: Unproven on the current head. Windows play on
5d8a060edemonstrated the speaker and headphones; title-screen measurements showed median frame time of 16.66 ms on both sides, but were capped at 60 fps and predate the current audio changes.Other systems: Windows wired and dongle use were reported working on an earlier head. Linux and Steam Deck wired vibration continuity and callback cost remain unchecked; controller speaker endpoint matching is unavailable there.
Switches: The PR adds audio-source and controller-speaker diagnostic and tuning switches, plus per-sound routing settings. They are documented with defaults in the description and switch reference; their performance on the current head remains unmeasured.
Reviewed:
c0e4e39b40against8aa7498345: Read the repository rules and PR template, the ledger-relevant routing and vibration code, option IDs, commit list, supplied description and recorded reports. The full diff and all changed files were not read in full; the large combined output was truncated.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. CI has not yet run on this head.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.