pub struct CMTimebase { /* private fields */ }CMSync only.Expand description
Models a timeline under application control.
A timebase represents a timeline that clients can control by setting the rate and time. Each timebase has either a source clock or a source timebase (previously referred to as a master clock or master timebase). The rate of the timebase is expressed relative to its source. When a timebase has rate 0.0, its time is fixed and does not change as its source’s time changes. When a timebase has rate 1.0, its time increases one second as its source’s time increases by one second. When a timebase has rate 2.0, its time increases two seconds as its source’s time increases by one second. When a timebase has rate -1.0, its time decreases one second as its source’s time increases by one second.
If a timebase has a source timebase, the source timebase’s rate is a factor in determining the timebase’s effective rate. In fact, a timebase’s effective rate is defined as the product of its rate, its source timebase’s rate, its source timebase’s source timebase’s rate, and so on up to the ultimate source clock. This is the rate at which the timebase’s time changes relative to the ultimate source clock.
See also Apple’s documentation
Implementations§
Source§impl CMTimebase
impl CMTimebase
Sourcepub unsafe fn create_with_master_clock(
allocator: Option<&CFAllocator>,
master_clock: &CMClock,
timebase_out: NonNull<*mut CMTimebase>,
) -> i32
👎Deprecated
pub unsafe fn create_with_master_clock( allocator: Option<&CFAllocator>, master_clock: &CMClock, timebase_out: NonNull<*mut CMTimebase>, ) -> i32
§Safety
timebase_out must be a valid pointer.
Sourcepub unsafe fn create_with_master_timebase(
allocator: Option<&CFAllocator>,
master_timebase: &CMTimebase,
timebase_out: NonNull<*mut CMTimebase>,
) -> i32
👎Deprecated
pub unsafe fn create_with_master_timebase( allocator: Option<&CFAllocator>, master_timebase: &CMTimebase, timebase_out: NonNull<*mut CMTimebase>, ) -> i32
§Safety
timebase_out must be a valid pointer.
pub unsafe fn master_timebase(&self) -> Option<CFRetained<CMTimebase>>
pub unsafe fn master_clock(&self) -> Option<CFRetained<CMClock>>
pub unsafe fn master(&self) -> CFRetained<CMClockOrTimebase>
pub unsafe fn ultimate_master_clock(&self) -> CFRetained<CMClock>
Sourcepub unsafe fn get_master_timebase(&self) -> Option<CFRetained<CMTimebase>>
👎Deprecated
pub unsafe fn get_master_timebase(&self) -> Option<CFRetained<CMTimebase>>
Returns the immediate source timebase of a timebase.
Returns NULL if the timebase actually has a source clock instead of a source timebase. Please use CMTimebaseCopySourceTimebase instead.
Sourcepub unsafe fn get_master_clock(&self) -> Option<CFRetained<CMClock>>
👎Deprecated
pub unsafe fn get_master_clock(&self) -> Option<CFRetained<CMClock>>
Returns the immediate source clock of a timebase.
Returns NULL if the timebase actually has a source timebase instead of a source clock. Please use CMTimebaseCopySourceClock instead.
Sourcepub unsafe fn get_master(&self) -> Option<CFRetained<CMClockOrTimebase>>
👎Deprecated
pub unsafe fn get_master(&self) -> Option<CFRetained<CMClockOrTimebase>>
Returns the immediate source (either timebase or clock) of a timebase.
Only returns NULL if there was an error (such as timebase == NULL). Example of use: time = CMSyncGetTime(CMTimebaseGetMaster(timebase)); Please use CMTimebaseCopySource instead.
Sourcepub unsafe fn get_ultimate_master_clock(&self) -> Option<CFRetained<CMClock>>
👎Deprecated
pub unsafe fn get_ultimate_master_clock(&self) -> Option<CFRetained<CMClock>>
Returns the source clock that is the source of all of a timebase’s source timebases.
Please use CMTimebaseCopyUltimateSourceClock instead.
pub unsafe fn set_master_clock(&self, new_master_clock: &CMClock) -> i32
pub unsafe fn set_master_timebase( &self, new_master_timebase: &CMTimebase, ) -> i32
Sourcepub unsafe fn time(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn time(&self) -> CMTime
CMTime only.Retrieves the current time from a timebase.
Sourcepub unsafe fn time_with_time_scale(
&self,
timescale: CMTimeScale,
method: CMTimeRoundingMethod,
) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn time_with_time_scale( &self, timescale: CMTimeScale, method: CMTimeRoundingMethod, ) -> CMTime
CMTime only.Retrieves the current time from a timebase in the specified timescale.
Sourcepub unsafe fn set_time(&self, time: CMTime) -> i32
Available on crate feature CMTime only.
pub unsafe fn set_time(&self, time: CMTime) -> i32
CMTime only.Sets the current time of a timebase.
Sourcepub unsafe fn set_anchor_time(
&self,
timebase_time: CMTime,
immediate_source_time: CMTime,
) -> i32
Available on crate feature CMTime only.
pub unsafe fn set_anchor_time( &self, timebase_time: CMTime, immediate_source_time: CMTime, ) -> i32
CMTime only.Sets the time of a timebase at a particular source time.
CMTimebaseGetTime’s results will be interpolated from that anchor time. CMTimebaseSetTime(timebase, time) is equivalent to calling CMClockOrTimebaseRef source = CMTimebaseCopySource(timebase); CMTimebaseSetAnchorTime(timebase, time, CMSyncGetTime(source)); CFRelease(source).
Sourcepub unsafe fn rate(&self) -> f64
pub unsafe fn rate(&self) -> f64
Retrieves the current rate of a timebase.
This is the rate relative to its immediate source clock or timebase. For example, if a timebase is running at twice the rate of its source, its rate is 2.0.
Sourcepub unsafe fn time_and_rate(
&self,
time_out: *mut CMTime,
rate_out: *mut f64,
) -> i32
Available on crate feature CMTime only.
pub unsafe fn time_and_rate( &self, time_out: *mut CMTime, rate_out: *mut f64, ) -> i32
CMTime only.Retrieves the current time and rate of a timebase.
You can use this function to take a consistent snapshot of the two values, avoiding possible inconsistencies due to external changes between retrieval of time and rate.
§Safety
time_outmust be a valid pointer or null.rate_outmust be a valid pointer or null.
Sourcepub unsafe fn set_rate_and_anchor_time(
&self,
rate: f64,
timebase_time: CMTime,
immediate_source_time: CMTime,
) -> i32
Available on crate feature CMTime only.
pub unsafe fn set_rate_and_anchor_time( &self, rate: f64, timebase_time: CMTime, immediate_source_time: CMTime, ) -> i32
CMTime only.Sets the time of a timebase at a particular source time, and changes the rate at exactly that time.
CMTimebaseGetTime’s results will be interpolated from that anchor time as though the timebase has been running at the requested rate since that time. CMTimebaseSetRate(timebase, rate) is approximately equivalent to calling CMClockOrTimebaseRef source = CMTimebaseCopySource(timebase); CMTimebaseSetRateAndAnchorTime(timebase, rate, CMTimebaseGetTime(timebase), CMSyncGetTime(source)), CFRelease(source); except that CMTimebaseSetRate will not generate a TimeJumped notification, and CMTimebaseSetRateAndAnchorTime will.
Sourcepub unsafe fn effective_rate(&self) -> f64
pub unsafe fn effective_rate(&self) -> f64
Gets the effective rate of a timebase (which combines its rate with the rates of all its source timebases).
Calling CMTimebaseGetEffectiveRate(timebase) is equivalent to calling CMClockRef clock = CMTimebaseCopyUltimateSourceClock(timebase); CMSyncGetRelativeRate(timebase, clock). CFRelease(clock);
Sourcepub unsafe fn add_timer(
&self,
timer: &CFRunLoopTimer,
runloop: &CFRunLoop,
) -> i32
pub unsafe fn add_timer( &self, timer: &CFRunLoopTimer, runloop: &CFRunLoop, ) -> i32
Adds the timer to the list of timers managed by the timebase.
The timer must be a repeating run loop timer (with a very long interval at least as long as kCMTimebaseVeryLongCFTimeInterval), attached to a runloop. The timebase will retain the timer, and will maintain its “NextFireDate” according to the CMTime set using CMTimebaseSetTimerNextFireTime. Until the first call to CMTimebaseSetTimerNextFireTime, the “NextFireDate” will be set far, far in the future. The runloop that timer is attached to must be passed in and the timebase will retain that runloop. The retained runloop will be used to call CFRunLoopWakeUp() any time the timebase modifies the timer’s fire date.
§Safety
runloop possibly has additional threading requirements.
Sourcepub unsafe fn remove_timer(&self, timer: &CFRunLoopTimer) -> i32
pub unsafe fn remove_timer(&self, timer: &CFRunLoopTimer) -> i32
Removes the timer from the list of timers managed by the timebase.
The timebase will no longer maintain the timer’s “NextFireDate”. If the timer is invalidated, the timebase will eventually remove it from its list and release it even if this function is not called.
Sourcepub unsafe fn set_timer_next_fire_time(
&self,
timer: &CFRunLoopTimer,
fire_time: CMTime,
flags: u32,
) -> i32
Available on crate feature CMTime only.
pub unsafe fn set_timer_next_fire_time( &self, timer: &CFRunLoopTimer, fire_time: CMTime, flags: u32, ) -> i32
CMTime only.Sets the CMTime on the timebase’s timeline at which the timer should next be fired.
The timer must be on the list of timers managed by the timebase. The timebase will continue to update the timer’s “NextFireDate” according to time jumps and effective rate changes. If fireTime is not numeric, or if the timebase is not moving, the “NextFireDate” will be set to a date far, far in the future. <BR
IMPORTANT NOTE: Due to the way that CFRunLoopTimers are implemented, if a timer passes through a state in which it is due to fire, it may fire even if its rescheduled before the runloop runs again. Clients should take care to avoid temporarily scheduling timers in the past. For example, set the timebase’s rate or time before you set the timer’s next fire time, if you are doing both at once. (If setting the timebase’s rate or time might put the timer’s fire time in the past, you may need to set the fire time to kCMTimeInvalid across the timebase change.)
Sourcepub unsafe fn set_timer_to_fire_immediately(
&self,
timer: &CFRunLoopTimer,
) -> i32
pub unsafe fn set_timer_to_fire_immediately( &self, timer: &CFRunLoopTimer, ) -> i32
Sets the timer to fire immediately once, overriding any previous CMTimebaseSetTimerNextFireTime call.
The timer must be on the list of timers managed by the timebase. This is equivalent to calling CFRunLoopTimerSetNextFireDate( timer, CFAbsoluteTimeGetCurrent() ); except that the timebase gets to know that it shouldn’t interfere.
Sourcepub unsafe fn add_timer_dispatch_source(
&self,
timer_source: &DispatchSource,
) -> i32
Available on crate feature dispatch2 only.
pub unsafe fn add_timer_dispatch_source( &self, timer_source: &DispatchSource, ) -> i32
dispatch2 only.Adds the timer dispatch source to the list of timers managed by the timebase.
The timer source must have been created by calling dispatch_source_create( DISPATCH_SOURCE_TYPE_TIMER, 0, 0, some_dispatch_queue ) and should have had an event handler associated with it via dispatch_source_set_event_handler( timerSource, some_handler_block ) or dispatch_source_set_event_handler_f( timerSource, some_handler_function ). Don’t forget to call dispatch_resume( timerSource ) as dispatch sources are created suspended.
The timebase will retain the timer source, and will maintain its start time according to the CMTime set using CMTimebaseSetTimerDispatchSourceNextFireTime. Until the first call to CMTimebaseSetTimerDispatchSourceNextFireTime, the start time will be set to DISPATCH_TIME_FOREVER.
Sourcepub unsafe fn remove_timer_dispatch_source(
&self,
timer_source: &DispatchSource,
) -> i32
Available on crate feature dispatch2 only.
pub unsafe fn remove_timer_dispatch_source( &self, timer_source: &DispatchSource, ) -> i32
dispatch2 only.Removes the timer dispatch source from the list of timers managed by the timebase.
The timebase will no longer maintain the timer source’s start time. If the timer source is cancelled, the timebase will eventually remove it from its list and release it even if this function is not called.
Sourcepub unsafe fn set_timer_dispatch_source_next_fire_time(
&self,
timer_source: &DispatchSource,
fire_time: CMTime,
flags: u32,
) -> i32
Available on crate features CMTime and dispatch2 only.
pub unsafe fn set_timer_dispatch_source_next_fire_time( &self, timer_source: &DispatchSource, fire_time: CMTime, flags: u32, ) -> i32
CMTime and dispatch2 only.Sets the CMTime on the timebase’s timeline at which the timer dispatch source should next be fired.
The timer source must be on the list of timers managed by the timebase. The timebase will continue to update the timer dispatch source’s start time according to time jumps and effective rate changes. If fireTime is not numeric, or if the timebase is not moving, the start time will be set to DISPATCH_TIME_FOREVER. <BR
IMPORTANT NOTE: Due to the way that timer dispatch sources are implemented, if a timer passes through a state in which it is due to fire, it may fire even if its rescheduled before the event handler is run. Clients should take care to avoid temporarily scheduling timers in the past. For example, set the timebase’s rate or time before you set the timer’s next fire time, if you are doing both at once. (If setting the timebase’s rate or time might put the timer’s fire time in the past, you may need to set the fire time to kCMTimeInvalid across the timebase change.)
Sourcepub unsafe fn set_timer_dispatch_source_to_fire_immediately(
&self,
timer_source: &DispatchSource,
) -> i32
Available on crate feature dispatch2 only.
pub unsafe fn set_timer_dispatch_source_to_fire_immediately( &self, timer_source: &DispatchSource, ) -> i32
dispatch2 only.Sets the timer dispatch source to fire immediately once, overriding any previous CMTimebaseSetTimerDispatchSourceNextFireTime call.
The timer source must be on the list of timers managed by the timebase. This is equivalent to calling dispatch_source_set_timer( timerSource, DISPATCH_TIME_NOW, 0, 0 ); except that the timebase gets to know that it shouldn’t interfere.
Source§impl CMTimebase
impl CMTimebase
Sourcepub unsafe fn notification_barrier(&self) -> i32
pub unsafe fn notification_barrier(&self) -> i32
Requests that the timebase wait until it is not posting any notifications.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate feature CMAttachment only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
CMAttachment only.Attempt to downcast the type to that of type T.
This is the reference-variant. Use CFRetained::downcast if you
want to convert a retained type. See also ConcreteType for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
Available on crate feature CMAttachment only.
pub fn retain_count(&self) -> usize
CMAttachment only.Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumbers, small CFStrings etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX in that case.
Trait Implementations§
Source§impl AsRef<AnyObject> for CMTimebase
impl AsRef<AnyObject> for CMTimebase
Source§impl AsRef<CFType> for CMTimebase
impl AsRef<CFType> for CMTimebase
Source§impl AsRef<CMTimebase> for CMTimebase
impl AsRef<CMTimebase> for CMTimebase
Source§impl Borrow<AnyObject> for CMTimebase
impl Borrow<AnyObject> for CMTimebase
Source§impl Borrow<CFType> for CMTimebase
impl Borrow<CFType> for CMTimebase
Source§impl ConcreteType for CMTimebase
impl ConcreteType for CMTimebase
Source§impl Debug for CMTimebase
impl Debug for CMTimebase
Source§impl Deref for CMTimebase
impl Deref for CMTimebase
Source§impl Hash for CMTimebase
impl Hash for CMTimebase
Source§impl Message for CMTimebase
impl Message for CMTimebase
Source§impl PartialEq for CMTimebase
impl PartialEq for CMTimebase
Source§impl RefEncode for CMTimebase
impl RefEncode for CMTimebase
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for CMTimebase
impl Type for CMTimebase
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more