Repository navigation
feat(libSceAudioOut): host volume and mute hotkeys, opt-in mute on focus loss - #12569
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
adriadam10
left a comment
There was a problem hiding this comment.
The full Build's windows job fails on this head in pad_sdl (Exit code 0xc0000409, an abort() after 0.38 s, run 40951632982). I reran the failed jobs once and it failed the same way, so it is not a flake; main does 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.- Please reproduce
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.
Re-checked — new head, pad_sdl now names the failing checkThanks @adriadam10: the Windows What changedNew head What I ranLinux, GCC 12, no build or test run (this host has no free space for one): The syntax check passes, Not verified
To get this to a good stateA Windows run on this head will give the failing line. With it I will look at the assertion and, if it points at the dependency, move the shared volume state as suggested. I will re-run the same commands on any new head. |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the diagnostic commit. Checked the Windows log of run 40951632982 for pad_sdl: the abort() is raised from pad_sdl_tests.exe itself (pad_sdl_tests.exe+0x161bb2, i.e. a Require), not from libSceAudioOut or 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, libSceVideoOut linking libSceAudioOut), and pad_sdl still has to pass on Windows before this can merge. The Build run on c1d819b954 (run 40962672138) will print pad_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 so libSceVideoOut does not link a second shared library that carries its own libScePad/SDL copy. Nothing else in the review changes.
Re-checked — new head, libSceVideoOut no longer links libSceAudioOutThanks @adriadam10: the shared host volume state now lives in What changedNew head
What I ranLinux, GCC 12, a throwaway build of this head from
ctest lines for the volume and pad testsNot verified
To get this to a good stateA full Build run on this head will show whether the Windows |
✅ NVIDIA GPU test: passedPR head
Failing on main too (2, not counted against this PR)Validation IDs already present on main (3 IDs in 119 tests)Skipped (8)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
✅ NVIDIA GPU test: passedPR head
Validation IDs already present on main (3 IDs in 125 tests)Skipped (8)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
bb4263e to
04aa91f
Compare
HostVolume holds the host output volume from 0 to 100 and moves it in steps of 5 without leaving the range. A move that changes nothing returns false.
Register audio_out_host_volume. It starts at 100, moves in steps of 5 in both directions, and refuses to leave 0 to 100.
The muted flag is separate from the volume, so unmuting brings back the volume that was set before.
Muting at 100, at 90 and at 0 keeps the volume, and unmuting returns it.
Raising or lowering the volume while muted unmutes, so the step is audible. A step that cannot move the volume still reports a change when it unmutes.
Both directions unmute, including at 0 and at 100 where the volume itself cannot move.
SetVolume takes a value from 0 to 100 for an initial volume and refuses anything else.
The volume keys and the focus rule live in the video output's input handling and drive the audio output's shared host volume. libSceAudioOut does not depend on libSceVideoOut.
…commands ApplyHostVolumeRequests runs the requested commands in the order up, down, mute and reports whether there was one, leaving the final state for the caller to print.
They are called across libraries like the other _nid_no_patch and _nid_postfix helpers, so their symbols must not depend on the C++ mangling of a particular compiler.
Register pad_host_volume. An empty request set changes nothing, volume up and down move one step and return to exactly unity, mute toggles, combined requests run up then down then mute, and the other host requests are ignored.
…volume Only focus lost and gained events of the display window count. Minimizing, restoring, closing and the events of other windows change nothing, and the shared volume only acts on them when the focus option is on.
Nothing happens by default, focus lost silences and focus gained restores exactly unity with the option on, other window events, other windows and key events are ignored, and the user's own mute survives a focus round trip.
… starts PadInput applies ANYPS5_VOLUME and ANYPS5_MUTE_ON_FOCUS_LOSS next to the input mapping, so an invalid value stops the game at the same point as an invalid mapping file, with an error naming the variable.
… on stderr The requests are handled only for key events of the display window, like fullscreen, the overlay and the screenshot, and each handled press prints one line with the resulting level or mute.
The display window's focus events drive the shared host volume. With ANYPS5_MUTE_ON_FOCUS_LOSS unset or 0 they change nothing; with 1 the audio is silent from focus lost until focus gained, and each change prints one line on stderr.
A window created without focus sends no focus lost event, so the first update reads the focus itself.
With the option on, a window that opens behind another one starts silent instead of waiting for a first focus event that never comes. With the option off this changes nothing.
Both are read in HostVolumeState.cpp when video output starts, and both refuse an invalid value with an error naming the variable.
VolumeDown, VolumeUp and ToggleMute join the supported actions with their default keys and the keyboard-only rule.
F5, F6 and F8 are used by no other default binding.
…s trigger both The configuration file does not reject a key bound to two actions, so the volume hotkeys follow the rule of the existing ones.
States that it is a host control and not a console behaviour, the steps and the curve, the bypass at the default, what is and is not covered, the stderr feedback, and the two variables.
…ost gain Halves round toward positive, and a ramp from silence back to unity never falls, stays within the slope and lands exactly on unity.
Require aborted without saying which check failed, so a failure on a CI host that cannot be reproduced locally left no trace of the assertion in the log. It now prints the source line before aborting.
libSceVideoOut reads and changes the shared host volume state, and linking libSceAudioOut for it puts a second shared library with its own static SDL2 into libSceVideoOut. Both libraries already link libScePad, so the headers that describe that state move there first; the include paths and guards follow.
The volume, mute and focus state that libSceAudioOut applies and libSceVideoOut changes now lives in libScePad, which both libraries already link, instead of in libSceAudioOut. The tests that compile the state directly and the environment reference follow the file.
The host volume hooks libSceVideoOut calls now come from libScePad, so libSceVideoOut no longer needs libSceAudioOut. That library links its own static SDL2, and loading it with libSceVideoOut is the dependency the Windows pad_sdl abort points at; the libSceVideoOut link line is back to what main has.
04aa91f to
cca2d08
Compare
|
Rebased onto current |
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(319621b). 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)