silent_audio: volume setters refuse NaN; master volume and mute under the lock (RT-SILENT-AUDIO-VOLUME-NAN) #2519

Closed
leonida/mandy
Tyrannys wants to merge 0 commits from rt-silent-audio-volume-spatial into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

Tyrannys commented 2026-11-28 00:20:36 +00:00

Claimed in the coordination issue as: RT-SILENT-AUDIO-VOLUME-NAN (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7230834145)

What and why

This fixes the first bullet of item 4 in kevincommits' finding in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7226429207).

  • NaN volume accepted. SimpleVolume::SetMasterVolume, StreamVolume::SetChannelVolume and StreamVolume::SetAllVolumes tested level < 0.0f || level > 1.0f. That test is false for NaN, so a NaN level was stored and read back. All three now share volume_level(), which accepts only 0 <= level <= 1. SpatialObject::SetVolume in the same file already checks it that way.
  • Unlocked master and mute. SimpleVolume read and wrote AudioClient::master_ and mute_ directly, without client_->lock_, while the channel volumes take that lock. Both members are now private and are reached through locked accessors.

Not changed: the second bullet, about SpatialStream::ActivateSpatialAudioObject outside BeginUpdatingAudioObjects and Reset keeping objects active. Microsoft's own spatial audio sample activates its static objects before Start, outside an update, so refusing that call would break titles that follow it. Nothing I could check shows that Windows' Reset deactivates objects either. Both are left as they are.

Merges cleanly with the other open silent_audio PRs, #2133, #2134 and #2387.

Tested

  • silent_audio_test gains checks:
    • Each setter refuses NaN and keeps the previous level.
    • SetAllVolumes with one NaN sets none.
    • A mute round trip.
  • With main's range check put back, the 3 NaN checks fail. With the fix, 133/133 checks pass.
  • ctest -R silent_audio passes.
  • The lock change has no test of its own: a plain race on a float and a BOOL does not fail on x86 without a race detector.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU-only test)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

Claimed in the coordination issue as: RT-SILENT-AUDIO-VOLUME-NAN (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7230834145) ### What and why This fixes the first bullet of item 4 in kevincommits' finding in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7226429207). - **NaN volume accepted.** `SimpleVolume::SetMasterVolume`, `StreamVolume::SetChannelVolume` and `StreamVolume::SetAllVolumes` tested `level < 0.0f || level > 1.0f`. That test is false for NaN, so a NaN level was stored and read back. All three now share `volume_level()`, which accepts only `0 <= level <= 1`. `SpatialObject::SetVolume` in the same file already checks it that way. - **Unlocked master and mute.** `SimpleVolume` read and wrote `AudioClient::master_` and `mute_` directly, without `client_->lock_`, while the channel volumes take that lock. Both members are now private and are reached through locked accessors. Not changed: the second bullet, about `SpatialStream::ActivateSpatialAudioObject` outside `BeginUpdatingAudioObjects` and `Reset` keeping objects active. Microsoft's own spatial audio sample activates its static objects before `Start`, outside an update, so refusing that call would break titles that follow it. Nothing I could check shows that Windows' `Reset` deactivates objects either. Both are left as they are. Merges cleanly with the other open `silent_audio` PRs, #2133, #2134 and #2387. ### Tested - `silent_audio_test` gains checks: - Each setter refuses NaN and keeps the previous level. - `SetAllVolumes` with one NaN sets none. - A mute round trip. - With main's range check put back, the 3 NaN checks fail. With the fix, 133/133 checks pass. - `ctest -R silent_audio` passes. - The lock change has no test of its own: a plain race on a float and a BOOL does not fail on x86 without a race detector. GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU-only test) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Tyrannys commented 2026-11-28 00:34:16 +00:00

Closing as a duplicate of #2521 (RT-SILENT-AUDIO-VOLUME-AND-SPATIAL), which two of our sessions opened against the same item at the same time. #2521 covers everything here (NaN volumes refused through one check, master volume and mute under the client's lock) plus the rest of item 4. Sorry for the noise. AI-assisted (Claude Code).

Closing as a duplicate of #2521 (RT-SILENT-AUDIO-VOLUME-AND-SPATIAL), which two of our sessions opened against the same item at the same time. #2521 covers everything here (NaN volumes refused through one check, master volume and mute under the client's lock) plus the rest of item 4. Sorry for the noise. AI-assisted (Claude Code).
Sign in to join this conversation.
No description provided.