AUDIO-038: out-of-range loop output recreation#
Status and boundary#
PR #553 now contains a bounded loop-only correction, following independent static review of the native stop/restart contract. It does not retire AUDIO-038. Finite one-shot restart/expiry, sentence selected-descriptor timing, initial submission admission and the broader host group-enable model remain residuals. Held-chain child playback and sentence scheduling are unchanged.
The implementation retains AudioVoice as the public logical Stop/move handle, but releases its per-output cursor when a catalogue loop leaves range. A later admitted tick creates a new output cursor at the selected source's beginning. Logical serial, selected PCM, parameter table and explicit-stop state survive independently of the output. A released loop does not mix, duck other channels, finish, or emit a segment-completion callback.
Native evidence#
Static addresses below refer to sp20_nocd/tp.exe, SHA-256 5472f97b5eb28f58b5a49f3a15f6f66adffa6b2625a623f503202c9696d1b805. No executable execution or original-media capture is claimed.
0x6BCA10 -> 0x6BCA70: range failure sets placeholder flag0x800before sending type-3 stop for sample handle+0x24. The immediate routine does not clear the handle.0x6B8D60 -> 0x6BAB50: validate the output handle against its slot/nested stream. A valid handle reaches0x6B7E60; only successful backend stop reaches0x6BB7C0.0x6BB7C0 -> 0x6C6260 -> 0x6C8E50: the output wrapper invokes owner virtual+4, passing output handle, logical owner handle and reason. It then clears its callback owner pointer.0x6BBE40: a matching logical owner handle (+0x2C) clears output handle+0x24and playing bit 1. Range flag0x800prevents terminal bit0x10being set. This resolves the old incomplete inference that the range-stopped output handle necessarily remained alive. Invalid lookups and failed stops do not establish this acknowledgment.0x6B62B0: group/range/admission precede pooled ticks.0x6BD800re-enters setup0x6BC410after the output callback clears playing state.0x6BC410reuses the selected sound/sample, evaluates volume, pitch and delay, and reinstalls the callback owner.0x6B9AB0calls0x6B9A60with existing handle zero. The source creation path builds a new output; the PCM source constructor0x6C6E70zeros its cursor/state.The elapsed modulo in
0x6BC534–0x6BC55Dis a late-start eligibility test, not a seek offset. Event flag 8 makes an expiry-exempt loop. Native finite-source setup would redraw delay and recheck expiry against the original base deadline; this PR does not implement finite-source return.0x6BC760muted-group handling additionally clears+0x24explicitly after stop dispatch. Zero host gain is not treated here as proof that this separate native group-enable switch is disabled.
Sentences and held children are distinct#
Sample-backed sentence tick 0x6BDF50 reuses 0x6BC410, but refill callback 0x6BDE00 may already have replaced the placeholder's selected sample before the previous output audibly finishes. Recreating the selected descriptor therefore does not justify either “always replay the audible segment” or “always consume the prefetched segment.” Mapping the existing early-prefetch extension requires a separate controlled selection/refill fixture.
Held-chain root tick 0x6BDAE0 -> 0x6BDB50 directly walks locally linked children. Creation 0x6BDBB0 -> 0x6B72F0 -> 0x6C3DE0 does not insert those children into the manager pool. Both child vtables 0x70A970 and 0x70A9E0 override sample setup to 0x6C3AE0, without the callback-owner setup of 0x6BC410. Root range exclusion prevents further child ticks/spawns, not a recursive output stop. Explicit stop 0x6BD9B0 is the separate cascade. Existing children continue playing out; they are not extra pool entries.
Implementation guardrails#
Range release and explicit Stop are separate operations; explicit Stop and channel StopAll remain terminal even while no output exists.
Restart is gated by the same twelve-owner rank/newest selection and by held lifetime
CanAdmit/Suspended. A non-admittable retained loop does not consume a candidate slot. Simultaneous loop restarts draw in admitted pool order.Pool eviction alone does not release already-playing output. Restart does not renew serial or create another logical pool entry.
No sound/sample chooser runs on range return. Retained parameters re-evaluate volume, pitch, then delay. Held lifetime preserves its volume where its existing contract requires it and receives the new output reply.
Held fade StopPending/terminal gates remain authoritative. Range release loses physical output-reply availability; a later fade poll can end that owner before return.
The software mixer is synchronous on the audio host thread. Released output state is unreachable; active logical voices reject completion notifications. This is a managed safety property, not a claim that the native callback compares output tokens (it compares owner identity).
Raw mixer sources retain their existing behavior. Catalogue range admission is not added to held children or arbitrary mixer callers.
Synthetic acceptance and validation#
AudioLoopRangeTests uses synthetic PCM, fake catalogs, explicit mixer ticks and injected clocks. It covers fresh output phase and identity, owner retention, idempotence, unchanged sample choice, ordered volume/pitch/delay draws, simultaneous return order, any-distance/flat/zero-range exceptions, explicit/channel stop, twelve-slot and rank-zero admission, suspended-owner exclusion, placed parameter updates, held fade termination/group gain, released-speech ducking, and held-child cursor preservation. The prior pitch test is updated to distinguish retained logical owner from released output. The raw-mixer spatial test is explicitly scoped as raw mixer behavior.
Local validation is limited to source review, whitespace checks and Python documentation/register validators. Local .NET execution was not attempted because of the existing execution restriction. Runtime acceptance requires successful focused/full test execution in the authorized exact-head CI and independent frozen-source review. No passing runtime result is claimed in this proposal.
Remaining work#
Finite one-shots: retain original expiry base, apply old-delay admission followed by new-delay expiry recheck, and preserve late-start rejection before enabling restart.
Sentences: test selected S before refill versus selected T after refill, independent of the audible-buffer boundary, before changing early-prefetch mapping.
Initial submission and general host group-enable parity remain outside this loop-return slice. Current host zero-gain behavior is preserved.
Exact codec/device buffering has not been captured from the original. Synthetic fresh-source tests are not an acoustic cross-device parity claim.
Do not publish original media or private game data in fixtures or commits. Keep the residual annotation and review/CI gates visible.
Update, October 28, 2026 (round 10 package G)#
A sentence stopped by range replays its segment from the beginning. The range stop leaves the selected descriptor (
+0x0C) alone; the sentence tick0x6BDF50starts it again through0x6BC410(volume, pitch and delay draws, a new stream with its cursor at 0,0x6B9AB0); only the refill0x6BDE00(0x6BDF00->0x6B9A60) advances the descriptor, when the decoder's0x2400-byte read (0x6BB510, the double-buffered producer around0x6BB5E0) reaches the end of the segment's data.SoundSentencekeeps the playing segment and the successor chosen ahead ([EXT:sentence-prefetch]) and replays the former first (AudioSentenceResumeTests). A stop inside that last look-ahead resumes on the successor in the original; the look-ahead (the producer thread's lead plus QMixer's stream buffer) was not read, so that window stays open.A started any-distance voice is ranked at the origin of the sound space: its sample start puts the raw dwords (0, 1, 0) into the placeholder's position (
0x6BC51D) and0x6BB9F0ranks every voice by the ground distance of that position (SoundEventSystem.RankPlace).Still open: the initial submission's admission, and the group-enable stop and restart of a voice (
0x6BC760, the enable bytes+0x44..+0x47of the sound system, fed by the sound service0x51BD70).
Source: docs/proposals/audio-038-trace-out-of-range-voice-resumption.md in the project repository.