[−][src]Struct soundio::OutStreamWriter
OutStreamWriter
is passed to the write callback and can be used to write to the stream.
You start by calling begin_write()
then you can write the samples. When the `OutStreamWriter``
is dropped the write is committed. An error at that point is written to the console and ignored.
Methods
impl<'a> OutStreamWriter<'a>
[src]
pub fn begin_write(&mut self, frame_count: usize) -> Result<usize>
[src]
Start a write. You can only call this once per callback otherwise it panics.
frame_count is the number of frames you want to write. It must be between
frame_count_min and frame_count_max or begin_write()
will panic.
It returns the number of frames you must actually write. The returned value will always be less than or equal to the provided value.
Errors
Error::Invalid
frame_count
<= 0frame_count
<frame_count_min
orframe_count
>frame_count_max
- function called too many times without respecting
frame_count_max
Error::Streaming
Error::Underflow
- an underflow caused this call to fail. You might also get anunderflow_callback()
, and you might not get this error code when an underflow occurs. UnlikeError::Streaming
, the outstream is still in a valid state and streaming can continue.Error::IncompatibleDevice
- in rare cases it might just now be discovered that the device uses non-byte-aligned access, in which case this error code is returned.
pub fn end_write(&mut self)
[src]
Commits the write that you began with begin_write()
.
Errors are currently are just printed to the console and ignored.
Errors
Error::Streaming
Error::Underflow
- an underflow caused this call to fail. You might also get anunderflow_callback()
, and you might not get this error code when an underflow occurs. UnlikeError::Streaming
, the outstream is still in a valid state and streaming can continue.
pub fn frame_count_min(&self) -> usize
[src]
Get the minimum frame count that you can call begin_write()
with.
Retreive this value before calling begin_write()
to ensure you read the correct number
of frames.
pub fn frame_count_max(&self) -> usize
[src]
Get the maximum frame count that you can call begin_write()
with.
Retreive this value before calling begin_write()
to ensure you read the correct number
of frames.
pub fn frame_count(&self) -> usize
[src]
Get the actual frame count that you did call begin_write()
with. Panics if you haven't called
begin_write()
yet.
pub fn software_latency(&self) -> f64
[src]
Get latency due to software only, not including hardware.
pub fn channel_count(&self) -> usize
[src]
Return the number of channels in this stream. Guaranteed to be at least 1.
pub fn sample_rate(&self) -> i32
[src]
Get the sample rate in Hertz.
pub fn get_latency(&mut self) -> Result<f64>
[src]
Obtain the total number of seconds that the next frame written after the
last frame written from the write callback will take to become
audible. This includes both software and hardware latency. In other words,
if you call this function directly after dropping the OutStreamWriter
,
this gives you the number of seconds that the next frame written will take
to become audible.
Errors
Error::Streaming
pub fn set_sample<T: Sample>(&mut self, channel: usize, frame: usize, sample: T)
[src]
Set the value of a sample/channel. This panics if the channel
or frame
are
out of range or if you haven't called begin_write()
yet.
If you use a different type from the actual one it will be converted.
Examples
fn write_callback(stream: &mut soundio::OutStreamWriter) { let frame_count_max = stream.frame_count_max(); stream.begin_write(frame_count_max).unwrap(); for c in 0..stream.channel_count() { for f in 0..stream.frame_count() { stream.set_sample::<f32>(c, f, 0.0 as f32); } } }
Trait Implementations
impl<'a> Drop for OutStreamWriter<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for OutStreamWriter<'a>
impl<'a> !Send for OutStreamWriter<'a>
impl<'a> !Sync for OutStreamWriter<'a>
impl<'a> Unpin for OutStreamWriter<'a>
impl<'a> UnwindSafe for OutStreamWriter<'a>
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>,