<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMClock",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@T@CMClockRef"
  },
  "title" : "CMClock"
}
-->

# CMClock

An object that represents a source of time.

```
class CMClock
```

## Overview

A clock represents a source of time information: a piece of hardware that measures the passage of time. One example of a clock is the host time clock, accessible via [`CMClockGetHostTimeClock()`](/documentation/CoreMedia/CMClockGetHostTimeClock()). It measures time using the CPU system clock, which in macOS is `mach_absolute_time()`. Every audio device is also a clock because the audio samples that it outputs or inputs each have a defined duration (for example, 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(_:)`](/documentation/CoreMedia/CMClockGetTime(_:)), which tells what time it is now. Additionally, the `CMSync` infrastructure monitors relative drift between `CMClocks`.

## Topics

### Inspecting a Clock

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

The current time.

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

The Core Foundation identifier that corresponds to the clock structure.

### Stopping a Clock

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

Stops the clock.

### Getting the Host Time

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

The singleton clock that the system identifies as host time.

### Getting Time and Devices

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

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

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

Returns the audio device the clock tracks.

[`setAudioDeviceID(_:)`](/documentation/CoreMedia/CMClock/setAudioDeviceID(_:))

Sets the audio device by using the device identifier.

[`setAudioDeviceUID(_:)`](/documentation/CoreMedia/CMClock/setAudioDeviceUID(_:))

Sets the audio device by using the unique device identifier.

### Determining Time Drift

[`mightDrift(relativeTo:)`](/documentation/CoreMedia/CMClock/mightDrift(relativeTo:))

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

### Converting Time

[`convertHostTimeToSystemUnits(_:)`](/documentation/CoreMedia/CMClock/convertHostTimeToSystemUnits(_:))

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

[`convertSystemUnitsToHostTime(_:)`](/documentation/CoreMedia/CMClock/convertSystemUnitsToHostTime(_:))

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

### Constants

[`CMClock.Error`](/documentation/CoreMedia/CMClock/Error)

Constants that describe clock errors.



---

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)