<!--
{
  "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/CMTimebaseAddTimerDispatchSource(_:timerSource:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMTimebaseAddTimerDispatchSource"
  },
  "title" : "CMTimebaseAddTimerDispatchSource(_:timerSource:)"
}
-->

# CMTimebaseAddTimerDispatchSource(_:timerSource:)

Adds the timer dispatch source to the list of timers the timebase manages.

```
func CMTimebaseAddTimerDispatchSource(_ timebase: CMTimebase, timerSource: dispatch_source_t) -> OSStatus
```

## Discussion

You must create the timer source by calling `dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, some_dispatch_queue)` and associate an event handler with it from `dispatch_source_set_event_handler(timerSource, some_handler_block)` or `dispatch_source_set_event_handler_f(timerSource, some_handler_function)`. Call `dispatch_resume(timerSource)` because the system creates dispatch sources in a suspended state.

The timebase retains the timer source, and maintains its start time according to the `CMTime` set using [`CMTimebaseSetTimerDispatchSourceNextFireTime(_:timerSource:fireTime:flags:)`](/documentation/CoreMedia/CMTimebaseSetTimerDispatchSourceNextFireTime(_:timerSource:fireTime:flags:)). Until the first call to [`CMTimebaseSetTimerDispatchSourceNextFireTime(_:timerSource:fireTime:flags:)`](/documentation/CoreMedia/CMTimebaseSetTimerDispatchSourceNextFireTime(_:timerSource:fireTime:flags:)), the system sets the start time to `DISPATCH_TIME_FOREVER`.

For more information on dispatch sources, see [Dispatch Sources](http://developer.apple.com/library/mac/#DOCUMENTATION/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html).

---

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)