CMTimebase

Struct CMTimebase 

Source
pub struct CMTimebase { /* private fields */ }
Available on crate feature 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

Source

pub unsafe fn create_with_master_clock( allocator: Option<&CFAllocator>, master_clock: &CMClock, timebase_out: NonNull<*mut CMTimebase>, ) -> i32

👎Deprecated
§Safety

timebase_out must be a valid pointer.

Source

pub unsafe fn create_with_master_timebase( allocator: Option<&CFAllocator>, master_timebase: &CMTimebase, timebase_out: NonNull<*mut CMTimebase>, ) -> i32

👎Deprecated
§Safety

timebase_out must be a valid pointer.

Source

pub unsafe fn master_timebase(&self) -> Option<CFRetained<CMTimebase>>

👎Deprecated
Source

pub unsafe fn master_clock(&self) -> Option<CFRetained<CMClock>>

👎Deprecated
Source

pub unsafe fn master(&self) -> CFRetained<CMClockOrTimebase>

👎Deprecated
Source

pub unsafe fn ultimate_master_clock(&self) -> CFRetained<CMClock>

👎Deprecated
Source

pub unsafe fn get_master_timebase(&self) -> Option<CFRetained<CMTimebase>>

👎Deprecated

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.

Source

pub unsafe fn get_master_clock(&self) -> Option<CFRetained<CMClock>>

👎Deprecated

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.

Source

pub unsafe fn get_master(&self) -> Option<CFRetained<CMClockOrTimebase>>

👎Deprecated

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.

Source

pub unsafe fn get_ultimate_master_clock(&self) -> Option<CFRetained<CMClock>>

👎Deprecated

Returns the source clock that is the source of all of a timebase’s source timebases.

Please use CMTimebaseCopyUltimateSourceClock instead.

Source

pub unsafe fn set_master_clock(&self, new_master_clock: &CMClock) -> i32

👎Deprecated
Source

pub unsafe fn set_master_timebase( &self, new_master_timebase: &CMTimebase, ) -> i32

👎Deprecated
Source

pub unsafe fn time(&self) -> CMTime

Available on crate feature CMTime only.

Retrieves the current time from a timebase.

Source

pub unsafe fn time_with_time_scale( &self, timescale: CMTimeScale, method: CMTimeRoundingMethod, ) -> CMTime

Available on crate feature CMTime only.

Retrieves the current time from a timebase in the specified timescale.

Source

pub unsafe fn set_time(&self, time: CMTime) -> i32

Available on crate feature CMTime only.

Sets the current time of a timebase.

Source

pub unsafe fn set_anchor_time( &self, timebase_time: CMTime, immediate_source_time: CMTime, ) -> i32

Available on crate feature 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).

Source

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.

Source

pub unsafe fn time_and_rate( &self, time_out: *mut CMTime, rate_out: *mut f64, ) -> i32

Available on crate feature 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_out must be a valid pointer or null.
  • rate_out must be a valid pointer or null.
Source

pub unsafe fn set_rate(&self, rate: f64) -> i32

Sets the rate of a timebase.

Source

pub unsafe fn set_rate_and_anchor_time( &self, rate: f64, timebase_time: CMTime, immediate_source_time: CMTime, ) -> i32

Available on crate feature 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.

Source

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);

Source

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.

Source

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.

Source

pub unsafe fn set_timer_next_fire_time( &self, timer: &CFRunLoopTimer, fire_time: CMTime, flags: u32, ) -> i32

Available on crate feature 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.)

Source

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.

Source

pub unsafe fn add_timer_dispatch_source( &self, timer_source: &DispatchSource, ) -> i32

Available on crate feature 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.

Source

pub unsafe fn remove_timer_dispatch_source( &self, timer_source: &DispatchSource, ) -> i32

Available on crate feature 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.

Source

pub 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.

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.)

Source

pub unsafe fn set_timer_dispatch_source_to_fire_immediately( &self, timer_source: &DispatchSource, ) -> i32

Available on crate feature 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

Source

pub unsafe fn notification_barrier(&self) -> i32

Requests that the timebase wait until it is not posting any notifications.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Available on crate feature 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.

Source

pub fn retain_count(&self) -> usize

Available on crate feature 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

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for CMTimebase

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CMTimebase> for CMTimebase

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for CMTimebase

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for CMTimebase

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for CMTimebase

Source§

fn type_id() -> CFTypeID

Returns the CFTypeID for CMTimebase.

Source§

impl Debug for CMTimebase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for CMTimebase

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for CMTimebase

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for CMTimebase

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for CMTimebase

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for CMTimebase

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for CMTimebase

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for CMTimebase

Source§

impl Send for CMTimebase

Source§

impl Sync for CMTimebase

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,