Main thread message endpoint. More...
#import <AEMainThreadEndpoint.h>
Inherits NSObject.
Instance Methods | |
(instancetype _Nullable) | - initWithHandler: |
Default initializer. | |
(instancetype _Nullable) | - initWithHandler:bufferCapacity: |
Initializer with custom buffer capacity. | |
(BOOL) | - AEMainThreadEndpointSend |
Send a message to the main thread endpoint. | |
(void *_Nullable) | - AEMainThreadEndpointCreateMessage |
Prepare a new message. | |
(void) | - AEMainThreadEndpointDispatchMessage |
Dispatch a message created with AEMainThreadEndpointCreateMessage. | |
Main thread message endpoint.
This class implements a mechanism to receive messages from the audio thread upon the main thread. Initialize an instance, and pass in a block to call to handle incoming messages. Then use AEMainThreadEndpointSend from the audio thread to send a message to the main thread.
Use this utility to perform synchronization across the audio and main threads.
You can also use the AEAudioThreadEndpoint class to perform messaging in the reverse direction.
- (instancetype _Nullable) initWithHandler: | (AEMainThreadEndpointHandler _Nonnull) | handler |
Default initializer.
handler | The handler block to use for incoming messages |
- (instancetype _Nullable) initWithHandler: | (AEMainThreadEndpointHandler _Nonnull) | handler | |
bufferCapacity: | (size_t) | bufferCapacity | |
Initializer with custom buffer capacity.
handler | The handler block to use for incoming messages |
bufferCapacity | The buffer capacity, in bytes (default is 8192 bytes). Note that due to the underlying implementation, actual capacity may be larger. |
- (BOOL) AEMainThreadEndpointSend | (__unsafe_unretained AEMainThreadEndpoint *_Nonnull) | endpoint | |
(const void *_Nullable) | data | ||
(size_t) | length | ||
Send a message to the main thread endpoint.
Use this on the audio thread to send messages to the endpoint instance. It will be received and handled on the main thread.
endpoint | The endpoint instance |
data | Message data (or NULL) to copy |
length | Length of message data |
- (void* _Nullable) AEMainThreadEndpointCreateMessage | (__unsafe_unretained AEMainThreadEndpoint *_Nonnull) | endpoint | |
(size_t) | length | ||
Prepare a new message.
Use this function to gain access to a writable message buffer of the given length, to assemble the message in multiple parts. Then call AEMainThreadEndpointDispatchMessage to dispatch.
endpoint | The endpoint instance |
length | Length of message data |
- (void) AEMainThreadEndpointDispatchMessage | (__unsafe_unretained AEMainThreadEndpoint *_Nonnull) | endpoint |
Dispatch a message created with AEMainThreadEndpointCreateMessage.
endpoint | The endpoint instance |