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
impl Clock
pub fn get_type_id() -> TypeId
Sourcepub fn host_time_clock() -> &'static Clock
pub fn host_time_clock() -> &'static Clock
Returns a reference to the singleton clock logically identified with host time.
pub fn time(&self) -> Time
Sourcepub fn convert_host_time_to_sys_units(host_time: Time) -> u64
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.
Sourcepub fn make_host_time_from_sys_units(host_time: u64) -> Time
pub fn make_host_time_from_sys_units(host_time: u64) -> Time
Converts a host time from native units to cm::Time.
pub fn anchor_time( &self, clock_time_out: &mut Time, ref_clock_time_out: &mut Time, ) -> Result
Sourcepub fn might_dirft(&self, other: &Clock) -> bool
pub fn might_dirft(&self, other: &Clock) -> bool
Indicates whether it is possible for two clocks to drift relative to each other.
Sourcepub fn invalidate(&mut self)
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
impl Clock
Sourcepub fn with_default_audio_output() -> Result<R<Self>>
pub fn with_default_audio_output() -> Result<R<Self>>
Unified api with iOS
pub fn with_audio_device_uid_in( device_uid: Option<&String>, allocator: Option<&Allocator>, ) -> Result<Option<R<Self>>>
pub fn with_audio_device_uid(device_uid: Option<&String>) -> Result<R<Self>>
pub fn with_audio_device_in( audio_device: Device, allocator: Option<&Allocator>, ) -> Result<Option<R<Self>>>
pub fn with_audio_device(audio_device: Device) -> Result<R<Self>>
pub fn set_audio_device_uid(&mut self, device_uid: Option<&String>) -> Result
pub fn set_audio_device(&mut self, audio_device: Device) -> Result
pub fn audio_device_uid(&self) -> Result<Option<&String>>
pub fn audio_device(&self) -> Result<Device>
pub fn is_tracking_default_device(&self) -> Result<bool>
Methods from Deref<Target = ClockOrTimebase>§
pub fn retained(&self) -> R<Self>
Sourcepub fn relative_rate(&self, relative_to: &Self) -> f64
pub fn relative_rate(&self, relative_to: &Self) -> f64
Queries the relative rate of one timebase or clock relative to another timebase or clock.
Sourcepub 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
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.
Sourcepub fn convert_time_to(&self, time: Time, to: &ClockOrTimebase) -> Time
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.
Sourcepub fn might_drift(&self, other: &Self) -> bool
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.
Methods from Deref<Target = Type>§
pub fn get_type_id(&self) -> TypeId
pub unsafe fn as_type_ptr(&self) -> *const c_void
pub fn as_type_ref(&self) -> &Type
pub fn is_tagged_ptr(&self) -> bool
pub fn try_as_number(&self) -> Option<&Number>
pub fn try_as_string(&self) -> Option<&String>
pub fn show(&self)
pub fn allocator(&self) -> Option<&Allocator>
pub fn retain_count(&self) -> isize
Sourcepub fn equal(&self, other: &Type) -> bool
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));