pub struct SourcePool { /* private fields */ }Expand description
Backend-agnostic voice-slot policy for a fixed pool of spatial
tracks — pure and unit-tested here so every backend (the built-in
kira one, or a host’s own AudioOut) inherits the same behaviour
(hazard 2: tracks are created up front and reused; a per-shot
allocation storm is the classic mistake). One-shots are stealable
(oldest first) when the pool is full; loops hold their slot until
explicitly stopped.
Implementations§
Source§impl SourcePool
impl SourcePool
Sourcepub fn allocate(
&mut self,
looping: bool,
finished: impl FnMut(usize) -> bool,
) -> Option<(usize, SourceId)>
pub fn allocate( &mut self, looping: bool, finished: impl FnMut(usize) -> bool, ) -> Option<(usize, SourceId)>
Allocate a slot for a new source. finished reports whether the
backend says slot i’s current sound has stopped on its own
(finished one-shots are reclaimed eagerly). Returns
(slot index, fresh id); None only when every slot holds a
loop or a younger one-shot than everything stealable.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SourcePool
impl RefUnwindSafe for SourcePool
impl Send for SourcePool
impl Sync for SourcePool
impl Unpin for SourcePool
impl UnsafeUnpin for SourcePool
impl UnwindSafe for SourcePool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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