Struct cpal::StreamInstant
source · pub struct StreamInstant { /* private fields */ }
Expand description
A monotonic time instance associated with a stream, retrieved from either:
- A timestamp provided to the stream’s underlying audio data callback or
- The same time source used to generate timestamps for a stream’s underlying audio data callback.
StreamInstant
represents a duration since some unspecified origin occurring either before
or equal to the moment the stream from which it was created begins.
Host StreamInstant
Sources
Host | Source |
---|---|
alsa | snd_pcm_status_get_htstamp |
coreaudio | mach_absolute_time |
wasapi | QueryPerformanceCounter |
asio | timeGetTime |
emscripten | AudioContext.getOutputTimestamp |
Implementations§
source§impl StreamInstant
impl StreamInstant
sourcepub fn duration_since(&self, earlier: &Self) -> Option<Duration>
pub fn duration_since(&self, earlier: &Self) -> Option<Duration>
The amount of time elapsed from another instant to this one.
Returns None
if earlier
is later than self.
sourcepub fn add(&self, duration: Duration) -> Option<Self>
pub fn add(&self, duration: Duration) -> Option<Self>
Returns the instant in time after the given duration has passed.
Returns None
if the resulting instant would exceed the bounds of the underlying data
structure.
sourcepub fn sub(&self, duration: Duration) -> Option<Self>
pub fn sub(&self, duration: Duration) -> Option<Self>
Returns the instant in time one duration
ago.
Returns None
if the resulting instant would underflow. As a result, it is important to
consider that on some platforms the StreamInstant
may begin at 0
from the moment the
source stream is created.
Trait Implementations§
source§impl Clone for StreamInstant
impl Clone for StreamInstant
source§fn clone(&self) -> StreamInstant
fn clone(&self) -> StreamInstant
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StreamInstant
impl Debug for StreamInstant
source§impl Hash for StreamInstant
impl Hash for StreamInstant
source§impl Ord for StreamInstant
impl Ord for StreamInstant
source§fn cmp(&self, other: &StreamInstant) -> Ordering
fn cmp(&self, other: &StreamInstant) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<StreamInstant> for StreamInstant
impl PartialEq<StreamInstant> for StreamInstant
source§fn eq(&self, other: &StreamInstant) -> bool
fn eq(&self, other: &StreamInstant) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<StreamInstant> for StreamInstant
impl PartialOrd<StreamInstant> for StreamInstant
source§fn partial_cmp(&self, other: &StreamInstant) -> Option<Ordering>
fn partial_cmp(&self, other: &StreamInstant) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more