objc2_core_media/generated/
CMSync.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11use objc2_core_foundation::*;
12
13use crate::*;
14
15/// A timing source object.
16///
17/// A clock represents a source of time information: generally, a piece of hardware that measures the passage of time.
18/// One example of a clock is the host time clock, accessible via CMClockGetHostTimeClock().
19/// It measures time using the CPU system clock, which on Mac OS X is mach_absolute_time().
20/// Every audio device can also be considered a clock since the audio samples that it outputs or inputs each have a
21/// defined duration (eg, 1/48000 of a second for 48 kHz audio).
22///
23/// CMClocks are read-only: they cannot be stopped or started, and the current time cannot be set.
24/// A CMClock has one primary function, CMClockGetTime, which tells what time it is now.
25/// Additionally, the CMSync infrastructure monitors relative drift between CMClocks.
26///
27/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmclock?language=objc)
28#[doc(alias = "CMClockRef")]
29#[repr(C)]
30pub struct CMClock {
31    inner: [u8; 0],
32    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
33}
34
35cf_type!(
36    unsafe impl CMClock {}
37);
38#[cfg(feature = "objc2")]
39cf_objc2_type!(
40    unsafe impl RefEncode<"OpaqueCMClock"> for CMClock {}
41);
42
43unsafe impl Send for CMClock {}
44
45unsafe impl Sync for CMClock {}
46
47/// Models a timeline under application control.
48///
49/// A timebase represents a timeline that clients can control by setting the rate and time.
50/// Each timebase has either a source clock or a source timebase (previously referred to as a master clock or master timebase).
51/// The rate of the timebase is expressed relative to its source.
52/// When a timebase has rate 0.0, its time is fixed and does not change as its source's time changes.
53/// When a timebase has rate 1.0, its time increases one second as its source's time increases by one second.
54/// When a timebase has rate 2.0, its time increases two seconds as its source's time increases by one second.
55/// When a timebase has rate -1.0, its time decreases one second as its source's time increases by one second.
56///
57/// If a timebase has a source timebase, the source timebase's rate is a factor in determining the timebase's effective rate.
58/// In fact, a timebase's effective rate is defined as the product of its rate, its source timebase's rate,
59/// its source timebase's source timebase's rate, and so on up to the ultimate source clock.  This is the rate at which
60/// the timebase's time changes relative to the ultimate source clock.
61///
62/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmtimebase?language=objc)
63#[doc(alias = "CMTimebaseRef")]
64#[repr(C)]
65pub struct CMTimebase {
66    inner: [u8; 0],
67    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
68}
69
70cf_type!(
71    unsafe impl CMTimebase {}
72);
73#[cfg(feature = "objc2")]
74cf_objc2_type!(
75    unsafe impl RefEncode<"OpaqueCMTimebase"> for CMTimebase {}
76);
77
78unsafe impl Send for CMTimebase {}
79
80unsafe impl Sync for CMTimebase {}
81
82/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmclockortimebase?language=objc)
83#[doc(alias = "CMClockOrTimebaseRef")]
84pub type CMClockOrTimebase = CFType;
85
86/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmclockerror_missingrequiredparameter?language=objc)
87pub const kCMClockError_MissingRequiredParameter: OSStatus = -12745;
88/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmclockerror_invalidparameter?language=objc)
89pub const kCMClockError_InvalidParameter: OSStatus = -12746;
90/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmclockerror_allocationfailed?language=objc)
91pub const kCMClockError_AllocationFailed: OSStatus = -12747;
92/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmclockerror_unsupportedoperation?language=objc)
93pub const kCMClockError_UnsupportedOperation: OSStatus = -12756;
94
95/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebaseerror_missingrequiredparameter?language=objc)
96pub const kCMTimebaseError_MissingRequiredParameter: OSStatus = -12748;
97/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebaseerror_invalidparameter?language=objc)
98pub const kCMTimebaseError_InvalidParameter: OSStatus = -12749;
99/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebaseerror_allocationfailed?language=objc)
100pub const kCMTimebaseError_AllocationFailed: OSStatus = -12750;
101/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebaseerror_timerintervaltooshort?language=objc)
102pub const kCMTimebaseError_TimerIntervalTooShort: OSStatus = -12751;
103/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebaseerror_readonly?language=objc)
104pub const kCMTimebaseError_ReadOnly: OSStatus = -12757;
105
106/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsyncerror_missingrequiredparameter?language=objc)
107pub const kCMSyncError_MissingRequiredParameter: OSStatus = -12752;
108/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsyncerror_invalidparameter?language=objc)
109pub const kCMSyncError_InvalidParameter: OSStatus = -12753;
110/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsyncerror_allocationfailed?language=objc)
111pub const kCMSyncError_AllocationFailed: OSStatus = -12754;
112/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsyncerror_ratemustbenonzero?language=objc)
113pub const kCMSyncError_RateMustBeNonZero: OSStatus = -12755;
114
115unsafe impl ConcreteType for CMClock {
116    /// Returns the CFTypeID for CMClock.
117    #[doc(alias = "CMClockGetTypeID")]
118    #[inline]
119    fn type_id() -> CFTypeID {
120        extern "C-unwind" {
121            fn CMClockGetTypeID() -> CFTypeID;
122        }
123        unsafe { CMClockGetTypeID() }
124    }
125}
126
127impl CMClock {
128    /// Returns a reference to the singleton clock logically identified with host time.
129    ///
130    /// On Mac OS X, the host time clock uses mach_absolute_time but returns a value
131    /// with a large integer timescale (eg, nanoseconds).
132    #[doc(alias = "CMClockGetHostTimeClock")]
133    #[inline]
134    pub unsafe fn host_time_clock() -> CFRetained<CMClock> {
135        extern "C-unwind" {
136            fn CMClockGetHostTimeClock() -> Option<NonNull<CMClock>>;
137        }
138        let ret = unsafe { CMClockGetHostTimeClock() };
139        let ret =
140            ret.expect("function was marked as returning non-null, but actually returned NULL");
141        unsafe { CFRetained::retain(ret) }
142    }
143
144    /// Converts a host time from CMTime to the host time's native units.
145    ///
146    /// This function performs a scale conversion, not a clock conversion.
147    /// It can be more accurate than CMTimeConvertScale because the system units may
148    /// have a non-integer timescale.
149    /// On Mac OS X, this function converts to the units of mach_absolute_time.
150    #[doc(alias = "CMClockConvertHostTimeToSystemUnits")]
151    #[cfg(feature = "CMTime")]
152    #[inline]
153    pub unsafe fn convert_host_time_to_system_units(host_time: CMTime) -> u64 {
154        extern "C-unwind" {
155            fn CMClockConvertHostTimeToSystemUnits(host_time: CMTime) -> u64;
156        }
157        unsafe { CMClockConvertHostTimeToSystemUnits(host_time) }
158    }
159
160    /// Converts a host time from native units to CMTime.
161    ///
162    /// The returned value will have a large integer timescale (eg, nanoseconds).
163    /// This function handles situations where host time's native units use a
164    /// non-integer timescale.
165    /// On Mac OS X, this function converts from the units of mach_absolute_time.
166    #[doc(alias = "CMClockMakeHostTimeFromSystemUnits")]
167    #[cfg(feature = "CMTime")]
168    #[inline]
169    pub unsafe fn make_host_time_from_system_units(host_time: u64) -> CMTime {
170        extern "C-unwind" {
171            fn CMClockMakeHostTimeFromSystemUnits(host_time: u64) -> CMTime;
172        }
173        unsafe { CMClockMakeHostTimeFromSystemUnits(host_time) }
174    }
175
176    /// Retrieves the current time from a clock.
177    #[doc(alias = "CMClockGetTime")]
178    #[cfg(feature = "CMTime")]
179    #[inline]
180    pub unsafe fn time(&self) -> CMTime {
181        extern "C-unwind" {
182            fn CMClockGetTime(clock: &CMClock) -> CMTime;
183        }
184        unsafe { CMClockGetTime(self) }
185    }
186
187    /// Retrieves the current time from a clock and also the matching time from the clock's reference clock.
188    ///
189    /// To make practical use of this, you may need to know what the clock's reference clock is.
190    ///
191    /// # Safety
192    ///
193    /// - `clock_time_out` must be a valid pointer.
194    /// - `reference_clock_time_out` must be a valid pointer.
195    #[doc(alias = "CMClockGetAnchorTime")]
196    #[cfg(feature = "CMTime")]
197    #[inline]
198    pub unsafe fn anchor_time(
199        &self,
200        clock_time_out: NonNull<CMTime>,
201        reference_clock_time_out: NonNull<CMTime>,
202    ) -> OSStatus {
203        extern "C-unwind" {
204            fn CMClockGetAnchorTime(
205                clock: &CMClock,
206                clock_time_out: NonNull<CMTime>,
207                reference_clock_time_out: NonNull<CMTime>,
208            ) -> OSStatus;
209        }
210        unsafe { CMClockGetAnchorTime(self, clock_time_out, reference_clock_time_out) }
211    }
212
213    /// Indicates whether it is possible for two clocks to drift relative to each other.
214    #[doc(alias = "CMClockMightDrift")]
215    #[inline]
216    pub unsafe fn might_drift(&self, other_clock: &CMClock) -> bool {
217        extern "C-unwind" {
218            fn CMClockMightDrift(clock: &CMClock, other_clock: &CMClock) -> Boolean;
219        }
220        let ret = unsafe { CMClockMightDrift(self, other_clock) };
221        ret != 0
222    }
223
224    /// Makes the clock stop functioning.
225    ///
226    /// After invalidation, the clock will return errors from all APIs.
227    /// This should only be called by the "owner" of the clock, who knows (for example) that some piece of hardware
228    /// has gone away, and the clock will no longer work (and might even crash).
229    #[doc(alias = "CMClockInvalidate")]
230    #[inline]
231    pub unsafe fn invalidate(&self) {
232        extern "C-unwind" {
233            fn CMClockInvalidate(clock: &CMClock);
234        }
235        unsafe { CMClockInvalidate(self) }
236    }
237}
238
239unsafe impl ConcreteType for CMTimebase {
240    /// Returns the CFTypeID for CMTimebase.
241    #[doc(alias = "CMTimebaseGetTypeID")]
242    #[inline]
243    fn type_id() -> CFTypeID {
244        extern "C-unwind" {
245            fn CMTimebaseGetTypeID() -> CFTypeID;
246        }
247        unsafe { CMTimebaseGetTypeID() }
248    }
249}
250
251impl CMTimebase {
252    /// # Safety
253    ///
254    /// `timebase_out` must be a valid pointer.
255    #[doc(alias = "CMTimebaseCreateWithMasterClock")]
256    #[deprecated]
257    #[inline]
258    pub unsafe fn create_with_master_clock(
259        allocator: Option<&CFAllocator>,
260        master_clock: &CMClock,
261        timebase_out: NonNull<*mut CMTimebase>,
262    ) -> OSStatus {
263        extern "C-unwind" {
264            fn CMTimebaseCreateWithMasterClock(
265                allocator: Option<&CFAllocator>,
266                master_clock: &CMClock,
267                timebase_out: NonNull<*mut CMTimebase>,
268            ) -> OSStatus;
269        }
270        unsafe { CMTimebaseCreateWithMasterClock(allocator, master_clock, timebase_out) }
271    }
272
273    // TODO: pub fn CMTimebaseCreateWithSourceClock(allocator: Option<&CFAllocator>,source_clock: &CMClock,timebase_out: NonNull<*mut CMTimebase>,) -> OSStatus;
274
275    /// # Safety
276    ///
277    /// `timebase_out` must be a valid pointer.
278    #[doc(alias = "CMTimebaseCreateWithMasterTimebase")]
279    #[deprecated]
280    #[inline]
281    pub unsafe fn create_with_master_timebase(
282        allocator: Option<&CFAllocator>,
283        master_timebase: &CMTimebase,
284        timebase_out: NonNull<*mut CMTimebase>,
285    ) -> OSStatus {
286        extern "C-unwind" {
287            fn CMTimebaseCreateWithMasterTimebase(
288                allocator: Option<&CFAllocator>,
289                master_timebase: &CMTimebase,
290                timebase_out: NonNull<*mut CMTimebase>,
291            ) -> OSStatus;
292        }
293        unsafe { CMTimebaseCreateWithMasterTimebase(allocator, master_timebase, timebase_out) }
294    }
295
296    // TODO: pub fn CMTimebaseCreateWithSourceTimebase(allocator: Option<&CFAllocator>,source_timebase: &CMTimebase,timebase_out: NonNull<*mut CMTimebase>,) -> OSStatus;
297
298    #[doc(alias = "CMTimebaseCopyMasterTimebase")]
299    #[deprecated]
300    #[inline]
301    pub unsafe fn master_timebase(&self) -> Option<CFRetained<CMTimebase>> {
302        extern "C-unwind" {
303            fn CMTimebaseCopyMasterTimebase(timebase: &CMTimebase) -> Option<NonNull<CMTimebase>>;
304        }
305        let ret = unsafe { CMTimebaseCopyMasterTimebase(self) };
306        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
307    }
308
309    // TODO: pub fn CMTimebaseCopySourceTimebase(timebase: &CMTimebase,)-> Option<NonNull<CMTimebase>>;
310
311    #[doc(alias = "CMTimebaseCopyMasterClock")]
312    #[deprecated]
313    #[inline]
314    pub unsafe fn master_clock(&self) -> Option<CFRetained<CMClock>> {
315        extern "C-unwind" {
316            fn CMTimebaseCopyMasterClock(timebase: &CMTimebase) -> Option<NonNull<CMClock>>;
317        }
318        let ret = unsafe { CMTimebaseCopyMasterClock(self) };
319        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
320    }
321
322    // TODO: pub fn CMTimebaseCopySourceClock(timebase: &CMTimebase,)-> Option<NonNull<CMClock>>;
323
324    #[doc(alias = "CMTimebaseCopyMaster")]
325    #[deprecated]
326    #[inline]
327    pub unsafe fn master(&self) -> CFRetained<CMClockOrTimebase> {
328        extern "C-unwind" {
329            fn CMTimebaseCopyMaster(timebase: &CMTimebase) -> Option<NonNull<CMClockOrTimebase>>;
330        }
331        let ret = unsafe { CMTimebaseCopyMaster(self) };
332        let ret =
333            ret.expect("function was marked as returning non-null, but actually returned NULL");
334        unsafe { CFRetained::from_raw(ret) }
335    }
336
337    // TODO: pub fn CMTimebaseCopySource(timebase: &CMTimebase,)-> Option<NonNull<CMClockOrTimebase>>;
338
339    #[doc(alias = "CMTimebaseCopyUltimateMasterClock")]
340    #[deprecated]
341    #[inline]
342    pub unsafe fn ultimate_master_clock(&self) -> CFRetained<CMClock> {
343        extern "C-unwind" {
344            fn CMTimebaseCopyUltimateMasterClock(timebase: &CMTimebase)
345                -> Option<NonNull<CMClock>>;
346        }
347        let ret = unsafe { CMTimebaseCopyUltimateMasterClock(self) };
348        let ret =
349            ret.expect("function was marked as returning non-null, but actually returned NULL");
350        unsafe { CFRetained::from_raw(ret) }
351    }
352
353    // TODO: pub fn CMTimebaseCopyUltimateSourceClock(timebase: &CMTimebase,)-> Option<NonNull<CMClock>>;
354
355    /// Returns the immediate source timebase of a timebase.
356    ///
357    /// Returns NULL if the timebase actually has a source clock instead of a source timebase.
358    /// Please use CMTimebaseCopySourceTimebase instead.
359    #[doc(alias = "CMTimebaseGetMasterTimebase")]
360    #[deprecated]
361    #[inline]
362    pub unsafe fn get_master_timebase(&self) -> Option<CFRetained<CMTimebase>> {
363        extern "C-unwind" {
364            fn CMTimebaseGetMasterTimebase(timebase: &CMTimebase) -> Option<NonNull<CMTimebase>>;
365        }
366        let ret = unsafe { CMTimebaseGetMasterTimebase(self) };
367        ret.map(|ret| unsafe { CFRetained::retain(ret) })
368    }
369
370    /// Returns the immediate source clock of a timebase.
371    ///
372    /// Returns NULL if the timebase actually has a source timebase instead of a source clock.
373    /// Please use CMTimebaseCopySourceClock instead.
374    #[doc(alias = "CMTimebaseGetMasterClock")]
375    #[deprecated]
376    #[inline]
377    pub unsafe fn get_master_clock(&self) -> Option<CFRetained<CMClock>> {
378        extern "C-unwind" {
379            fn CMTimebaseGetMasterClock(timebase: &CMTimebase) -> Option<NonNull<CMClock>>;
380        }
381        let ret = unsafe { CMTimebaseGetMasterClock(self) };
382        ret.map(|ret| unsafe { CFRetained::retain(ret) })
383    }
384
385    /// Returns the immediate source (either timebase or clock) of a timebase.
386    ///
387    /// Only returns NULL if there was an error (such as timebase == NULL).
388    /// Example of use: time = CMSyncGetTime(CMTimebaseGetMaster(timebase));
389    /// Please use CMTimebaseCopySource instead.
390    #[doc(alias = "CMTimebaseGetMaster")]
391    #[deprecated]
392    #[inline]
393    pub unsafe fn get_master(&self) -> Option<CFRetained<CMClockOrTimebase>> {
394        extern "C-unwind" {
395            fn CMTimebaseGetMaster(timebase: &CMTimebase) -> Option<NonNull<CMClockOrTimebase>>;
396        }
397        let ret = unsafe { CMTimebaseGetMaster(self) };
398        ret.map(|ret| unsafe { CFRetained::retain(ret) })
399    }
400
401    /// Returns the source clock that is the source of all of a timebase's source timebases.
402    ///
403    /// Please use CMTimebaseCopyUltimateSourceClock instead.
404    #[doc(alias = "CMTimebaseGetUltimateMasterClock")]
405    #[deprecated]
406    #[inline]
407    pub unsafe fn get_ultimate_master_clock(&self) -> Option<CFRetained<CMClock>> {
408        extern "C-unwind" {
409            fn CMTimebaseGetUltimateMasterClock(timebase: &CMTimebase) -> Option<NonNull<CMClock>>;
410        }
411        let ret = unsafe { CMTimebaseGetUltimateMasterClock(self) };
412        ret.map(|ret| unsafe { CFRetained::retain(ret) })
413    }
414
415    #[doc(alias = "CMTimebaseSetMasterClock")]
416    #[deprecated]
417    #[inline]
418    pub unsafe fn set_master_clock(&self, new_master_clock: &CMClock) -> OSStatus {
419        extern "C-unwind" {
420            fn CMTimebaseSetMasterClock(
421                timebase: &CMTimebase,
422                new_master_clock: &CMClock,
423            ) -> OSStatus;
424        }
425        unsafe { CMTimebaseSetMasterClock(self, new_master_clock) }
426    }
427
428    // TODO: pub fn CMTimebaseSetSourceClock(timebase: &CMTimebase,new_source_clock: &CMClock,) -> OSStatus;
429
430    #[doc(alias = "CMTimebaseSetMasterTimebase")]
431    #[deprecated]
432    #[inline]
433    pub unsafe fn set_master_timebase(&self, new_master_timebase: &CMTimebase) -> OSStatus {
434        extern "C-unwind" {
435            fn CMTimebaseSetMasterTimebase(
436                timebase: &CMTimebase,
437                new_master_timebase: &CMTimebase,
438            ) -> OSStatus;
439        }
440        unsafe { CMTimebaseSetMasterTimebase(self, new_master_timebase) }
441    }
442
443    // TODO: pub fn CMTimebaseSetSourceTimebase(timebase: &CMTimebase,new_source_timebase: &CMTimebase,) -> OSStatus;
444
445    /// Retrieves the current time from a timebase.
446    #[doc(alias = "CMTimebaseGetTime")]
447    #[cfg(feature = "CMTime")]
448    #[inline]
449    pub unsafe fn time(&self) -> CMTime {
450        extern "C-unwind" {
451            fn CMTimebaseGetTime(timebase: &CMTimebase) -> CMTime;
452        }
453        unsafe { CMTimebaseGetTime(self) }
454    }
455
456    /// Retrieves the current time from a timebase in the specified timescale.
457    #[doc(alias = "CMTimebaseGetTimeWithTimeScale")]
458    #[cfg(feature = "CMTime")]
459    #[inline]
460    pub unsafe fn time_with_time_scale(
461        &self,
462        timescale: CMTimeScale,
463        method: CMTimeRoundingMethod,
464    ) -> CMTime {
465        extern "C-unwind" {
466            fn CMTimebaseGetTimeWithTimeScale(
467                timebase: &CMTimebase,
468                timescale: CMTimeScale,
469                method: CMTimeRoundingMethod,
470            ) -> CMTime;
471        }
472        unsafe { CMTimebaseGetTimeWithTimeScale(self, timescale, method) }
473    }
474
475    /// Sets the current time of a timebase.
476    #[doc(alias = "CMTimebaseSetTime")]
477    #[cfg(feature = "CMTime")]
478    #[inline]
479    pub unsafe fn set_time(&self, time: CMTime) -> OSStatus {
480        extern "C-unwind" {
481            fn CMTimebaseSetTime(timebase: &CMTimebase, time: CMTime) -> OSStatus;
482        }
483        unsafe { CMTimebaseSetTime(self, time) }
484    }
485
486    /// Sets the time of a timebase at a particular source time.
487    ///
488    /// CMTimebaseGetTime's results will be interpolated from that anchor time.
489    /// CMTimebaseSetTime(timebase, time) is equivalent to calling
490    /// CMClockOrTimebaseRef source = CMTimebaseCopySource(timebase);
491    /// CMTimebaseSetAnchorTime(timebase, time, CMSyncGetTime(source));
492    /// CFRelease(source).
493    #[doc(alias = "CMTimebaseSetAnchorTime")]
494    #[cfg(feature = "CMTime")]
495    #[inline]
496    pub unsafe fn set_anchor_time(
497        &self,
498        timebase_time: CMTime,
499        immediate_source_time: CMTime,
500    ) -> OSStatus {
501        extern "C-unwind" {
502            fn CMTimebaseSetAnchorTime(
503                timebase: &CMTimebase,
504                timebase_time: CMTime,
505                immediate_source_time: CMTime,
506            ) -> OSStatus;
507        }
508        unsafe { CMTimebaseSetAnchorTime(self, timebase_time, immediate_source_time) }
509    }
510
511    /// Retrieves the current rate of a timebase.
512    ///
513    /// This is the rate relative to its immediate source clock or timebase.
514    /// For example, if a timebase is running at twice the rate of its source, its rate is 2.0.
515    #[doc(alias = "CMTimebaseGetRate")]
516    #[inline]
517    pub unsafe fn rate(&self) -> f64 {
518        extern "C-unwind" {
519            fn CMTimebaseGetRate(timebase: &CMTimebase) -> f64;
520        }
521        unsafe { CMTimebaseGetRate(self) }
522    }
523
524    /// Retrieves the current time and rate of a timebase.
525    ///
526    /// You can use this function to take a consistent snapshot of the two values,
527    /// avoiding possible inconsistencies due to external changes between retrieval of time and rate.
528    ///
529    /// # Safety
530    ///
531    /// - `time_out` must be a valid pointer or null.
532    /// - `rate_out` must be a valid pointer or null.
533    #[doc(alias = "CMTimebaseGetTimeAndRate")]
534    #[cfg(feature = "CMTime")]
535    #[inline]
536    pub unsafe fn time_and_rate(&self, time_out: *mut CMTime, rate_out: *mut f64) -> OSStatus {
537        extern "C-unwind" {
538            fn CMTimebaseGetTimeAndRate(
539                timebase: &CMTimebase,
540                time_out: *mut CMTime,
541                rate_out: *mut f64,
542            ) -> OSStatus;
543        }
544        unsafe { CMTimebaseGetTimeAndRate(self, time_out, rate_out) }
545    }
546
547    /// Sets the rate of a timebase.
548    #[doc(alias = "CMTimebaseSetRate")]
549    #[inline]
550    pub unsafe fn set_rate(&self, rate: f64) -> OSStatus {
551        extern "C-unwind" {
552            fn CMTimebaseSetRate(timebase: &CMTimebase, rate: f64) -> OSStatus;
553        }
554        unsafe { CMTimebaseSetRate(self, rate) }
555    }
556
557    /// Sets the time of a timebase at a particular source time, and changes the rate at exactly that time.
558    ///
559    /// CMTimebaseGetTime's results will be interpolated from that anchor time as though the timebase
560    /// has been running at the requested rate since that time.
561    /// CMTimebaseSetRate(timebase, rate) is approximately equivalent to calling
562    /// CMClockOrTimebaseRef source = CMTimebaseCopySource(timebase);
563    /// CMTimebaseSetRateAndAnchorTime(timebase, rate, CMTimebaseGetTime(timebase), CMSyncGetTime(source)),
564    /// CFRelease(source);
565    /// except that CMTimebaseSetRate will not generate a TimeJumped notification, and
566    /// CMTimebaseSetRateAndAnchorTime will.
567    #[doc(alias = "CMTimebaseSetRateAndAnchorTime")]
568    #[cfg(feature = "CMTime")]
569    #[inline]
570    pub unsafe fn set_rate_and_anchor_time(
571        &self,
572        rate: f64,
573        timebase_time: CMTime,
574        immediate_source_time: CMTime,
575    ) -> OSStatus {
576        extern "C-unwind" {
577            fn CMTimebaseSetRateAndAnchorTime(
578                timebase: &CMTimebase,
579                rate: f64,
580                timebase_time: CMTime,
581                immediate_source_time: CMTime,
582            ) -> OSStatus;
583        }
584        unsafe { CMTimebaseSetRateAndAnchorTime(self, rate, timebase_time, immediate_source_time) }
585    }
586
587    /// Gets the effective rate of a timebase (which combines its rate with the rates of all its source timebases).
588    ///
589    /// Calling CMTimebaseGetEffectiveRate(timebase) is equivalent to calling
590    /// CMClockRef clock = CMTimebaseCopyUltimateSourceClock(timebase);
591    /// CMSyncGetRelativeRate(timebase, clock).
592    /// CFRelease(clock);
593    #[doc(alias = "CMTimebaseGetEffectiveRate")]
594    #[inline]
595    pub unsafe fn effective_rate(&self) -> f64 {
596        extern "C-unwind" {
597            fn CMTimebaseGetEffectiveRate(timebase: &CMTimebase) -> f64;
598        }
599        unsafe { CMTimebaseGetEffectiveRate(self) }
600    }
601
602    /// Adds the timer to the list of timers managed by the timebase.
603    ///
604    /// The timer must be a repeating run loop timer (with a very long interval at
605    /// least as long as kCMTimebaseVeryLongCFTimeInterval), attached to a runloop.
606    /// The timebase will retain the timer, and will maintain its "NextFireDate"
607    /// according to the CMTime set using CMTimebaseSetTimerNextFireTime.
608    /// Until the first call to CMTimebaseSetTimerNextFireTime, the "NextFireDate"
609    /// will be set far, far in the future. The runloop that timer is attached to must be
610    /// passed in and the timebase will retain that runloop. The retained runloop will be
611    /// used to call CFRunLoopWakeUp() any time the timebase modifies the timer's fire date.
612    ///
613    /// # Safety
614    ///
615    /// `runloop` possibly has additional threading requirements.
616    #[doc(alias = "CMTimebaseAddTimer")]
617    #[inline]
618    pub unsafe fn add_timer(&self, timer: &CFRunLoopTimer, runloop: &CFRunLoop) -> OSStatus {
619        extern "C-unwind" {
620            fn CMTimebaseAddTimer(
621                timebase: &CMTimebase,
622                timer: &CFRunLoopTimer,
623                runloop: &CFRunLoop,
624            ) -> OSStatus;
625        }
626        unsafe { CMTimebaseAddTimer(self, timer, runloop) }
627    }
628
629    /// Removes the timer from the list of timers managed by the timebase.
630    ///
631    /// The timebase will no longer maintain the timer's "NextFireDate".
632    /// If the timer is invalidated, the timebase will eventually remove it
633    /// from its list and release it even if this function is not called.
634    #[doc(alias = "CMTimebaseRemoveTimer")]
635    #[inline]
636    pub unsafe fn remove_timer(&self, timer: &CFRunLoopTimer) -> OSStatus {
637        extern "C-unwind" {
638            fn CMTimebaseRemoveTimer(timebase: &CMTimebase, timer: &CFRunLoopTimer) -> OSStatus;
639        }
640        unsafe { CMTimebaseRemoveTimer(self, timer) }
641    }
642
643    /// Sets the CMTime on the timebase's timeline at which the timer should next be fired.
644    ///
645    /// The timer must be on the list of timers managed by the timebase.
646    /// The timebase will continue to update the timer's "NextFireDate" according to time jumps
647    /// and effective rate changes.
648    /// If fireTime is not numeric, or if the timebase is not moving, the "NextFireDate"
649    /// will be set to a date far, far in the future.
650    /// <BR
651    /// >
652    /// IMPORTANT NOTE: Due to the way that CFRunLoopTimers are implemented, if a timer passes
653    /// through a state in which it is due to fire, it may fire even if its rescheduled before
654    /// the runloop runs again.  Clients should take care to avoid temporarily scheduling timers
655    /// in the past.  For example, set the timebase's rate or time before you set the timer's
656    /// next fire time, if you are doing both at once.  (If setting the timebase's rate or time
657    /// might put the timer's fire time in the past, you may need to set the fire time to
658    /// kCMTimeInvalid across the timebase change.)
659    #[doc(alias = "CMTimebaseSetTimerNextFireTime")]
660    #[cfg(feature = "CMTime")]
661    #[inline]
662    pub unsafe fn set_timer_next_fire_time(
663        &self,
664        timer: &CFRunLoopTimer,
665        fire_time: CMTime,
666        flags: u32,
667    ) -> OSStatus {
668        extern "C-unwind" {
669            fn CMTimebaseSetTimerNextFireTime(
670                timebase: &CMTimebase,
671                timer: &CFRunLoopTimer,
672                fire_time: CMTime,
673                flags: u32,
674            ) -> OSStatus;
675        }
676        unsafe { CMTimebaseSetTimerNextFireTime(self, timer, fire_time, flags) }
677    }
678
679    /// Sets the timer to fire immediately once, overriding any previous CMTimebaseSetTimerNextFireTime call.
680    ///
681    /// The timer must be on the list of timers managed by the timebase.
682    /// This is equivalent to calling
683    /// CFRunLoopTimerSetNextFireDate( timer, CFAbsoluteTimeGetCurrent() );
684    /// except that the timebase gets to know that it shouldn't interfere.
685    #[doc(alias = "CMTimebaseSetTimerToFireImmediately")]
686    #[inline]
687    pub unsafe fn set_timer_to_fire_immediately(&self, timer: &CFRunLoopTimer) -> OSStatus {
688        extern "C-unwind" {
689            fn CMTimebaseSetTimerToFireImmediately(
690                timebase: &CMTimebase,
691                timer: &CFRunLoopTimer,
692            ) -> OSStatus;
693        }
694        unsafe { CMTimebaseSetTimerToFireImmediately(self, timer) }
695    }
696
697    /// Adds the timer dispatch source to the list of timers managed by the timebase.
698    ///
699    /// The timer source must have been created by calling
700    /// dispatch_source_create( DISPATCH_SOURCE_TYPE_TIMER, 0, 0, some_dispatch_queue )
701    /// and should have had an event handler associated with it via
702    /// dispatch_source_set_event_handler( timerSource, some_handler_block )
703    /// or dispatch_source_set_event_handler_f( timerSource, some_handler_function ).
704    /// Don't forget to call dispatch_resume( timerSource ) as dispatch sources are
705    /// created suspended.
706    ///
707    /// The timebase will retain the timer source, and will maintain its start time
708    /// according to the CMTime set using CMTimebaseSetTimerDispatchSourceNextFireTime.
709    /// Until the first call to CMTimebaseSetTimerDispatchSourceNextFireTime, the start time
710    /// will be set to DISPATCH_TIME_FOREVER.
711    #[doc(alias = "CMTimebaseAddTimerDispatchSource")]
712    #[cfg(feature = "dispatch2")]
713    #[inline]
714    pub unsafe fn add_timer_dispatch_source(&self, timer_source: &DispatchSource) -> OSStatus {
715        extern "C-unwind" {
716            fn CMTimebaseAddTimerDispatchSource(
717                timebase: &CMTimebase,
718                timer_source: &DispatchSource,
719            ) -> OSStatus;
720        }
721        unsafe { CMTimebaseAddTimerDispatchSource(self, timer_source) }
722    }
723
724    /// Removes the timer dispatch source from the list of timers managed by the timebase.
725    ///
726    /// The timebase will no longer maintain the timer source's start time.
727    /// If the timer source is cancelled, the timebase will eventually remove it
728    /// from its list and release it even if this function is not called.
729    #[doc(alias = "CMTimebaseRemoveTimerDispatchSource")]
730    #[cfg(feature = "dispatch2")]
731    #[inline]
732    pub unsafe fn remove_timer_dispatch_source(&self, timer_source: &DispatchSource) -> OSStatus {
733        extern "C-unwind" {
734            fn CMTimebaseRemoveTimerDispatchSource(
735                timebase: &CMTimebase,
736                timer_source: &DispatchSource,
737            ) -> OSStatus;
738        }
739        unsafe { CMTimebaseRemoveTimerDispatchSource(self, timer_source) }
740    }
741
742    /// Sets the CMTime on the timebase's timeline at which the timer dispatch source should next be fired.
743    ///
744    /// The timer source must be on the list of timers managed by the timebase.
745    /// The timebase will continue to update the timer dispatch source's start time
746    /// according to time jumps and effective rate changes.
747    /// If fireTime is not numeric, or if the timebase is not moving, the start time
748    /// will be set to DISPATCH_TIME_FOREVER.
749    /// <BR
750    /// >
751    /// IMPORTANT NOTE: Due to the way that timer dispatch sources are implemented, if a timer passes
752    /// through a state in which it is due to fire, it may fire even if its rescheduled before
753    /// the event handler is run.  Clients should take care to avoid temporarily scheduling timers
754    /// in the past.  For example, set the timebase's rate or time before you set the timer's
755    /// next fire time, if you are doing both at once.  (If setting the timebase's rate or time
756    /// might put the timer's fire time in the past, you may need to set the fire time to
757    /// kCMTimeInvalid across the timebase change.)
758    #[doc(alias = "CMTimebaseSetTimerDispatchSourceNextFireTime")]
759    #[cfg(all(feature = "CMTime", feature = "dispatch2"))]
760    #[inline]
761    pub unsafe fn set_timer_dispatch_source_next_fire_time(
762        &self,
763        timer_source: &DispatchSource,
764        fire_time: CMTime,
765        flags: u32,
766    ) -> OSStatus {
767        extern "C-unwind" {
768            fn CMTimebaseSetTimerDispatchSourceNextFireTime(
769                timebase: &CMTimebase,
770                timer_source: &DispatchSource,
771                fire_time: CMTime,
772                flags: u32,
773            ) -> OSStatus;
774        }
775        unsafe {
776            CMTimebaseSetTimerDispatchSourceNextFireTime(self, timer_source, fire_time, flags)
777        }
778    }
779
780    /// Sets the timer dispatch source to fire immediately once, overriding any previous
781    /// CMTimebaseSetTimerDispatchSourceNextFireTime call.
782    ///
783    /// The timer source must be on the list of timers managed by the timebase.
784    /// This is equivalent to calling
785    /// dispatch_source_set_timer( timerSource, DISPATCH_TIME_NOW, 0, 0 );
786    /// except that the timebase gets to know that it shouldn't interfere.
787    #[doc(alias = "CMTimebaseSetTimerDispatchSourceToFireImmediately")]
788    #[cfg(feature = "dispatch2")]
789    #[inline]
790    pub unsafe fn set_timer_dispatch_source_to_fire_immediately(
791        &self,
792        timer_source: &DispatchSource,
793    ) -> OSStatus {
794        extern "C-unwind" {
795            fn CMTimebaseSetTimerDispatchSourceToFireImmediately(
796                timebase: &CMTimebase,
797                timer_source: &DispatchSource,
798            ) -> OSStatus;
799        }
800        unsafe { CMTimebaseSetTimerDispatchSourceToFireImmediately(self, timer_source) }
801    }
802}
803
804extern "C-unwind" {
805    /// Queries the relative rate of one timebase or clock relative to another timebase or clock.
806    ///
807    /// If both have a common source, this calculation is performed purely based on the rates in the common tree
808    /// rooted in that source.
809    /// If they have different source clocks (or are both clocks), this calculation takes into account the measured
810    /// drift between the two clocks, using host time as a pivot.
811    /// The rate of a moving timebase relative to a stopped timebase is a NaN.
812    /// Calling CMTimebaseGetEffectiveRate(timebase) is equivalent to calling
813    /// CMClockRef clock = CMTimebaseCopyUltimateSourceClock(timebase);
814    /// CMSyncGetRelativeRate(timebase, clock).
815    /// CFRelease(clock);
816    ///
817    /// # Safety
818    ///
819    /// - `of_clock_or_timebase` should be of the correct type.
820    /// - `relative_to_clock_or_timebase` should be of the correct type.
821    pub fn CMSyncGetRelativeRate(
822        of_clock_or_timebase: &CMClockOrTimebase,
823        relative_to_clock_or_timebase: &CMClockOrTimebase,
824    ) -> f64;
825}
826
827extern "C-unwind" {
828    /// 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.
829    ///
830    /// If both have a common source, this calculation is performed purely based on the rates in the common tree
831    /// rooted in that source.
832    /// If they have different source clocks (or are both clocks), this calculation takes into account the measured
833    /// drift between the two clocks, using host time as a pivot.
834    /// The rate of a moving timebase relative to a stopped timebase is a NaN.
835    ///
836    /// # Safety
837    ///
838    /// - `of_clock_or_timebase` should be of the correct type.
839    /// - `relative_to_clock_or_timebase` should be of the correct type.
840    /// - `out_relative_rate` must be a valid pointer or null.
841    /// - `out_of_clock_or_timebase_anchor_time` must be a valid pointer or null.
842    /// - `out_relative_to_clock_or_timebase_anchor_time` must be a valid pointer or null.
843    #[cfg(feature = "CMTime")]
844    pub fn CMSyncGetRelativeRateAndAnchorTime(
845        of_clock_or_timebase: &CMClockOrTimebase,
846        relative_to_clock_or_timebase: &CMClockOrTimebase,
847        out_relative_rate: *mut f64,
848        out_of_clock_or_timebase_anchor_time: *mut CMTime,
849        out_relative_to_clock_or_timebase_anchor_time: *mut CMTime,
850    ) -> OSStatus;
851}
852
853extern "C-unwind" {
854    /// Converts a time from one timebase or clock to another timebase or clock.
855    ///
856    /// If both have a common source, this calculation is performed purely based on the mathematical rates and offsets
857    /// in the common tree rooted in that source.
858    /// If they have different source clocks (or are both clocks), this calculation also compensates
859    /// for measured drift between the clocks.
860    /// To convert to or from host time, pass CMClockGetHostTimeClock() as the appropriate argument.
861    ///
862    /// # Safety
863    ///
864    /// - `from_clock_or_timebase` should be of the correct type.
865    /// - `to_clock_or_timebase` should be of the correct type.
866    #[cfg(feature = "CMTime")]
867    pub fn CMSyncConvertTime(
868        time: CMTime,
869        from_clock_or_timebase: &CMClockOrTimebase,
870        to_clock_or_timebase: &CMClockOrTimebase,
871    ) -> CMTime;
872}
873
874/// Reports whether it is possible for one timebase/clock to drift relative to the other.
875///
876/// A timebase can drift relative to another if their ultimate source clocks that can drift relative
877/// to each other.
878///
879/// # Safety
880///
881/// - `clock_or_timebase1` should be of the correct type.
882/// - `clock_or_timebase2` should be of the correct type.
883#[inline]
884pub unsafe extern "C-unwind" fn CMSyncMightDrift(
885    clock_or_timebase1: &CMClockOrTimebase,
886    clock_or_timebase2: &CMClockOrTimebase,
887) -> bool {
888    extern "C-unwind" {
889        fn CMSyncMightDrift(
890            clock_or_timebase1: &CMClockOrTimebase,
891            clock_or_timebase2: &CMClockOrTimebase,
892        ) -> Boolean;
893    }
894    let ret = unsafe { CMSyncMightDrift(clock_or_timebase1, clock_or_timebase2) };
895    ret != 0
896}
897
898extern "C-unwind" {
899    /// A helper function to get time from a clock or timebase.
900    ///
901    /// CMSyncGetTime simply calls either CMClockGetTime or CMTimebaseGetTime, as appropriate.
902    /// It comes in handy for things like:
903    /// CMClockOrTimebaseRef source = CMTimebaseCopySource(timebase);
904    /// CMSyncGetTime(source);
905    /// CFRelease(source);
906    ///
907    /// # Safety
908    ///
909    /// `clock_or_timebase` should be of the correct type.
910    #[cfg(feature = "CMTime")]
911    pub fn CMSyncGetTime(clock_or_timebase: &CMClockOrTimebase) -> CMTime;
912}
913
914impl CMTimebase {
915    /// Requests that the timebase wait until it is not posting any notifications.
916    #[doc(alias = "CMTimebaseNotificationBarrier")]
917    #[inline]
918    pub unsafe fn notification_barrier(&self) -> OSStatus {
919        extern "C-unwind" {
920            fn CMTimebaseNotificationBarrier(timebase: &CMTimebase) -> OSStatus;
921        }
922        unsafe { CMTimebaseNotificationBarrier(self) }
923    }
924}
925
926extern "C" {
927    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebasenotification_effectiveratechanged?language=objc)
928    pub static kCMTimebaseNotification_EffectiveRateChanged: &'static CFString;
929}
930
931extern "C" {
932    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebasenotification_timejumped?language=objc)
933    pub static kCMTimebaseNotification_TimeJumped: &'static CFString;
934}
935
936extern "C" {
937    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtimebasenotificationkey_eventtime?language=objc)
938    pub static kCMTimebaseNotificationKey_EventTime: &'static CFString;
939}
940
941#[deprecated = "renamed to `CMClock::host_time_clock`"]
942#[inline]
943pub unsafe extern "C-unwind" fn CMClockGetHostTimeClock() -> CFRetained<CMClock> {
944    extern "C-unwind" {
945        fn CMClockGetHostTimeClock() -> Option<NonNull<CMClock>>;
946    }
947    let ret = unsafe { CMClockGetHostTimeClock() };
948    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
949    unsafe { CFRetained::retain(ret) }
950}
951
952extern "C-unwind" {
953    #[cfg(feature = "CMTime")]
954    #[deprecated = "renamed to `CMClock::convert_host_time_to_system_units`"]
955    pub fn CMClockConvertHostTimeToSystemUnits(host_time: CMTime) -> u64;
956}
957
958extern "C-unwind" {
959    #[cfg(feature = "CMTime")]
960    #[deprecated = "renamed to `CMClock::make_host_time_from_system_units`"]
961    pub fn CMClockMakeHostTimeFromSystemUnits(host_time: u64) -> CMTime;
962}
963
964extern "C-unwind" {
965    #[cfg(feature = "CMTime")]
966    #[deprecated = "renamed to `CMClock::time`"]
967    pub fn CMClockGetTime(clock: &CMClock) -> CMTime;
968}
969
970extern "C-unwind" {
971    #[cfg(feature = "CMTime")]
972    #[deprecated = "renamed to `CMClock::anchor_time`"]
973    pub fn CMClockGetAnchorTime(
974        clock: &CMClock,
975        clock_time_out: NonNull<CMTime>,
976        reference_clock_time_out: NonNull<CMTime>,
977    ) -> OSStatus;
978}
979
980#[deprecated = "renamed to `CMClock::might_drift`"]
981#[inline]
982pub unsafe extern "C-unwind" fn CMClockMightDrift(clock: &CMClock, other_clock: &CMClock) -> bool {
983    extern "C-unwind" {
984        fn CMClockMightDrift(clock: &CMClock, other_clock: &CMClock) -> Boolean;
985    }
986    let ret = unsafe { CMClockMightDrift(clock, other_clock) };
987    ret != 0
988}
989
990extern "C-unwind" {
991    #[deprecated = "renamed to `CMClock::invalidate`"]
992    pub fn CMClockInvalidate(clock: &CMClock);
993}
994
995extern "C-unwind" {
996    #[deprecated = "renamed to `CMTimebase::create_with_master_clock`"]
997    pub fn CMTimebaseCreateWithMasterClock(
998        allocator: Option<&CFAllocator>,
999        master_clock: &CMClock,
1000        timebase_out: NonNull<*mut CMTimebase>,
1001    ) -> OSStatus;
1002}
1003
1004extern "C-unwind" {
1005    #[deprecated = "renamed to `CMTimebase::create_with_master_timebase`"]
1006    pub fn CMTimebaseCreateWithMasterTimebase(
1007        allocator: Option<&CFAllocator>,
1008        master_timebase: &CMTimebase,
1009        timebase_out: NonNull<*mut CMTimebase>,
1010    ) -> OSStatus;
1011}
1012
1013#[deprecated = "renamed to `CMTimebase::master_timebase`"]
1014#[inline]
1015pub unsafe extern "C-unwind" fn CMTimebaseCopyMasterTimebase(
1016    timebase: &CMTimebase,
1017) -> Option<CFRetained<CMTimebase>> {
1018    extern "C-unwind" {
1019        fn CMTimebaseCopyMasterTimebase(timebase: &CMTimebase) -> Option<NonNull<CMTimebase>>;
1020    }
1021    let ret = unsafe { CMTimebaseCopyMasterTimebase(timebase) };
1022    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1023}
1024
1025#[deprecated = "renamed to `CMTimebase::master_clock`"]
1026#[inline]
1027pub unsafe extern "C-unwind" fn CMTimebaseCopyMasterClock(
1028    timebase: &CMTimebase,
1029) -> Option<CFRetained<CMClock>> {
1030    extern "C-unwind" {
1031        fn CMTimebaseCopyMasterClock(timebase: &CMTimebase) -> Option<NonNull<CMClock>>;
1032    }
1033    let ret = unsafe { CMTimebaseCopyMasterClock(timebase) };
1034    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1035}
1036
1037#[deprecated = "renamed to `CMTimebase::master`"]
1038#[inline]
1039pub unsafe extern "C-unwind" fn CMTimebaseCopyMaster(
1040    timebase: &CMTimebase,
1041) -> CFRetained<CMClockOrTimebase> {
1042    extern "C-unwind" {
1043        fn CMTimebaseCopyMaster(timebase: &CMTimebase) -> Option<NonNull<CMClockOrTimebase>>;
1044    }
1045    let ret = unsafe { CMTimebaseCopyMaster(timebase) };
1046    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1047    unsafe { CFRetained::from_raw(ret) }
1048}
1049
1050#[deprecated = "renamed to `CMTimebase::ultimate_master_clock`"]
1051#[inline]
1052pub unsafe extern "C-unwind" fn CMTimebaseCopyUltimateMasterClock(
1053    timebase: &CMTimebase,
1054) -> CFRetained<CMClock> {
1055    extern "C-unwind" {
1056        fn CMTimebaseCopyUltimateMasterClock(timebase: &CMTimebase) -> Option<NonNull<CMClock>>;
1057    }
1058    let ret = unsafe { CMTimebaseCopyUltimateMasterClock(timebase) };
1059    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1060    unsafe { CFRetained::from_raw(ret) }
1061}
1062
1063#[deprecated = "renamed to `CMTimebase::get_master_timebase`"]
1064#[inline]
1065pub unsafe extern "C-unwind" fn CMTimebaseGetMasterTimebase(
1066    timebase: &CMTimebase,
1067) -> Option<CFRetained<CMTimebase>> {
1068    extern "C-unwind" {
1069        fn CMTimebaseGetMasterTimebase(timebase: &CMTimebase) -> Option<NonNull<CMTimebase>>;
1070    }
1071    let ret = unsafe { CMTimebaseGetMasterTimebase(timebase) };
1072    ret.map(|ret| unsafe { CFRetained::retain(ret) })
1073}
1074
1075#[deprecated = "renamed to `CMTimebase::get_master_clock`"]
1076#[inline]
1077pub unsafe extern "C-unwind" fn CMTimebaseGetMasterClock(
1078    timebase: &CMTimebase,
1079) -> Option<CFRetained<CMClock>> {
1080    extern "C-unwind" {
1081        fn CMTimebaseGetMasterClock(timebase: &CMTimebase) -> Option<NonNull<CMClock>>;
1082    }
1083    let ret = unsafe { CMTimebaseGetMasterClock(timebase) };
1084    ret.map(|ret| unsafe { CFRetained::retain(ret) })
1085}
1086
1087#[deprecated = "renamed to `CMTimebase::get_master`"]
1088#[inline]
1089pub unsafe extern "C-unwind" fn CMTimebaseGetMaster(
1090    timebase: &CMTimebase,
1091) -> Option<CFRetained<CMClockOrTimebase>> {
1092    extern "C-unwind" {
1093        fn CMTimebaseGetMaster(timebase: &CMTimebase) -> Option<NonNull<CMClockOrTimebase>>;
1094    }
1095    let ret = unsafe { CMTimebaseGetMaster(timebase) };
1096    ret.map(|ret| unsafe { CFRetained::retain(ret) })
1097}
1098
1099#[deprecated = "renamed to `CMTimebase::get_ultimate_master_clock`"]
1100#[inline]
1101pub unsafe extern "C-unwind" fn CMTimebaseGetUltimateMasterClock(
1102    timebase: &CMTimebase,
1103) -> Option<CFRetained<CMClock>> {
1104    extern "C-unwind" {
1105        fn CMTimebaseGetUltimateMasterClock(timebase: &CMTimebase) -> Option<NonNull<CMClock>>;
1106    }
1107    let ret = unsafe { CMTimebaseGetUltimateMasterClock(timebase) };
1108    ret.map(|ret| unsafe { CFRetained::retain(ret) })
1109}
1110
1111extern "C-unwind" {
1112    #[deprecated = "renamed to `CMTimebase::set_master_clock`"]
1113    pub fn CMTimebaseSetMasterClock(timebase: &CMTimebase, new_master_clock: &CMClock) -> OSStatus;
1114}
1115
1116extern "C-unwind" {
1117    #[deprecated = "renamed to `CMTimebase::set_master_timebase`"]
1118    pub fn CMTimebaseSetMasterTimebase(
1119        timebase: &CMTimebase,
1120        new_master_timebase: &CMTimebase,
1121    ) -> OSStatus;
1122}
1123
1124extern "C-unwind" {
1125    #[cfg(feature = "CMTime")]
1126    #[deprecated = "renamed to `CMTimebase::time`"]
1127    pub fn CMTimebaseGetTime(timebase: &CMTimebase) -> CMTime;
1128}
1129
1130extern "C-unwind" {
1131    #[cfg(feature = "CMTime")]
1132    #[deprecated = "renamed to `CMTimebase::time_with_time_scale`"]
1133    pub fn CMTimebaseGetTimeWithTimeScale(
1134        timebase: &CMTimebase,
1135        timescale: CMTimeScale,
1136        method: CMTimeRoundingMethod,
1137    ) -> CMTime;
1138}
1139
1140extern "C-unwind" {
1141    #[cfg(feature = "CMTime")]
1142    #[deprecated = "renamed to `CMTimebase::set_time`"]
1143    pub fn CMTimebaseSetTime(timebase: &CMTimebase, time: CMTime) -> OSStatus;
1144}
1145
1146extern "C-unwind" {
1147    #[cfg(feature = "CMTime")]
1148    #[deprecated = "renamed to `CMTimebase::set_anchor_time`"]
1149    pub fn CMTimebaseSetAnchorTime(
1150        timebase: &CMTimebase,
1151        timebase_time: CMTime,
1152        immediate_source_time: CMTime,
1153    ) -> OSStatus;
1154}
1155
1156extern "C-unwind" {
1157    #[deprecated = "renamed to `CMTimebase::rate`"]
1158    pub fn CMTimebaseGetRate(timebase: &CMTimebase) -> f64;
1159}
1160
1161extern "C-unwind" {
1162    #[cfg(feature = "CMTime")]
1163    #[deprecated = "renamed to `CMTimebase::time_and_rate`"]
1164    pub fn CMTimebaseGetTimeAndRate(
1165        timebase: &CMTimebase,
1166        time_out: *mut CMTime,
1167        rate_out: *mut f64,
1168    ) -> OSStatus;
1169}
1170
1171extern "C-unwind" {
1172    #[deprecated = "renamed to `CMTimebase::set_rate`"]
1173    pub fn CMTimebaseSetRate(timebase: &CMTimebase, rate: f64) -> OSStatus;
1174}
1175
1176extern "C-unwind" {
1177    #[cfg(feature = "CMTime")]
1178    #[deprecated = "renamed to `CMTimebase::set_rate_and_anchor_time`"]
1179    pub fn CMTimebaseSetRateAndAnchorTime(
1180        timebase: &CMTimebase,
1181        rate: f64,
1182        timebase_time: CMTime,
1183        immediate_source_time: CMTime,
1184    ) -> OSStatus;
1185}
1186
1187extern "C-unwind" {
1188    #[deprecated = "renamed to `CMTimebase::effective_rate`"]
1189    pub fn CMTimebaseGetEffectiveRate(timebase: &CMTimebase) -> f64;
1190}
1191
1192extern "C-unwind" {
1193    #[deprecated = "renamed to `CMTimebase::add_timer`"]
1194    pub fn CMTimebaseAddTimer(
1195        timebase: &CMTimebase,
1196        timer: &CFRunLoopTimer,
1197        runloop: &CFRunLoop,
1198    ) -> OSStatus;
1199}
1200
1201extern "C-unwind" {
1202    #[deprecated = "renamed to `CMTimebase::remove_timer`"]
1203    pub fn CMTimebaseRemoveTimer(timebase: &CMTimebase, timer: &CFRunLoopTimer) -> OSStatus;
1204}
1205
1206extern "C-unwind" {
1207    #[cfg(feature = "CMTime")]
1208    #[deprecated = "renamed to `CMTimebase::set_timer_next_fire_time`"]
1209    pub fn CMTimebaseSetTimerNextFireTime(
1210        timebase: &CMTimebase,
1211        timer: &CFRunLoopTimer,
1212        fire_time: CMTime,
1213        flags: u32,
1214    ) -> OSStatus;
1215}
1216
1217extern "C-unwind" {
1218    #[deprecated = "renamed to `CMTimebase::set_timer_to_fire_immediately`"]
1219    pub fn CMTimebaseSetTimerToFireImmediately(
1220        timebase: &CMTimebase,
1221        timer: &CFRunLoopTimer,
1222    ) -> OSStatus;
1223}
1224
1225extern "C-unwind" {
1226    #[cfg(feature = "dispatch2")]
1227    #[deprecated = "renamed to `CMTimebase::add_timer_dispatch_source`"]
1228    pub fn CMTimebaseAddTimerDispatchSource(
1229        timebase: &CMTimebase,
1230        timer_source: &DispatchSource,
1231    ) -> OSStatus;
1232}
1233
1234extern "C-unwind" {
1235    #[cfg(feature = "dispatch2")]
1236    #[deprecated = "renamed to `CMTimebase::remove_timer_dispatch_source`"]
1237    pub fn CMTimebaseRemoveTimerDispatchSource(
1238        timebase: &CMTimebase,
1239        timer_source: &DispatchSource,
1240    ) -> OSStatus;
1241}
1242
1243extern "C-unwind" {
1244    #[cfg(all(feature = "CMTime", feature = "dispatch2"))]
1245    #[deprecated = "renamed to `CMTimebase::set_timer_dispatch_source_next_fire_time`"]
1246    pub fn CMTimebaseSetTimerDispatchSourceNextFireTime(
1247        timebase: &CMTimebase,
1248        timer_source: &DispatchSource,
1249        fire_time: CMTime,
1250        flags: u32,
1251    ) -> OSStatus;
1252}
1253
1254extern "C-unwind" {
1255    #[cfg(feature = "dispatch2")]
1256    #[deprecated = "renamed to `CMTimebase::set_timer_dispatch_source_to_fire_immediately`"]
1257    pub fn CMTimebaseSetTimerDispatchSourceToFireImmediately(
1258        timebase: &CMTimebase,
1259        timer_source: &DispatchSource,
1260    ) -> OSStatus;
1261}
1262
1263extern "C-unwind" {
1264    #[deprecated = "renamed to `CMTimebase::notification_barrier`"]
1265    pub fn CMTimebaseNotificationBarrier(timebase: &CMTimebase) -> OSStatus;
1266}