Skip to main content

RenderPlan

Struct RenderPlan 

Source
pub struct RenderPlan {
    pub buffer_size: usize,
    pub buffers: Vec<UnsafeCell<Vec<f32>>>,
    pub nodes: Vec<Op>,
    pub indegree: Vec<u32>,
    pub dependents: Vec<Vec<NodeId>>,
    pub sources: Vec<NodeId>,
    pub hw_in_map: Vec<(usize, BufferId)>,
    pub hw_out_map: Vec<(BufferId, usize)>,
    pub port_map: HashMap<usize, BufferId>,
    pub midi_edges: Vec<(NodeId, NodeId)>,
    pub forced: Vec<NodeId>,
}
Expand description

A compiled, immutable render plan. Owns the whole buffer arena.

Fields§

§buffer_size: usize

Samples per port buffer (the driver block size at compile time).

§buffers: Vec<UnsafeCell<Vec<f32>>>

The arena: one buffer per AudioIO port, owned by the plan. Replaces shared mutable buffer wrappers on the real-time path.

Interior mutability is required because workers execute disjoint nodes of the same plan concurrently. Soundness rests on the single-producer-chain invariant enforced by RenderPlan::verify: two nodes that may run concurrently never touch the same buffer, and every buffer access goes through the node currently executing on this thread. This is the one audited unsafe cell of the design.

§nodes: Vec<Op>

Nodes in topological order (producers before consumers).

§indegree: Vec<u32>

indegree[i] = number of nodes that must finish before nodes[i].

§dependents: Vec<Vec<NodeId>>

dependents[i] = nodes that may run once nodes[i] has finished.

§sources: Vec<NodeId>

Nodes with indegree == 0 — the cycle seeds.

§hw_in_map: Vec<(usize, BufferId)>

(hw channel, buffer) — the driver fills these before dispatch.

§hw_out_map: Vec<(BufferId, usize)>

(buffer, hw channel) — the driver drains these after the cycle.

§port_map: HashMap<usize, BufferId>

Arc pointer identity of each AudioIO port → its arena buffer. Transition aid so control code can resolve ports without re-walking.

§midi_edges: Vec<(NodeId, NodeId)>

(writer task, reader task) pairs derived from MIDI connections (Phase 3, see LOCKLESS.md). Event payloads stay in the MIDIIO port buffers; these edges only guarantee that a port’s producer task completes before any task that merges it. Checked by verify().

§forced: Vec<NodeId>

Nodes whose dependencies may never be satisfied (feedback loops). The executor force-completes them after the task timeout, mirroring today’s !progressed fallback in the dynamic scheduler.

Implementations§

Source§

impl RenderPlan

Source

pub unsafe fn buffer_ptr(&self, id: BufferId) -> *mut Vec<f32>

Mutable access to an arena buffer, as a raw pointer.

Returns a pointer rather than a &mut because the aliasing discipline is dynamic (enforced by the plan’s dependency graph, not the borrow checker) — this is the same shape as UnsafeCell::get.

§Safety

The caller must be executing (or have already completed) the unique node chain that writes buffer id in this cycle, per the plan’s single-producer-chain invariant: no other concurrently running node may read or write the same buffer. The returned pointer is valid for the lifetime of the plan.

Source

pub unsafe fn buffer(&self, id: BufferId) -> &[f32]

Read access to an arena buffer.

§Safety

Same discipline as RenderPlan::buffer_ptr: the buffer’s producer chain must have completed, and no concurrent writer may exist.

Source

pub fn buffer_count(&self) -> usize

Number of arena buffers.

Source

pub fn compile( state: &StateSnapshot, hw_inputs: &[Arc<AudioIO>], hw_outputs: &[Arc<AudioIO>], buffer_size: usize, ) -> Self

Compile the current topology (tracks, folders, plugins, port wiring, HW bridges) into an immutable plan. Runs on the control thread; may allocate freely.

Track visit order is sorted by name so plans are deterministic — the legacy scheduler iterated State.tracks in HashMap order.

Source

pub fn verify(&self) -> Result<(), String>

Verify the plan invariants (see the module docs). Called by compile (violations are logged) and by tests. Returns the first violation.

Trait Implementations§

Source§

impl Debug for RenderPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Sync for RenderPlan

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more