[−][src]Struct portaudio_rs::stream::Stream
An object for an PortAudio stream
Streams can have an input type I and output type O.
Methods
impl<'a, T: SampleType> Stream<'a, T, T>
[src]
pub fn open_default(
num_input_channels: u32,
num_output_channels: u32,
sample_rate: f64,
frames_per_buffer: u64,
callback: Option<Box<StreamCallback<'a, T, T>>>
) -> Result<Stream<'a, T, T>, PaError>
[src]
num_input_channels: u32,
num_output_channels: u32,
sample_rate: f64,
frames_per_buffer: u64,
callback: Option<Box<StreamCallback<'a, T, T>>>
) -> Result<Stream<'a, T, T>, PaError>
Constructs a stream using the default input and output devices
Arguments
- num_input_channels: Desired number of input channels
- num_output_channels: Desired number of output channels
- sample_rate: Sample rate of the stream
- frames_per_buffer: Number of frames per buffer. Use FRAMES_PER_BUFFER_UNSPECIFIED to let portaudio determine the optimal number.
- callback: Some(callback) which PortAudio will call to read/write the buffers, or None when using the read and write methods
impl<'a, I: SampleType, O: SampleType> Stream<'a, I, O>
[src]
pub fn open(
input: Option<StreamParameters<I>>,
output: Option<StreamParameters<O>>,
sample_rate: f64,
frames_per_buffer: u64,
flags: StreamFlags,
callback: Option<Box<StreamCallback<'a, I, O>>>
) -> Result<Stream<'a, I, O>, PaError>
[src]
input: Option<StreamParameters<I>>,
output: Option<StreamParameters<O>>,
sample_rate: f64,
frames_per_buffer: u64,
flags: StreamFlags,
callback: Option<Box<StreamCallback<'a, I, O>>>
) -> Result<Stream<'a, I, O>, PaError>
Constructs a stream with the desired input and output specifications
Arguments
- input: Specification for the input channel, or None for an output-only stream
- output: Specification for the output channel, or None for an input-only stream
- sample_rate: Sample rate of the stream
- frames_per_buffer: Number of frames per buffer. Use FRAMES_PER_BUFFER_UNSPECIFIED to let portaudio determine the optimal number.
- flags: Additional flags for the behaviour of the stream
- callback: Some(callback) which PortAudio will call to read/write the buffers, or None when using the read and write methods
pub fn start(&self) -> PaResult
[src]
Starts the stream
pub fn stop(&self) -> PaResult
[src]
Stops the stream. It will block untill all audio has finished playing
pub fn abort(&self) -> PaResult
[src]
Stop stream immediately without waiting for the buffers to complete
pub fn is_stopped(&self) -> Result<bool, PaError>
[src]
Returns wether the stream is stopped
pub fn is_active(&self) -> Result<bool, PaError>
[src]
Returns wether the stream is active
pub fn num_read_available(&self) -> Result<u32, PaError>
[src]
Get the number of frames that can be read from the stream without waiting
pub fn num_write_available(&self) -> Result<u32, PaError>
[src]
Get the number of frames that can be written to the stream without waiting
pub fn write(&self, buffer: &[O]) -> PaResult
[src]
Write the given buffer to the stream. This function blocks
Possible Error codes:
CanNotWriteToAnInputOnlyStream
: when num_output_channels = 0BadBufferPtr
: when buffer.len() is not a multiple of num_output_channels- Some other error given by PortAudio
pub fn read(&self, frames: u32) -> Result<Vec<I>, PaError>
[src]
Reads the requested number of frames from the input devices. This function blocks until the whole buffer has been filled.
Will return CanNotReadFromAnOutputOnlyStream
if num_input_channels = 0.
pub fn cpu_load(&self) -> f64
[src]
Returns the cpu load the stream callback consumes. This will return 0.0 if the stream uses blocking read/write, or if an error occured.
pub fn time(&self) -> Duration
[src]
Get the current timestamp of the stream
pub fn info(&self) -> Option<StreamInfo>
[src]
Get the actual latencies and sample rate
Returns None when the stream is invalid or an error occured
pub fn set_finished_callback(
&mut self,
finished_callback: Box<StreamFinishedCallback<'a>>
) -> PaResult
[src]
&mut self,
finished_callback: Box<StreamFinishedCallback<'a>>
) -> PaResult
Set a callback which is to be called when the StreamCallback finishes
pub fn unset_finished_callback(&mut self) -> PaResult
[src]
Remove any previously attached finish callback
Trait Implementations
impl<'a, I: SampleType, O: SampleType> Drop for Stream<'a, I, O>
[src]
Auto Trait Implementations
impl<'a, I, O> !RefUnwindSafe for Stream<'a, I, O>
impl<'a, I, O> !Send for Stream<'a, I, O>
impl<'a, I, O> !Sync for Stream<'a, I, O>
impl<'a, I, O> Unpin for Stream<'a, I, O>
impl<'a, I, O> !UnwindSafe for Stream<'a, I, O>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,