Harden the PlatformAudio lifecycle (PAR-025) - #377
Draft
MaxHeimbrock wants to merge 1 commit into
Draft
Conversation
Every public member now throws ObjectDisposedException after Dispose() instead of reaching a disposed FfiHandle (or, on iOS, driving the audio session after it was handed back). DevicesChanged subscribe/unsubscribe and double-Dispose stay safe, as before. The constructor no longer leaks the FFI handle when route-controller creation fails after the handle exists: the post-handle work is wrapped so the handle (and a half-built controller) are disposed before the exception propagates, instead of waiting on the SafeHandle finalizer. The SelectOutput deferral while session audio is disabled deliberately gets no pending flag (PAR-019 keeps the surface frozen); the XML doc and the README routing section now spell out how a pre-call picker tracks its deferred choice through the existing IsSelected/DevicesChanged surface, including the drop-on-disappear case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
PR #374's review left three low-severity sharp edges on the phase-A
PlatformAudiocode (finding cluster N, tracked as PAR-025). None is user-visible in the shipped samples, but all three bite apps built on the API: methods called afterDispose()reach a disposedFfiHandle(or, on iOS, drive the audio session after it was handed back to Unity); a route-controller failure in the constructor leaks the FFI handle until the SafeHandle finalizer runs; andSelectOutput's deferral while session audio is disabled gave a pre-call device picker no stated way to track when its choice actually applies.Stacked on #376 (PAR-024), which is stacked on #374 (PAR-023).
Changes
PlatformAudiomember now throwsObjectDisposedExceptionafterDispose(). Subscribing to / unsubscribing fromDevicesChangedand double-Disposestay safe (the existing PlayMode test still passes);_disposedis set at the top ofDisposeso the guard takes effect immediately.SelectOutputdeferral signal: resolved doc-only, no API addition — the PAR-019 surface stays frozen. The app already holds both inputs of "is my choice pending" (its ownSelectOutputcall and its own session-enable state); application ground-truth arrives via the existingIsSelectedflip inGetDevices/DevicesChanged, and the silent drop case (a deferred choice whose device disappears) is visible as the device leaving the playout list. A pending signal would carry meaning only on Android (desktop applies immediately, iOS throws), which is the platform-conditional shape PAR-019 deliberately avoided; phase B's FFI device model (PAR-003) is the right layer if a cross-SDK signal proves needed. TheSelectOutputXML doc and the README routing section now spell out the tracking recipe.PublicMembers_AfterDispose_ThrowObjectDisposed; fullPlatformAudioTestssuite passes on 2022.3.62f1 (10 passed, 1 pre-existing environment skip). The ctor-leak fix is not editor-testable: the desktop route controller's construction cannot be made to fail.No device test required for this card (
human_required: none).🤖 Generated with Claude Code