Explicit audio-owner sessions¶
Processor::start_audio/stop_audio are optional prepared session hooks with
no-op defaults. Ordinary portable graph process behavior stays unchanged;
existing format/device adapters do not automatically opt into these hooks.
Nodes requiring split native thread lifecycle use an explicit graph session.
Control prepares the graph, transfers it to its audio owner, then calls
Graph::start_audio or DynamicGraph::start_audio on that owner. The returned
borrowed session is non-Send/non-Sync and exposes rendering/reset/timing queries,
without exposing the underlying mutable graph. Finish/drop it on that owner
before transferring the prepared graph back for control deactivation/destruction.
Do not forget/leak the guard. Active preparation rejects AudioSessionActive;
deactivation requires the session to have ended.
Nodes start in topological order. A returned start failure leaves the failing node stopped, rolls earlier successful nodes back in reverse order and faults the graph until reset. A local rollback guard also stops earlier nodes during unwinding start panics; the failing hook retains its own rollback obligation. Successful session finish stops nodes in reverse order, retaining preparation and histories. Default portable hooks leave existing render/reset results unchanged. Hook implementations obey prepared callback allocation/locking/I/O contracts; panic containment remains caller ABI policy and has no real-time guarantee.
While a dynamic session is active, accepted candidates start on the same owner
before old nodes stop. A failed candidate start is returned through retirement
with GraphSwapStatus::StartRejected, and the old graph keeps rendering. Full
retirement or invalid outer blocks prevent candidate execution. Old nodes stop
before their graph enters control retirement; control still deactivates/destroys
it. Session finish stops only the currently selected graph. Proposals must be
prepared, fault-free and outside an audio session, with existing exact config/
latency checks. No crossfade, tail drain, state migration or implicit reprepare.
Thread/callback fixtures check start rollback (error and unwind), reverse stop, invalid input, candidate failure/backpressure, retained rendering, control-only deactivation/destruction and heap-free rendering/swaps. Native f64 default hooks retain sub-f32 precision and large values. This supplies lifecycle mechanics; it does not itself map native CLAP ports/events, schedule a device or prove platform/deadline support. A dedicated audio worker can hold a session; a native callback requiring Send cannot capture this non-Send guard. See decision 0107.
The native preparation builder also selects one explicit note/MIDI input index and dialect, sharing bounded slots with optional global parameters. Whole input validates before native calls, preserving offsets/order; zero-frame performance rejects before parameter flush. CLAP notes use wildcard IDs, MIDI/MPE quantize velocity, and MIDI2 preserves framed UMP without translation. See the selected-input guide and decision 0114 for limits and probes.
A separate selected native performance-output profile shares bounded output storage with mapped parameters. It preserves representable CLAP notes, short MIDI/MPE or framed UMP through explicit graph edges; unsupported targets filter, and selected malformed output clears audio/events with nonrollback failure. See the output guide and decision 0115.
Hosted native graphs expose guarded main-thread editor creation through their retained control. The separately owned audio node may run, while exclusive editor borrowing prevents control retirement until GUI destruction. Core callbacks can be serviced once per consumer main tick through the guard. See the hosting guide and decision 0116.
The optional device crate has an explicit buffered f32 graph-worker output bridge. A non-Send graph session stays on its worker while a separate device processor consumes a prepared queue; stop/join precedes main graph/native retirement. No device clock or callback-thread teardown is inferred. See the device guide and decision 0117.