StreamWriterState

Struct StreamWriterState 

Source
pub struct StreamWriterState { /* private fields */ }

Implementations§

Source§

impl StreamWriterState

Source

pub fn is_active(&self) -> bool

Returns true if there is there is currently an active stream on this node.

Source

pub fn underflow_occurred(&self) -> bool

Returns true if an underflow occured (due to the output stream running faster than the input stream).

If this happens excessively in Release mode, you may want to consider increasing ResamplingChannelConfig::latency_seconds.

(Calling this will also reset the flag indicating whether an underflow occurred.)

Source

pub fn overflow_occurred(&self) -> bool

Returns true if an overflow occured (due to the input stream running faster than the output stream).

If this happens excessively in Release mode, you may want to consider increasing ResamplingChannelConfig::capacity_seconds. For example, if you are streaming data from a network, you may want to increase the capacity to several seconds.

(Calling this will also reset the flag indicating whether an overflow occurred.)

Source

pub fn available_frames(&self) -> usize

The total number of frames (not samples) that can currently be pushed to the stream.

If there is no active stream, the stream is paused, or the processor end is not ready to receive samples, then this will return 0.

Source

pub fn occupied_seconds(&self) -> Option<f64>

The amount of data in seconds that is currently occupied in the channel.

This value will be in the range [0.0, ResamplingChannelConfig::capacity_seconds].

If there is no active stream, then this will return None.

Source

pub fn num_channels(&self) -> NonZeroChannelCount

The number of channels in this node.

Source

pub fn sample_rate(&self) -> Option<NonZeroU32>

The sample rate of the active stream.

Returns None if there is no active stream.

Source

pub fn start_stream( &mut self, sample_rate: NonZeroU32, output_stream_sample_rate: NonZeroU32, channel_config: ResamplingChannelConfig, ) -> Result<NewInputStreamEvent, ()>

Begin the input audio stream on this node.

The returned event must be sent to the node’s processor for this to take effect.

  • sample_rate - The sample rate of this node.
  • output_stream_sample_rate - The sample rate of the active output audio stream.
  • channel_config - The configuration of the input to output channel.

If there is already an active stream running on this node, then this will return an error.

Source

pub fn push_interleaved(&mut self, data: &[f32]) -> PushStatus

Push the given data in interleaved format.

Returns the number of frames (not samples) that were successfully pushed. If this number is less than the number of frames in data, then it means an overflow has occured.

If there is no active stream, the stream is paused, or the processor end is not ready to receive samples, then no data will be sent and this will return 0.

Source

pub fn push<Vin: AsRef<[f32]>>( &mut self, data: &[Vin], range: Range<usize>, ) -> PushStatus

Push the given data in de-interleaved format.

  • data - The channels of data to push to the channel.
  • range - The range in each slice in input to read data from.

Returns the number of frames (not samples) that were successfully pushed. If this number is less than the number of frames in data, then it means an overflow has occured. b If there is no active stream, the stream is paused, or the processor end is not ready to receive samples, then no data will be sent and this will return 0.

Source

pub fn is_ready(&self) -> bool

Returns true if the processor end of the stream is ready to start receiving data.

Source

pub fn pause_stream(&mut self)

Pause any active audio streams.

Source

pub fn autocorrect_underflows(&mut self) -> Option<usize>

Correct for any underflows.

This returns the number of extra zero frames (samples in a single channel of audio) that were added due to an underflow occurring. If no underflow occured, then None is returned.

Note, this method is already automatically called in StreamWriterState::push and StreamWriterState::push_interleaved.

This will have no effect if ResamplingChannelConfig::underflow_autocorrect_percent_threshold was set to None.

This method is realtime-safe.

Source

pub fn resume(&mut self)

Resume any active audio streams after pausing.

Source

pub fn stop_stream(&mut self)

Source

pub fn handle(&self) -> Mutex<Self>

Trait Implementations§

Source§

impl Clone for StreamWriterState

Source§

fn clone(&self) -> StreamWriterState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for StreamWriterState

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of this value.
Source§

impl<T> ConditionalSend for T
where T: Send,