1use 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#[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#[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#[doc(alias = "CMClockOrTimebaseRef")]
84pub type CMClockOrTimebase = CFType;
85
86pub const kCMClockError_MissingRequiredParameter: OSStatus = -12745;
88pub const kCMClockError_InvalidParameter: OSStatus = -12746;
90pub const kCMClockError_AllocationFailed: OSStatus = -12747;
92pub const kCMClockError_UnsupportedOperation: OSStatus = -12756;
94
95pub const kCMTimebaseError_MissingRequiredParameter: OSStatus = -12748;
97pub const kCMTimebaseError_InvalidParameter: OSStatus = -12749;
99pub const kCMTimebaseError_AllocationFailed: OSStatus = -12750;
101pub const kCMTimebaseError_TimerIntervalTooShort: OSStatus = -12751;
103pub const kCMTimebaseError_ReadOnly: OSStatus = -12757;
105
106pub const kCMSyncError_MissingRequiredParameter: OSStatus = -12752;
108pub const kCMSyncError_InvalidParameter: OSStatus = -12753;
110pub const kCMSyncError_AllocationFailed: OSStatus = -12754;
112pub const kCMSyncError_RateMustBeNonZero: OSStatus = -12755;
114
115unsafe impl ConcreteType for CMClock {
116 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 pub fn CMSyncGetRelativeRate(
822 of_clock_or_timebase: &CMClockOrTimebase,
823 relative_to_clock_or_timebase: &CMClockOrTimebase,
824 ) -> f64;
825}
826
827extern "C-unwind" {
828 #[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 #[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#[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 #[cfg(feature = "CMTime")]
911 pub fn CMSyncGetTime(clock_or_timebase: &CMClockOrTimebase) -> CMTime;
912}
913
914impl CMTimebase {
915 #[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 pub static kCMTimebaseNotification_EffectiveRateChanged: &'static CFString;
929}
930
931extern "C" {
932 pub static kCMTimebaseNotification_TimeJumped: &'static CFString;
934}
935
936extern "C" {
937 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}