AEBlockScheduler Class Reference

Block scheduler. More...

#import <AEBlockScheduler.h>

Inherits <NSObject>, and <AEAudioTimingReceiver>.

Instance Methods

(id) - initWithAudioController:
 Initialize.
 
(void) - scheduleBlock:atTime:timingContext:identifier:
 Schedule a block for execution.
 
(void) - scheduleBlock:atTime:timingContext:identifier:mainThreadResponseBlock:
 Schedule a block for execution, with a response block to be performed on the main thread.
 
(NSArray *) - schedules
 Obtain a list of schedules awaiting execution.
 
(NSDictionary *) - infoForScheduleWithIdentifier:
 Obtain information about a particular schedule.
 
(void) - cancelScheduleWithIdentifier:
 Cancel a given schedule, so that it will not be performed.
 

Class Methods

(uint64_t) + now
 Utility: Get current time.
 
(uint64_t) + hostTicksFromSeconds:
 Utility: Convert time in seconds to host ticks.
 
(NSTimeInterval) + secondsFromHostTicks:
 Utility: Convert time in host ticks to seconds.
 
(uint64_t) + timestampWithSecondsFromNow:
 Utility: Create a timestamp in host ticks the given number of seconds in the future.
 
(uint64_t) + timestampWithSeconds:fromTimestamp:
 Utility: Create a timestamp in host ticks the given number of seconds from a timestamp.
 
(NSTimeInterval) + secondsUntilTimestamp:
 Utility: Determine the number of seconds until a given timestamp.
 

Additional Inherited Members

- Properties inherited from <AEAudioTimingReceiver>
AEAudioTimingCallback timingReceiverCallback
 Reference to the receiver callback.
 

Detailed Description

Block scheduler.

This class allows you to schedule blocks to be performed at a particular time, on the Core Audio thread.

To use this class, create an instance, then add it as a timing receiver using AEAudioController's addTimingReceiver: .

Then begin scheduling blocks using scheduleBlock:atTime:timingContext:identifier:.

Method Documentation

+ (uint64_t) now

Utility: Get current time.

+ (uint64_t) hostTicksFromSeconds: (NSTimeInterval)  seconds

Utility: Convert time in seconds to host ticks.

+ (NSTimeInterval) secondsFromHostTicks: (uint64_t)  ticks

Utility: Convert time in host ticks to seconds.

+ (uint64_t) timestampWithSecondsFromNow: (NSTimeInterval)  seconds

Utility: Create a timestamp in host ticks the given number of seconds in the future.

+ (uint64_t) timestampWithSeconds: (NSTimeInterval)  seconds
fromTimestamp: (uint64_t)  timeStamp 

Utility: Create a timestamp in host ticks the given number of seconds from a timestamp.

+ (NSTimeInterval) secondsUntilTimestamp: (uint64_t)  timestamp

Utility: Determine the number of seconds until a given timestamp.

- (id) initWithAudioController: (AEAudioController *)  audioController

Initialize.

Parameters
audioControllerThe audio controller
- (void) scheduleBlock: (AEBlockSchedulerBlock block
atTime: (uint64_t)  time
timingContext: (AEAudioTimingContext context
identifier: (id< NSCopying >)  identifier 

Schedule a block for execution.

Once scheduled, the given block will be performed at or before the given time. Depending on the hardware buffer duration, this may occur some milliseconds before the scheduled time.

The actual time corresponding to the beginning of the time interval in which the scheduled block was actually invoked will be passed to the block as an argument, as well as the number of frames into the time interval that the block is scheduled.

Blocks that are to be performed during the same time interval will be performed in the order in which they were scheduled.

VERY IMPORTANT NOTE: This block will be invoked on the Core Audio thread. You must never call any Objective-C methods, allocate or free memory, or hold locks within this block, or you will cause audio glitches to occur.

Parameters
blockBlock to perform
timeTime at which block will be performed, in host ticks
contextTiming context
identifierAn identifier used to refer to the schedule later, if necessary (may not be nil)
- (void) scheduleBlock: (AEBlockSchedulerBlock block
atTime: (uint64_t)  time
timingContext: (AEAudioTimingContext context
identifier: (id< NSCopying >)  identifier
mainThreadResponseBlock: (AEBlockSchedulerResponseBlock response 

Schedule a block for execution, with a response block to be performed on the main thread.

Once scheduled, the given block will be performed at or before the given time. Depending on the hardware buffer duration, this may occur some milliseconds before the scheduled time.

The actual time corresponding to the beginning of the time interval in which the scheduled block was actually invoked will be passed to the block as an argument, as well as the number of frames into the time interval that the block is scheduled.

Blocks that are to be performed during the same time interval will be performed in the order in which they were scheduled.

VERY IMPORTANT NOTE: This block will be invoked on the Core Audio thread. You must never call any Objective-C methods, allocate or free memory, or hold locks within this block, or you will cause audio glitches to occur.

Once the schedule has finished, the response block will be performed on the main thread.

Parameters
blockBlock to perform
timeTime at which block will be performed, in host ticks
contextTiming context
identifierAn identifier used to refer to the schedule later, if necessary (may not be nil)
responseA block to be performed on the main thread after the main block has been performed
- (NSArray*) schedules

Obtain a list of schedules awaiting execution.

This will return an array of schedule identifiers, which you passed as the 'identifier' parameter when scheduling.

Returns
Array of block identifiers
- (NSDictionary*) infoForScheduleWithIdentifier: (id< NSCopying >)  identifier

Obtain information about a particular schedule.

This will return a dictionary with information about the schedule associated with the given identifier.

- (void) cancelScheduleWithIdentifier: (id< NSCopying >)  identifier

Cancel a given schedule, so that it will not be performed.

Note: If you have scheduled multiple blocks with the same identifier, all of these blocks will be cancelled.

Parameters
identifierThe schedule identifier

The documentation for this class was generated from the following file: