silent_audio: NaN volumes refused, master volume under the lock, Reset revokes objects (RT-SILENT-AUDIO-VOLUME-AND-SPATIAL) #2521
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2521
Loading…
Reference in a new issue
No description provided.
Delete branch "rt-silent-audio-volume-and-spatial"
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?
Pull request successfully merged and closed
Package RT-SILENT-AUDIO-VOLUME-AND-SPATIAL: item 4 of @kevincommits' finding on #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7226429207). Thank you for the find. Claim: https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7230866389.
What changes (
runtime/shims/silent_audio.cpp)SimpleVolume::SetMasterVolume,StreamVolume::SetChannelVolumeandStreamVolume::SetAllVolumestestedlevel < 0.0f || level > 1.0f. That is false for NaN, so NaN was stored. One helper now checkslevel >= 0.0f && level <= 1.0f, asSpatialObject::SetVolumealready does.ISimpleAudioVolumeread and wroteclient_->master_andmute_with no lock. They are now private, behind accessors that takelock_, like the channel volumes.SpatialStream::Resetrevokes active objects. Microsoft's reference forISpatialAudioObjectRenderStreamBase::Resetsays resetting "causes all active ISpatialAudioObject instances to be revoked". Now each live object becomes inactive and its type can be activated again. Ends that a pass had queued are released. The stream keeps a list of its live objects (not owned). An object leaves the list first thing in its destructor, so a Reset that holds the lock still sees the whole object.Not changed:
ActivateSpatialAudioObjectduring an update pass. The finding suggests returningSPTLAUDCLNT_E_OUT_OF_ORDERthere. Microsoft's reference for that method lists no such return code. Activating objects inside a Begin/End pass is the documented pattern for dynamic objects, andsilent_audio_testitself activates its static objects that way. So this PR leaves it as it is.Tests (
silent_audio_test)SetMasterVolume(NaN),SetChannelVolume(7, NaN)andSetAllVolumeswith one NaN level are each refused, and the stored volumes stay as they were.StopandReset, a front-left object that was active reportsIsActive == FALSE.GetBufferon it givesSPTLAUDCLNT_E_RESOURCES_INVALIDATED. Front left can be activated again; on main that givesSPTLAUDCLNT_E_OBJECT_ALREADY_ACTIVE.On main, 6 of the new checks fail. With the fix, all 135 checks pass (3 runs).
The lock change has no test of its own: a data race on a float does not show up in a test. It now follows the same pattern as the channel volumes.
Profile M: RTX 4070 SUPER, Windows 11, Ryzen 7 9800X3D, MSVC RelWithDebInfo. CPU only. The full suite was not run because a boot was running.
git diff --checkandscripts/check_no_game_data.pyare clean. Open PRs #2133, #2134 and #2387 change other functions in this file. No game files used.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Reviewed at head
53ea681a0on Windows 11 (MSVC 202219.44).Verification
silent_audio_test,com_shim_test, andgta6rt.silent_audio_test(5 consecutive runs): 135/135 checks passed on all 5 runs.com_shim_test(5 consecutive runs): 42/42 checks passed on all 5 runs.Findings (Request changes)
active_types_andobjects_races withReset()(silent_audio.cpp:775-782,817-831,894-897):ActivateSpatialAudioObject()setsactive_types_ |= t, releaseslock_, allocatesSpatialObject, then re-acquireslock_toobjects_.push_back(o). IfReset()runs in the gap, it clearsactive_types_ = 0without seeingoinobjects_;ois then pushed still active, and a secondActivateSpatialAudioObject(t)succeeds — leaving two live active spatial objects for the same static channel.~SpatialObject()has the inverse split:stream_->forget(this)andif (take_type()) stream_->release_type(type_)takelock_separately. IfReset()runs between them and a replacement object oftype_is activated, the dying object'stake_type()still returnstrueand clears the replacement'sactive_types_bit.objects_membership andactive_types_under a single lock acquisition in both activation and destruction closes both windows.objects_.push_back(o)leaks the object and lets an exception escape a COMHRESULTmethod (silent_audio.cpp:821-833):If
objects_.push_back(o)throwsstd::bad_alloc,o(and itsstream_->AddRef()andactive_types_reservation) is leaked and a C++ exception crosses the COM ABI boundary. Reserving/inserting under atry { ... } catch (const std::bad_alloc&)before committingactive_types_ |= t(or rolling back and returningE_OUTOFMEMORY) handles both issues together cleanly.The NaN volume rejection and locked master volume/mute access (
silent_audio.cpp:419-435,620-626) look solid.AI-assisted review + local MSVC verification.
#2521 | head 53ea681a07fa9e3678b9d43e1fd3eb8dea0deece (merged cleanly with main 09c153948386fd658fe2f999f6176efbaa8c8345) |
ctest --test-dir runtime/build -C RelWithDebInfo -R "^silent_audio$" --output-on-failure| red on main:silent_audio_testfails (135 check(s), 6 failure(s):SetMasterVolume/SetChannelVolume/SetAllVolumesacceptedNaNvia< 0.0f || > 1.0f, andSpatialStream::Reset()left activeSpatialObjects active) | green on PR+main:1/1CTest passes (silent_audio135/135checks in0.78s),check_no_game_data.py0violations. Source audit note: independently confirmed the two open review items insilent_audio.cpp(ActivateSpatialAudioObject/~SpatialObjectsplit lock windows betweenactive_types_andobjects_vs concurrentReset(), and unguardedobjects_.push_back(o)inside a COMHRESULTmethod) | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yesVerified by OreoFR
c1ecf04ed+ PR head53ea681a0; green run in a merge package of 11 PRs, no new ctest failure vs mainctest -R "^silent_audio$"AI-assisted (Claude Code, Claude Opus 5.5).
Tested
53ea681a0merged (no commit) withmainaa918e5d9. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), RelWithDebInfo, Ninja.silent_audiopasses.runtime/shims/silent_audio.cppback tomain, 6 of its 135 checks fail:SetMasterVolume(NaN) is refused and the volume staysSetChannelVolume(NaN) is refused and the volume staysSetAllVolumes with a NaN level is refused and changes nothingReset revokes the objects that were activea revoked object gets no bufferafter Reset, a type that was active can be activated againNo blocker from my side. AI-assisted (Claude Code).
Merged after TheGeogeo's red/green check (check: green with this PR, red with
main's code, no regression over the relinked tests) and a re-check here: no conflict withmain670f1689c, same head as checked,no-game-datagreen, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known onmainor Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ). The Python jobs fail onmaintoo.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.