pub struct CMClock { /* private fields */ }CMSync only.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 CMClockGetHostTimeClock(). 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).
CMClocks are read-only: they cannot be stopped or started, and the current time cannot be set. A CMClock has one primary function, CMClockGetTime, which tells what time it is now. Additionally, the CMSync infrastructure monitors relative drift between CMClocks.
See also Apple’s documentation
Implementations§
Source§impl CMClock
impl CMClock
Sourcepub unsafe fn host_time_clock() -> CFRetained<CMClock>
pub unsafe fn host_time_clock() -> CFRetained<CMClock>
Returns a reference to the singleton clock logically identified with host time.
On Mac OS X, the host time clock uses mach_absolute_time but returns a value with a large integer timescale (eg, nanoseconds).
Sourcepub unsafe fn convert_host_time_to_system_units(host_time: CMTime) -> u64
Available on crate feature CMTime only.
pub unsafe fn convert_host_time_to_system_units(host_time: CMTime) -> u64
CMTime only.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 unsafe fn make_host_time_from_system_units(host_time: u64) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn make_host_time_from_system_units(host_time: u64) -> CMTime
CMTime only.Converts a host time from native units to CMTime.
The returned value will have a large integer timescale (eg, nanoseconds). This function handles situations where host time’s native units use a non-integer timescale. On Mac OS X, this function converts from the units of mach_absolute_time.
Sourcepub unsafe fn time(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn time(&self) -> CMTime
CMTime only.Retrieves the current time from a clock.
Sourcepub unsafe fn anchor_time(
&self,
clock_time_out: NonNull<CMTime>,
reference_clock_time_out: NonNull<CMTime>,
) -> i32
Available on crate feature CMTime only.
pub unsafe fn anchor_time( &self, clock_time_out: NonNull<CMTime>, reference_clock_time_out: NonNull<CMTime>, ) -> i32
CMTime only.Retrieves the current time from a clock and also the matching time from the clock’s reference clock.
To make practical use of this, you may need to know what the clock’s reference clock is.
§Safety
clock_time_outmust be a valid pointer.reference_clock_time_outmust be a valid pointer.
Sourcepub unsafe fn might_drift(&self, other_clock: &CMClock) -> bool
pub unsafe fn might_drift(&self, other_clock: &CMClock) -> bool
Indicates whether it is possible for two clocks to drift relative to each other.
Sourcepub unsafe fn invalidate(&self)
pub unsafe fn invalidate(&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).
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate feature CMAttachment only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
CMAttachment only.Attempt to downcast the type to that of type T.
This is the reference-variant. Use CFRetained::downcast if you
want to convert a retained type. See also ConcreteType for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
Available on crate feature CMAttachment only.
pub fn retain_count(&self) -> usize
CMAttachment only.Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumbers, small CFStrings etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX in that case.
Trait Implementations§
Source§impl ConcreteType for CMClock
impl ConcreteType for CMClock
Source§impl RefEncode for CMClock
impl RefEncode for CMClock
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for CMClock
impl Type for CMClock
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more