feat(libSceAudioOut): host volume and mute hotkeys, opt-in mute on focus loss #12569
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12569"
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?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T20:45:28Z.
What
Host-side master volume and mute for the game window, plus an opt-in mute while the window has no focus. This is a control of the host, like a media player's volume. It is not a console behaviour and the title does not see it.
VolumeDown(F5),VolumeUp(F6),ToggleMute(F8). They are keyboard-only, rebindable inanyps5-input.ini, never reach the pad, and follow the same conflict rule as the existing actions (a shared key triggers both). F5, F6 and F8 are used by no other default binding. Each handled press prints one line on stderr.ANYPS5_VOLUME. The gain is the square of the volume as a fraction of 100, in 16.16 fixed point. Mute is separate from the volume, so unmuting restores it. A volume key while muted also unmutes. A gain change ramps at a constant per-frame step (10 ms for a full-scale change), exact and continuous across buffers.ANYPS5_MUTE_ON_FOCUS_LOSS=1mutes while the display window has no focus and restores on focus gained. Unset or0is today's behaviour. It never replaces the user's own mute. Only focus events of the display window count. An invalid value of either variable, including an empty one, stops the game with an error naming the variable.AudioOut.cppjust beforeSDL_QueueAudiofor every non-vibration port, andAudioOut2Context.cppinDeviceCallback(the only place the main mix reaches the speakers).libSceAudio3dplays throughsceAudioOutOutput, so it is covered. Not touched: the controller's sound card and haptics (vibration ports, the AudioOut2 pad device), and the microphone.Commits (67): the pure state class and its steps, mute independence, focus, gain (each with its test), the ramp and the S16 and float gain with their tests, the bypass filter, the strict setting parsers and message wording, the shared state, one commit per playback hook, the three input controls (per action: key request, mapping action, default key, each with a test), the VideoOut wiring (settings at startup, hotkeys, focus events, first focus read), and docs per file (
ENVIRONMENT.md,INPUT_MAPPING.mdin three commits,USAGE.md). The input mapper's action list and defaults follow the native table (its source-contract test).Overlaps with open PRs (edits kept local, branched from
main): #7499 (InputMapping.hpp/.cpp, PadInput.cpp, tests/InputMapping.cpp, INPUT_MAPPING.md), #11860 (input mapper and tests/InputMapping.cpp), #9154 (AudioOut.cpp, AudioOut2Context.cpp, VideoOut CMakeLists.txt, PadInput.cpp), #11049 and #11584 (libSceAudioOut/CMakeLists.txt), #12379 and #12536 (VideoOut, CMake and VulkanDevice areas; no code of theirs used).Tested
Linux x86_64, GCC 12, throwaway archive build of this branch and of
main(319621ba2e). No console, no title.audio_out_host_volume(state machine, steps at 0 and 100, mute restore, focus transitions, gain, strict setting parsers, messages),audio_out_host_gain(S16 and float on mono, stereo and 8 channels: byte-for-byte bypass at unity, exact first sample and landing frame, up and down ramps, no step above the slope, a ramp split across buffers equal to one buffer, saturation, rounding, filter pointer and copy rules),audio_out_host_volume_state(shared state, env parsing, invalid values refused and named, concurrent readers),pad_host_volume(requests and focus events).pad_keyboard_mouseandpad_input_mappinggained cases for the three actions, their defaults, key repeat, mouse and wheel refusal, shared keys and unknown names. Input mapper:node --test tests25 pass.-R '^(audio_out|pad_|video_out_)':main85 tests, 0 failed; this branch 89 tests, 0 failed. The per-test results are identical except for the four added tests (pad_command_filewas not built in the first branch run and passed when built).ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation xvfb-run -a ctest -R '^(video_out_|pad_)' -Vwith-DANYPS5_VIDEO_OUT_TEST_DRIVER=x11:main33/33 passed, branch 34/34 passed (the extra one ispad_host_volume). The validation layer was found in both runs andVUID-appears 0 times in both.std::from_charsalready rejects an empty string. Two controls first passed (an upward ramp without a final snap, S16 truncation instead of rounding); tests were added and now catch them. Removing the bypass is not caught by the byte-for-byte S16 sample test, since unity is an identity; the filter's pointer and copy assertions catch it.check_conventions.py --base upstream/main,git diff --check, the public-headers audit andenv_reference.py --checkare clean.Not run: Windows, macOS, a real audio device (the hooks themselves were reasoned, not heard), a real window system with a real SDL focus sequence (the hotkey wiring and focus events in
PadInput.cppare covered through the pure functions they call, not end to end), a hardware GPU, a console.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T21:36:43Z.
Review: CHANGES_REQUESTED
The full Build's
windowsjob fails on this head inpad_sdl(Exit code 0xc0000409, anabort()after 0.38 s, run 40951632982). I reran the failed jobs once and it failed the same way, so it is not a flake;maindoes not have this failure.core/libs/prx/libSceVideoOut/CMakeLists.txt:26:libSceVideoOutnow linkslibSceAudioOut, a second shared library that statically links its own SDL2 andlibScePad.pad_sdl_tests(tests/PadSdl.cpp) drivesPadInputwith SDL virtual joysticks and aborts in one of itsRequirecalls, so the new dependency, or the newPadInputcode that runs inside that test (HostVolumeConfigureFromEnvironment_nid_no_patchin the constructor, the focus read in the firstUpdate), changes what that test sees on Windows.pad_sdlon Windows and find whichRequireaborts. One direction: keeplibSceVideoOutfrom depending onlibSceAudioOut(for example put the shared volume state somewhere both already link, such aslibScePad) and check thatpad_sdlpasses again.The other jobs on this head are green and the review of the rest (gain path, bypass, shared state, input actions, docs, tests) is unchanged.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T22:13:44Z.
Review: CHANGES_REQUESTED
Thanks for the diagnostic commit. Checked the Windows log of run 40951632982 for
pad_sdl: theabort()is raised frompad_sdl_tests.exeitself (pad_sdl_tests.exe+0x161bb2, i.e. aRequire), not fromlibSceAudioOutor an uncaught exception, so the environment parsing is not the cause and one of the pad/slot assertions fails.The head still has the same dependency (
core/libs/prx/libSceVideoOut/CMakeLists.txt:26,libSceVideoOutlinkinglibSceAudioOut), andpad_sdlstill has to pass on Windows before this can merge. The Build run onc1d819b954(run 40962672138) will printpad_sdl: check failed at line N; once it does, please fix that case, or, if it points at the new dependency, move the shared volume state solibSceVideoOutdoes not link a second shared library that carries its ownlibScePad/SDL copy. Nothing else in the review changes.