Trait oboe::AudioStream [−][src]
pub trait AudioStream: AudioStreamSafe { fn close(&mut self) -> Status; fn start_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status; fn stop_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status; fn request_start(&mut self) -> Status; fn request_stop(&mut self) -> Status; fn wait_for_state_change(
&mut self,
input_state: StreamState,
timeout_nanoseconds: i64
) -> Result<StreamState>; fn wait_for_available_frames(
&mut self,
num_frames: i32,
timeout_nanoseconds: i64
) -> Result<i32>; fn open(&mut self) -> Status { ... } fn start(&mut self) -> Status { ... } fn stop(&mut self) -> Status { ... } }
Expand description
Base trait for Oboe audio stream.
Required methods
fn close(&mut self) -> Status
[src]
fn close(&mut self) -> Status
[src]Close the stream and deallocate any resources from the open() call.
fn start_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status
[src]
fn start_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status
[src]Start the stream. This will block until the stream has been started, an error occurs
or timeout_nanoseconds
has been reached.
fn stop_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status
[src]
fn stop_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status
[src]Stop the stream. This will block until the stream has been stopped, an error occurs
or timeoutNanoseconds
has been reached.
fn request_start(&mut self) -> Status
[src]
fn request_start(&mut self) -> Status
[src]Start the stream asynchronously. Returns immediately (does not block). Equivalent to calling
start(0)
.
fn request_stop(&mut self) -> Status
[src]
fn request_stop(&mut self) -> Status
[src]Stop the stream asynchronously. Returns immediately (does not block). Equivalent to calling
stop(0)
.
fn wait_for_state_change(
&mut self,
input_state: StreamState,
timeout_nanoseconds: i64
) -> Result<StreamState>
[src]
fn wait_for_state_change(
&mut self,
input_state: StreamState,
timeout_nanoseconds: i64
) -> Result<StreamState>
[src]Wait until the stream’s current state no longer matches the input state. The input state is passed to avoid race conditions caused by the state changing between calls.
Note that generally applications do not need to call this. It is considered an advanced technique and is mostly used for testing.
const TIMEOUT_NANOS: i64 = 500 * NANOS_PER_MILLISECOND; // arbitrary 1/2 second let mut current_state = stream.get_state(); loop { if let Ok(next_state) = stream.wait_for_state_change(current_state, TIMEOUT_NANOS) { if next_state != StreamState::Paused { current_state = next_state; continue; } } break; }
If the state does not change within the timeout period then it will
return Error::Timeout
. This is true even if timeout_nanoseconds is zero.
fn wait_for_available_frames(
&mut self,
num_frames: i32,
timeout_nanoseconds: i64
) -> Result<i32>
[src]
fn wait_for_available_frames(
&mut self,
num_frames: i32,
timeout_nanoseconds: i64
) -> Result<i32>
[src]Wait until the stream has a minimum amount of data available in its buffer. This can be used with an EXCLUSIVE MMAP input stream to avoid reading data too close to the DSP write position, which may cause glitches.
Provided methods
fn open(&mut self) -> Status
[src]
fn open(&mut self) -> Status
[src]Open a stream based on the current settings.
Note that we do not recommend re-opening a stream that has been closed. TODO Should we prevent re-opening?
Implementors
impl<T: RawAudioStream + RawAudioStreamBase> AudioStream for T
[src]
impl<T: RawAudioStream + RawAudioStreamBase> AudioStream for T
[src]fn open(&mut self) -> Status
[src]
fn close(&mut self) -> Status
[src]
fn start_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status
[src]
fn stop_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status
[src]
fn request_start(&mut self) -> Status
[src]
fn request_stop(&mut self) -> Status
[src]
fn wait_for_state_change(
&mut self,
input_state: StreamState,
timeout_nanoseconds: i64
) -> Result<StreamState>
[src]
&mut self,
input_state: StreamState,
timeout_nanoseconds: i64
) -> Result<StreamState>
fn wait_for_available_frames(
&mut self,
num_frames: i32,
timeout_nanoseconds: i64
) -> Result<i32>
[src]
&mut self,
num_frames: i32,
timeout_nanoseconds: i64
) -> Result<i32>