Prepared file output¶
Enable ravet-device/resampled-playback explicitly for FilePlaybackOutput, an
output-only processor owning the complete output-rate clip prepared by
ravet-audio-file::prepare_file_playback. Configure its exclusive memory transport
before moving it into PreparedOutput/open_output. Preparation rejects mismatched
rate/channel/event/auxiliary/render configurations before callbacks and allocates
bounded scratch; valid processing only renders memory and copies planar output.
Reset pauses at zero/configured loop start; deactivate retires processing while
preserving clip/cursor. No cross-thread transport mailbox is added. Stop callbacks
before recovering/dropping clip storage. Retained causal filter delay/tail, complete
file budgets and failure-owned reader semantics are documented in
audio files.
Actual PreparedOutput tests establish variable-buffer/sample/heap/lifecycle
behavior; physical output, deadlines, live buffered conversion, drift and device
clocked transport still require their separate implementation/validation.
Prepared buffered file output¶
The default-disabled resampled-playback feature also exposes
BufferedPlaybackOutput. It owns BufferedPlayback from a native or explicitly
converted ReadAheadWorker and implements the existing actual PreparedOutput /
open_output processor path with preallocated planar bridging. Prepare rejects
sample-rate, channel and render-capacity mismatches before rendering. Callback
processing renders the prepared unique consumer, updates atomic monitor counters
and copies samples; it performs no file read, conversion, allocation or wait.
Configure play/pause through the exclusively owned endpoint before handing the
processor to an output owner. Reset pauses while retaining queue/cursor; deactivate
and prepare retain transport. A directly owned stopped processor can reclaim its
playback endpoint and perform matching stopped worker seeks. open_output keeps
its processor in a native closure; this API does not reclaim that inaccessible
endpoint or promise live physical seek/recovery. BufferedPlaybackOutputMonitor
returns relaxed snapshots that may span adjacent callbacks; counters wrap and
count converted output frames. Worker status distinguishes Failed/Stopped from
verified EOF; ended requires EOF and complete queue drain. Source-worker failures
retain previously queued audio for one exact drain and preserve their original error in worker shutdown.
Prepared adapter evidence covers exact conversion/tail, arbitrary callback sizes, allocation-free callback execution, paused consumption, failed-worker prefix, configuration and exclusive reset/deactivate/reprepare/seek/reclaim. It does not establish physical-device support, clock mapping/drift control, device scheduling, a cross-thread command mailbox or a callback deadline.
Explicit stopped native output recovery¶
PreparedOutput::new_owned returns the original processor on ordinary preparation
failure. It preflights configuration and fallibly allocates scratch before calling
Processor::prepare; a failing processor must satisfy the trait's inactive
contract. The existing new keeps its consuming failure signature.
into_processor consumes a directly owned stopped renderer on control, deactivates
once and returns its processor for explicit preparation/reopening. It performs no
hidden source seek, reset or read-ahead shutdown.
open_reclaimable_output adds a native f32 output owner with a dedicated control
retirement worker. ReclaimableOutput::stop drops the native stream on control and
returns OutputRetirement. Poll try_reclaim without waiting or explicitly block
with wait on control. The pending proof has no deadline or cancellation guarantee:
CPAL may destroy callback captures asynchronously. Ordinary stream/receiver Drop
also leaves the worker retaining framework captures until retirement is safe.
ReclaimedOutput distinguishes normal stopped ownership from a caught retirement
worker fault that still returns the original owner. Processing panics permanently
silence the data callback; recovered ownership does not restore correct DSP history.
Original opening errors are returned with either FailedOutputOwner::Immediate
(preflight/preparation/spawn) or Pending (backend ownership may remain). No error
is replaced by a successful owner or file EOF claim. A foreign deactivation panic
after callback retirement can lose owner recovery and reports an exceptional worker
error. Calls and joins belong to control; no automatic retry or recovery occurs.
The framework's data/error closure captures only unique guards and primitive state. Each guard Drop publishes its retirement flag and releases a non-last Arc. The worker extracts renderer/scratch/counters only after both Acquire flags and sole strong ownership prove that callback borrows and Arc fields are gone. An early receiver drop or a caught polling panic cannot move final framework destruction onto a callback. This narrowly audited shared-cell access is an explicit unsafe boundary, documented with SAFETY comments that clippy enforces. The guards' owner borrow sits outside the unwind scope, so a missing owner silences output or drops input instead of panicking; native CPAL/OS closure allocation, locking and destruction are separate backend limits. Panic handlers/runtime costs are exceptional.
A recovered BufferedPlaybackOutput retains its original unique consumer. Stop
its native callbacks first, obtain the processor, then use the matching worker's
seek_stopped and explicitly prepare/reopen the recovered owner. Failed candidate
seeks preserve the prior cursor and queue. This ownership integration does not
provide a live seek mailbox, clock/drift correction, arbitrary endpoint reclamation,
physical-device support or a teardown/callback deadline.
The reusable silent probe opens the exact default f32 profile without channel or sample-format fallback:
cargo run -p ravet-device-probe --bin reclaimable-output --locked
cargo run -p ravet-device-probe --bin reclaimable-output --features resampled-playback --locked -- --converted
The default mode checks two native silent stop/recover/reopen cycles. The explicit converted mode uses a 257-frame zero-valued Float32 WAV at 44.1kHz in every device channel, bounded Sinc16 conversion and an independent retained-output integer count. It drains through the actual native callback, reclaims the unique file consumer, checks a failed stopped seek, seeks to output frame17 and explicitly reopens/drains again. It checks exact consumed output coordinates/EOF and original worker errors. It rejects unsupported default layouts/rates/formats. Underflow is reported without advancing the source cursor and is not a scheduling guarantee. Five-second control observation windows are local probe limits; they do not establish callback or teardown deadlines. These zero-PCM receipts establish environment-specific ownership/conversion composition, not audible quality, clock alignment/drift or broad physical-device support.