Crate ravet_ device
Expand description
Explicit CPAL input, output and FIFO duplex adapters, outside the portable umbrella.
Control threads enumerate/select devices and prepare processors. The callback uses preallocated planar f32 scratch, divides variable device buffers into bounded blocks and publishes only atomic counters. This prototype accepts f32 main-bus processors, with no auxiliary buses or event delivery. Duplex connects independently scheduled streams through a prepared bounded ring; matching-rate mode has no drift correction; an explicit clocked mode combines bounded FIFO feedback and prepared sinc conversion without sample alignment. Device availability, callback deadlines and audible output require target validation.
Callback-path invariants never panic: a violated internal invariant silences the affected block and counts a processor fault instead (decision 0295).
Re-exports§
pub use cpal;
Structs§
- Buffered
File Duplex Monitor - Relaxed control telemetry; fields may span adjacent callbacks and counters wrap. No coherent latency, hardware timestamp or audible-delivery claim.
- Buffered
File Duplex Processor - One unique prepared file consumer plus downstream f32 processing. Outer inputs are captured PCM already converted to the output clock by PreparedClockedDuplex; child inputs are file channels first, captured channels second. No file FIFO drift estimator exists. All rates equal the file queue rate. Prepared callbacks allocate nothing and do no lock/I/O/wait; source/capture clocks remain distinct.
- Buffered
File Duplex Statistics - Typed file and logical device coordinates; neither is a hardware timestamp.
- Buffered
Playback Output - Own the automatic worker’s unique prepared callback transport through the actual output Processor path. Prepare validates target rate/channel/render bounds and allocates scratch; process renders/publishes atomics/copies only. Configure transport exclusively before transferring into PreparedOutput or open_output. No duplicate consumer, clock mapping or callback mailbox exists. Reset pauses retaining cursor/queue; reader seek needs reclaimed stopped playback plus its matching control worker. into_playback reclaims only this directly owned stopped processor; it does not reclaim an inaccessible native open_output closure. Native live seek/recovery remains separately integrated.
- Buffered
Playback Output Monitor - Buffered
Playback Output Statistics - Relaxed control snapshots can span adjacent callbacks; counters wrap.
- Clocked
Duplex Options - Prepared callback profile. Clock capacity must match the capture ring; target is strictly inside it. Complete queued+prefetched occupancy is used, capped at raw ring capacity for feedback. The internal converted ring never crosses threads and is drained immediately by the existing duplex renderer.
- Clocked
Duplex Retirement - Poll without waiting; explicit wait is CONTROL only with no deadline guarantee. Early Drop detaches the worker, which retains both capture fields until proof.
- Clocked
Duplex Statistics - Independently loaded telemetry; these fields are not one atomic callback snapshot. Initial/recovery priming is intentional zero input, not underflow.
- Clocked
Duplex Stream - Explicit paired native streams; pause preserves queue/converter/DSP history. Start/pause are sequential, not physically sample-synchronized. Reopen for fresh state or backend failure/panic recovery; no fallback/hotplug is implicit.
- Clocked
Input Progress - Progress separates a fresh converted block from retained queue publication. Counts describe worker blocks, not capture/playback timestamps or latency.
- Clocked
Recovery Receipt - Exact stopped observations passed once to caller-selected restoration policy.
- Duplex
Stream - Two explicit streams with a bounded input FIFO. Matching nominal rates are required but separate device clocks can drift; no compensation is supplied. Start/pause are sequential and not sample-synchronized. Pause retains queued input/DSP history. Reopen to clear queue or recover backend failure/panic.
- File
Playback Output - Output-only processor owning a complete, already converted file clip. Configuration must match the prepared target rate/channel order and fit the clip’s render bound. Prepare allocates scratch; process only copies samples. File reads, conversion, device opening and clip destruction belong off audio.
- Graph
Event Batch - Borrowed immutable pending batch. Drop retains it for another owner tick; acknowledge explicitly after graph consumption or deliberate discard. The tag is caller-owned correlation, not a sample/device-clock identity.
- Graph
Event Consumer - Unique consumer with preallocated retained batch storage. A borrowed batch stays pending until explicit acknowledgement; dropping its borrow does not imply delivery or discard. Endpoints/storage drop after owners stop.
- Graph
Event Producer - Unique producer, prepared off callbacks. Each publication is atomic as one complete fixed-slot batch; full/invalid input publishes no prefix. Use for either control input or worker output with an explicit consumer policy.
- Graph
Event Queue Config - Fixed rendering quantum and whole-batch queue budget. No clock is inferred.
- Graph
Output Progress - Progress distinguishes a newly rendered block from retained backpressure. Published frames are a queue prefix, not hardware playback or latency evidence.
- Graph
Output Session - Non-Send borrowed graph worker session. Rendering/publishing are bounded and heap-free; worker wake/sleep, graph reset, queue/device rate matching and shutdown/join remain explicit. Queue underruns are handled by RingOutput.
- Input
Device Info - Control-thread input enumeration; IDs belong to the selected default host.
- Input
Statistics - Relaxed counters, not a coherent sample/latency measurement. Counters wrap on overflow; notifications are counted only when reported by CPAL.
- Input
Stream - Live f32 input stream. Control-thread play/pause/drop owns backend lifecycle. Pause does not discard queued captured frames; seek/flush policy is external.
- Output
Device Info - A control-thread snapshot; IDs belong to the current CPAL host/backend.
- Output
Retirement - Control-side pending owner. Polling never waits.
waitexplicitly blocks on control, with no deadline/cancellation guarantee. Early Drop detaches the retirement worker; it retains captures until both callback owners are gone. - Output
Statistics - Relaxed atomic diagnostics, sampled on a control thread. Fields may come from adjacent callbacks; this is not a coherent meter or latency measurement. Frames count completed DSP sub-blocks; callbacks include permanently disabled callbacks after a panic. Counters wrap on overflow. Stream notifications are counted only when reported by CPAL; zero xruns do not prove glitch-free audio.
- Output
Stream - A live stream. Start/pause/drop on the control thread; drop stops callbacks. Backend errors are counted and require caller-directed recovery/reopening. Pause/resume retains DSP history and logical sample position.
- Prepared
Capture - Prepared interleaved capture into a whole-frame SPSC ring. Full rings discard the newest input suffix and count it. No callback allocation, locks or I/O.
- Prepared
Clocked Duplex - Prepared f32 duplex input-clock conversion with per-channel f64 sinc storage. Input/output nominal rates are 8000..=192000 and the complete corrected ratio must satisfy the sinc bounds. Preparation allocates; rendering allocates nothing and gives the processor input at the output clock/rate. Prime to target occupancy before consuming capture. Underflow fills remaining converted input with zeros, clears converter/controller histories and reprimes; processor history/output clock continues. Nonfinite audio propagates. Caller owns callback serialization/lifecycle; no physical alignment, universal drift stability, device recovery, headroom or native deadline guarantee.
- Prepared
Clocked Duplex Failure - Original preparation error and original processor/raw capture consumer. Failed prepare is inactive; foreign lifecycle panics are exceptional.
- Prepared
Clocked Input - Control-prepared worker conversion from raw capture to a graph-rate queue. Matching 1..64 channel counts, 8000..192000 nominal integer rates, existing clock/sinc bounds and 1..65536 fixed frames apply. Output scratch<=16MiB is additional to converter/internal queues and source/destination ring memory. Construction/drop allocate off callbacks. Pumping uses no heap/locks/I/O; worker pacing, queue priming, thread ownership and endpoint shutdown are explicit. No physical clock alignment, universal drift stability or deadline guarantee.
- Prepared
Duplex - Prepared f32 effect processing over queued interleaved input. Input underflow fills the missing suffix with zero and counts frames. Variable output buffers split at the preparation maximum; no rate adaptation or event delivery.
- Prepared
Duplex Failure - Original preparation error and exclusive unchanged endpoint ownership.
- Prepared
Dynamic Graph Output - Buffered prepared dynamic graph, reusing fixed-worker queue/event/scratch semantics. The engine must already be prepared at the exact configuration; no graph is reprepared. Offer/reclaim through its separately retained control. Swaps occur only on fresh renders after prior audio suffixes publish. Queued audio retains the old graph’s copied samples, without crossfade/tail drain. Worker start/stop precedes main engine/native retirement and endpoint drop.
- Prepared
Graph Output - Control-prepared f32 graph and worker scratch; new uses no input while with_input consumes an explicitly prepared input queue. Move this to an explicitly owned worker; start its non-Send session there and finish before returning it to main for graph/node retirement. No thread/device is created. Config requires matching input/output queue channels, zero aux buses, 0..1024 events per direction, 1..65536 frames, and producer-matching 1..64 channels. Scratch uses at most 32 MiB outside the graph’s own memory cap. Preparation consumes a fresh graph, preparing it once. Queue backpressure retains exact whole-frame suffixes without rerendering.
- Prepared
Output - Prepared output-only f32 rendering, independently testable without hardware. Construction may allocate; render uses bounded scratch without allocation. Processor implementations must obey the portable callback contract.
- Prepared
Output Failure - Failure-owned output preparation. The original processor survives ordinary format/configuration/scratch/prepare errors; preparation runs off callback. A failing Processor::prepare must leave itself inactive. Foreign prepare panics are exceptional and do not produce a successful recovery receipt.
- Reclaimable
Clocked Duplex - Explicit f32 pair. Control owns play/pause/stop; callbacks only release guards. No physical synchronization, hotplug subscription or teardown deadline.
- Reclaimable
Clocked Failure - Reclaimable
Clocked Recovery Construction Failure - Invalid construction retains the original processor, before native calls.
- Reclaimable
Clocked Statistics - Independently loaded control telemetry, not shared hardware timestamps.
- Reclaimable
Output - Native output plus explicitly pending stopped-processor recovery. Stop/Drop happen on control. Framework callback capture Drop only publishes atomics and releases a non-last Arc; native CPAL/OS destruction is a separate backend limit.
- Reclaimable
Output Failure - Original opening error and exclusive processor recovery ownership.
- Recovering
Clocked Duplex - Caller-scheduled exact input/output pair recovery with bounded clocked conversion. Service/enable/reopen/drop on a control thread. Missing devices, backend errors or output panic release both streams before fresh FIFO, converters/controller and factory-owned DSP are opened. No fallback, settings changes, polling timer, hotplug subscription, state migration or physical fault/deadline guarantee. Ordinary underflow/overflow or DSP faults do not reopen; neither do CPAL xruns or automatic route changes. Native hosted plug-ins retain their own thread/lifecycle obligations.
- Recovering
Duplex - Exact input/output pair recovery, serviced explicitly on a control thread. CPAL xruns and automatic route changes leave both streams active. Both streams/FIFO are released if either device disappears or either backend fails (or output DSP panics). Every successful reopen uses fresh DSP and FIFO. Nominal rates must match; no drift correction or sample synchronization. Factories own restored state. No fallback, timer, recording or native plug-in scheduling is added. Backend enumeration/open/destruction may block.
- Recovering
Output - Caller-scheduled output recovery with an exact host-local device ID and fixed f32 configuration. Construct/service/enable/reopen/drop on a control thread. Service explicitly enumerates the device, closes missing/failed streams and opens fresh DSP after return/backend error/panic. CPAL xruns and automatic route changes do not reopen streams. No device fallback, timer, settings changes, state migration, clock compensation or hotplug subscription. The processor factory runs once per open attempt; it owns restored state and preparation failures. Poll cadence/retry backoff belong to the application. Stream destruction/backend work is blocking and has no callback deadline claim. Generic/native hosted plug-ins still need their own thread-correct lifecycle.
- Recovering
Reclaimable Clocked Duplex - Explicit selected-ID recovery with original processor ownership. Control service never invokes restoration or opens while old callbacks are pending. No timer, fallback, automatic state migration or physical hotplug guarantee. Restoration runs only after a receipt and before fresh preparation; its error preserves P. CPAL xruns and automatic route changes are counted without retiring the pair; backend failures and capture/output panics remain recovery faults. Foreign restoration/deactivation panic loses recovery, never a false receipt.
- Ring
Output - Prepared queue consumer usable with the existing f32 output device adapter. A worker must render at this explicit rate; no resampling/clock matching is inferred. Valid processing consumes a whole-frame prefix and silences every missing sample. Invalid blocks do not dequeue. Drop belongs after callbacks.
- Ring
Output Monitor - Relaxed independent queue-consumption counters, not a coherent clock or latency measurement. Clone during preparation, before callback ownership.
- Ring
Output Statistics - Stopped
Clocked Duplex - All native callback owners are gone. No render or mutable-processor access. Extraction belongs on control and disposes transient conversion/prefetched history. Queued raw frames keep their actual cursor; no rollback is promised.
Enums§
- Clocked
Duplex Error - Clocked
Duplex Open Error - Clocked
Duplex Recovery Error - Exact-ID clocked pair selection, preparation or native backend failure.
- Clocked
Recovery Failure - Restoration failures preserve the original processor and receipt for retry.
- Clocked
Retirement Error - Failed
Clocked Owner - Exclusive original processor or proof pending asynchronous callback teardown.
- Failed
Output Owner - Opening failure keeps the original processor immediately or an explicitly pending retirement proof when a backend may still own its callback captures.
- Graph
Event Queue Error - Graph
Output Error - Open
Error - Output stream construction error, reported outside the callback.
- Output
Recovery Error - Invalid selection or ordinary output preparation/backend failure.
- Output
Recovery Status - Result of one caller-scheduled recovery service. No timer/thread is created.
- Output
Retirement Error - Lifecycle or exceptional worker failure. Callback/backend shutdown has no timeout guarantee; a failed worker does not imply a successful owner receipt.
- Reclaimable
Clocked Open Error - Original opening failure; native build failures may leave pending owners.
- Reclaimable
Clocked Recovery Error - Reclaimable
Clocked Recovery Status - Explicit control state; disabled retirement still polls to retain original owners.
- Reclaimable
Output Open Error - Original control-side failure; no original backend/spawn error is cloned.
- Reclaimed
Clocked Duplex - Normal retirement versus caught worker-poll fault; both retain exclusive owners after proof. Processing panic remains explicit statistics, not valid history.
- Reclaimed
Output - Exclusive stopped processor ownership. A recovered worker fault is distinct from normal retirement; neither outcome promises correct DSP history after a processing panic (inspect statistics). Reopening explicitly prepares the owner.
Constants§
- MAXIMUM_
FRAMES - Upper bound on scratch frames per channel, allocated before stream creation.
Functions§
- device_
nominal_ sample_ rate - Read this device’s current nominal sample rate on the control thread.
- graph_
event_ queue - Allocate 1..65536-frame, 0..4096-event, 1..64-batch SPSC storage on control. Each batch uses capacity+1 slots including unused payload; at most 32 MiB of queue values plus one retained event buffer. Publish/read/acknowledge are bounded without allocation/locks/I/O. Tags/context are opaque caller values; no timestamp translation, retiming, retries or native scheduling is inferred.
- input_
device - Select an exact input ID or default device, with no implicit fallback.
- input_
devices - Enumerate the default host’s input devices and supported configurations.
- open_
clocked_ duplex - Open explicit f32 input/output devices using prepared clocked conversion. Ring frames must match options.clock.capacity_frames. No implicit format, device or output routing changes; both device rates are verified after building. Mismatch drops both streams; streams start only on play().
- open_
duplex - Prepare/open matching-rate f32 effect capture/playback with explicit devices. Both rates are verified after building; mismatch drops both streams. No hidden default fallback, loopback routing, resampling or automatic recovery.
- open_
input - Open explicitly configured f32 capture; backend format/rate errors propagate.
Post-build rate verification uses the same contract as
crate::open_output. No sample conversion, resampling or automatic device recovery is performed. - open_
output - Open an explicitly configured f32 output stream; unsupported device settings
are returned by CPAL. No implicit sample format conversion or rate fallback.
The device rate is checked after construction; mismatch drops the stream
before returning
OpenError::SampleRateMismatch. A failed rate query also rejects the stream. Seedevice_nominal_sample_ratefor backend limits. Fixed buffer size is a backend request, not a guaranteed callback size. Processors are moved into the callback after preparation. A panic silences output and permanently disables DSP for this stream; reopen to recover. Panic unwinding/handlers are exceptional and have no real-time guarantee. - open_
reclaimable_ clocked_ duplex - Open a matched clocked capture/render pair with original processor ownership. Both device rates are verified after construction, including input after output may have changed a shared device. Mismatch drops the pair. All four callback owners must retire before recovery. No format/device fallback, inferred timestamp alignment or native deadline/support guarantee follows.
- open_
reclaimable_ output - Open explicit f32 output with recoverable processor ownership and a dedicated
control retirement worker. Preflight/spawn failures return the original owner;
backend/rate-query/mismatch failures can return pending ownership. Post-build
rate verification follows
crate::open_output. No implicit rate fallback, scheduling/drift/physical support or teardown deadline is promised. Processing panic permanently silences the data callback and has exceptional runtime cost. - output_
device - Select an enumerated host-local ID, or the current default output device. Returns None when the requested device is unavailable; no silent fallback.
- output_
devices - Enumerate the default host’s output devices and supported configurations. Refresh explicitly after device changes; this does not subscribe to hotplug.
Type Aliases§
- Duplex
Recovery Error - Duplex configuration/selection/backend error; the shared error representation retains its output-origin name for existing callers.
- Duplex
Recovery Status - Duplex alias of the common recovery status; open generations refer to pairs.