Skip to main content

Clock

Struct Clock 

Source
pub struct Clock(/* private fields */);
Expand description

A timing source object.

A clock represents a source of time information: generally, a piece of hardware that measures the passage of time. One example of a clock is the host time clock, accessible via cm::Clock::host_time_clock(). It measures time using the CPU system clock, which on Mac OS X is mach_absolute_time(). Every audio device can also be considered a clock since the audio samples that it outputs or inputs each have a defined duration (eg, 1/48000 of a second for 48 kHz audio).

cm::Clocks are read-only: they cannot be stopped or started, and the current time cannot be set. A CMClock has one primary function, cm::Clock::get_time, which tells what time it is now. Additionally, the cm::Sync infrastructure monitors relative drift between cm::Clocks.

Implementations§

Source§

impl Clock

Source

pub fn retained(&self) -> R<Self>

Source§

impl Clock

Source

pub fn get_type_id() -> TypeId

Source

pub fn host_time_clock() -> &'static Clock

Returns a reference to the singleton clock logically identified with host time.

Source

pub fn time(&self) -> Time

Source

pub fn convert_host_time_to_sys_units(host_time: Time) -> u64

Converts a host time from CMTime to the host time’s native units.

This function performs a scale conversion, not a clock conversion. It can be more accurate than CMTimeConvertScale because the system units may have a non-integer timescale. On Mac OS X, this function converts to the units of mach_absolute_time.

Source

pub fn make_host_time_from_sys_units(host_time: u64) -> Time

Converts a host time from native units to cm::Time.

Source

pub fn anchor_time( &self, clock_time_out: &mut Time, ref_clock_time_out: &mut Time, ) -> Result

Source

pub fn might_dirft(&self, other: &Clock) -> bool

Indicates whether it is possible for two clocks to drift relative to each other.

Source

pub fn invalidate(&mut self)

Makes the clock stop functioning.

After invalidation, the clock will return errors from all APIs. This should only be called by the “owner” of the clock, who knows (for example) that some piece of hardware has gone away, and the clock will no longer work (and might even crash).

Source§

impl Clock

Source

pub fn with_default_audio_output() -> Result<R<Self>>

Unified api with iOS

Source

pub fn with_audio_device_uid_in( device_uid: Option<&String>, allocator: Option<&Allocator>, ) -> Result<Option<R<Self>>>

Source

pub fn with_audio_device_uid(device_uid: Option<&String>) -> Result<R<Self>>

Source

pub fn with_audio_device_in( audio_device: Device, allocator: Option<&Allocator>, ) -> Result<Option<R<Self>>>

Source

pub fn with_audio_device(audio_device: Device) -> Result<R<Self>>

Source

pub fn set_audio_device_uid(&mut self, device_uid: Option<&String>) -> Result

Source

pub fn set_audio_device(&mut self, audio_device: Device) -> Result

Source

pub fn audio_device_uid(&self) -> Result<Option<&String>>

Source

pub fn audio_device(&self) -> Result<Device>

Source

pub fn is_tracking_default_device(&self) -> Result<bool>

Methods from Deref<Target = ClockOrTimebase>§

Source

pub fn retained(&self) -> R<Self>

Source

pub fn relative_rate(&self, relative_to: &Self) -> f64

Queries the relative rate of one timebase or clock relative to another timebase or clock.

Source

pub fn relative_rate_and_anchor_time( &self, relative_to: &Self, relative_rate: &mut f64, anchor_time: &mut Time, relative_to_anchor_time: &mut Time, ) -> Result

Queries the relative rate of one timebase or clock relative to another timebase or clock and the times of each timebase or clock at which the relative rate went into effect.

Source

pub fn convert_time_to(&self, time: Time, to: &ClockOrTimebase) -> Time

Converts a time from one timebase or clock to another timebase or clock.

If both have a common source, this calculation is performed purely based on the mathematical rates and offsets in the common tree rooted in that source.
If they have different source clocks (or are both clocks), this calculation also compensates for measured drift between the clocks. To convert to or from host time, pass cm::Clock::host_time_clock() as the appropriate argument.

Source

pub fn might_drift(&self, other: &Self) -> bool

Reports whether it is possible for one timebase/clock to drift relative to the other.

A timebase can drift relative to another if their ultimate source clocks that can drift relative to each other.

Source

pub fn time(&self) -> Time

A helper function to get time from a clock or timebase.

Methods from Deref<Target = Type>§

Source

pub fn get_type_id(&self) -> TypeId

Source

pub unsafe fn as_type_ptr(&self) -> *const c_void

Source

pub fn as_type_ref(&self) -> &Type

Source

pub fn is_tagged_ptr(&self) -> bool

Source

pub fn try_as_number(&self) -> Option<&Number>

Source

pub fn try_as_string(&self) -> Option<&String>

Source

pub fn show(&self)

Source

pub fn allocator(&self) -> Option<&Allocator>

Source

pub fn retain_count(&self) -> isize

Source

pub fn equal(&self, other: &Type) -> bool

use cidre::cf;

let n1 = cf::Number::from_i8(4);
let n2 = cf::Number::from_i32(4);
let n3 = cf::Number::from_f64(3.0);

assert!(n1.equal(&n2));
assert_eq!(false, n1.equal(&n3));
Source

pub fn hash(&self) -> usize

Source

pub fn desc(&self) -> R<String>

Trait Implementations§

Source§

impl AsRef<Type> for Clock

Source§

fn as_ref(&self) -> &Type

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Clock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Clock

Source§

type Target = ClockOrTimebase

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Clock

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Release for Clock

Source§

unsafe fn release(&mut self)

Source§

impl Retain for Clock

Source§

fn retained(&self) -> R<Self>

Source§

impl Send for Clock

Auto Trait Implementations§

§

impl !Sync for Clock

§

impl Freeze for Clock

§

impl RefUnwindSafe for Clock

§

impl Unpin for Clock

§

impl UnsafeUnpin for Clock

§

impl UnwindSafe for Clock

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.