<!--
{
  "documentType" : "article",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/cmclock-api",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "CMClock"
}
-->

# CMClock

A reference clock you use to synchronize applications and devices.

## Discussion

`The CMSync` API provides a reference clock that you use to synchronize applications and devices. This API also provides functions to monitor relative drift between `CMClocks` and functions that are associated with timer services.

## Topics

### Accessing the Host Clock

[`func CMClockGetHostTimeClock() -> CMClock`](/documentation/CoreMedia/CMClockGetHostTimeClock())

Returns a reference to the singleton clock that reflects the host time.

### Stopping the Clock

[`func CMClockInvalidate(CMClock)`](/documentation/CoreMedia/CMClockInvalidate(_:))

Stops the clock.

### Accessing and Converting Time

[`func CMClockGetTime(CMClock) -> CMTime`](/documentation/CoreMedia/CMClockGetTime(_:))

Returns the current time from a clock.

[`func CMClockGetAnchorTime(CMClock, clockTimeOut: UnsafeMutablePointer<CMTime>, referenceClockTimeOut: UnsafeMutablePointer<CMTime>) -> OSStatus`](/documentation/CoreMedia/CMClockGetAnchorTime(_:clockTimeOut:referenceClockTimeOut:))

Returns the current time from a clock and the matching time from the clock’s reference clock.

[`func CMClockConvertHostTimeToSystemUnits(CMTime) -> UInt64`](/documentation/CoreMedia/CMClockConvertHostTimeToSystemUnits(_:))

Converts a host time from a core media time structure to the host time’s native units.

[`func CMClockMakeHostTimeFromSystemUnits(UInt64) -> CMTime`](/documentation/CoreMedia/CMClockMakeHostTimeFromSystemUnits(_:))

Converts a host time from native units to a core media time structure.

### Getting and Syncing Time

[`func CMSyncGetTime(CMClockOrTimebase) -> CMTime`](/documentation/CoreMedia/CMSyncGetTime(_:))

Returns the time from a clock or timebase.

[`func CMSyncGetRelativeRate(CMClockOrTimebase, relativeTo: CMClockOrTimebase) -> Float64`](/documentation/CoreMedia/CMSyncGetRelativeRate(_:relativeTo:))

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

[`func CMSyncGetRelativeRateAndAnchorTime(CMClockOrTimebase, relativeTo: CMClockOrTimebase, relativeRateOut: UnsafeMutablePointer<Float64>?, anchorTimeOut: UnsafeMutablePointer<CMTime>?, relativeToAnchorTimeOut: UnsafeMutablePointer<CMTime>?) -> OSStatus`](/documentation/CoreMedia/CMSyncGetRelativeRateAndAnchorTime(_:relativeTo:relativeRateOut:anchorTimeOut:relativeToAnchorTimeOut:))

Returns 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.

[`func CMSyncConvertTime(CMTime, from: CMClockOrTimebase, to: CMClockOrTimebase) -> CMTime`](/documentation/CoreMedia/CMSyncConvertTime(_:from:to:))

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

### Determining Clock Drift

[`func CMClockMightDrift(CMClock, otherClock: CMClock) -> Bool`](/documentation/CoreMedia/CMClockMightDrift(_:otherClock:))

Returns a Boolean value that indicates whether it’s possible for two clocks to drift relative to each other.

[`func CMSyncMightDrift(CMClockOrTimebase, CMClockOrTimebase) -> Bool`](/documentation/CoreMedia/CMSyncMightDrift(_:_:))

Returns a Boolean value that indicates whether it’s possible for one timebase or clock to drift relative to the other.

### Data Types

[`class CMClock`](/documentation/CoreMedia/CMClock)

An object that represents a source of time.

[`typealias CMClockOrTimebase`](/documentation/CoreMedia/CMClockOrTimebase)

A type you use in argument lists and function results to indicate that you can pass either a clock or timebase.

[`func CMClockGetTypeID() -> CFTypeID`](/documentation/CoreMedia/CMClockGetTypeID())

Returns the core foundation type identifier of a clock type.

### Constants

[CMClock Error Codes](/documentation/CoreMedia/cmclock-error-codes)

Constants that represent the errors in Core Media clock operations.

[CMTimebase Error Codes](/documentation/CoreMedia/cmtimebase-errors)

Constants that represent errors in Core Media timebase operations.

[CMSync error codes](/documentation/CoreMedia/cmsync-error-codes)

Constants that represent error codes Core Media sync operations return.

[Timebase Notifications](/documentation/CoreMedia/timebase-notifications)

Keys that represent timebase notifications.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)