2016-01-15 01:33:22 +00:00
|
|
|
//
|
|
|
|
// AudioQueue.h
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 14/01/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-01-15 01:33:22 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2016-06-15 12:07:25 +00:00
|
|
|
@class CSAudioQueue;
|
2016-06-15 11:35:34 +00:00
|
|
|
|
2016-06-17 00:51:35 +00:00
|
|
|
@protocol CSAudioQueueDelegate
|
2016-10-17 12:18:32 +00:00
|
|
|
- (void)audioQueueIsRunningDry:(nonnull CSAudioQueue *)audioQueue;
|
2016-06-15 11:35:34 +00:00
|
|
|
@end
|
|
|
|
|
2016-10-10 11:42:24 +00:00
|
|
|
/*!
|
|
|
|
CSAudioQueue provides an audio queue to which packets of arbitrary size may be appended;
|
|
|
|
it can notify a delegate each time a buffer is completed and offer advice as to the preferred
|
|
|
|
output sampling rate and a manageable buffer size for this machine.
|
|
|
|
*/
|
2016-06-15 12:07:25 +00:00
|
|
|
@interface CSAudioQueue : NSObject
|
2016-01-15 01:33:22 +00:00
|
|
|
|
2016-10-10 11:42:24 +00:00
|
|
|
/*!
|
|
|
|
Creates an instance of CSAudioQueue.
|
|
|
|
|
|
|
|
@param samplingRate The output audio rate.
|
2020-02-16 19:05:50 +00:00
|
|
|
@param isStereo @c YES if audio buffers will contain stereo audio, @c NO otherwise.
|
2016-10-10 11:42:24 +00:00
|
|
|
|
|
|
|
@returns An instance of CSAudioQueue if successful; @c nil otherwise.
|
|
|
|
*/
|
2022-07-12 19:03:35 +00:00
|
|
|
- (nullable instancetype)initWithSamplingRate:(Float64)samplingRate isStereo:(BOOL)isStereo NS_DESIGNATED_INITIALIZER;
|
2020-02-16 19:05:50 +00:00
|
|
|
- (nonnull instancetype)init __attribute((unavailable));
|
2016-10-10 11:42:24 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Enqueues a buffer for playback.
|
|
|
|
|
|
|
|
@param buffer A pointer to the data that comprises the buffer.
|
|
|
|
*/
|
2022-07-14 18:34:11 +00:00
|
|
|
- (void)enqueueAudioBuffer:(nonnull const int16_t *)buffer;
|
2016-01-15 01:33:22 +00:00
|
|
|
|
2016-10-10 11:42:24 +00:00
|
|
|
/// @returns The sampling rate at which this queue is playing audio.
|
2016-06-01 23:04:07 +00:00
|
|
|
@property (nonatomic, readonly) Float64 samplingRate;
|
2016-10-10 11:42:24 +00:00
|
|
|
|
|
|
|
/// A delegate, if set, will receive notification upon the completion of each enqueue buffer.
|
2016-06-23 13:37:49 +00:00
|
|
|
@property (nonatomic, weak, nullable) id<CSAudioQueueDelegate> delegate;
|
2016-06-01 23:04:07 +00:00
|
|
|
|
2016-10-10 11:42:24 +00:00
|
|
|
/*!
|
|
|
|
@returns The ideal output sampling rate for this computer; likely to be 44.1Khz or
|
|
|
|
48Khz or 96Khz or one of the other comon numbers but not guaranteed to be.
|
|
|
|
*/
|
2016-06-01 23:04:07 +00:00
|
|
|
+ (Float64)preferredSamplingRate;
|
2016-10-10 11:42:24 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns A selected preferred buffer size (in samples). If an owner cannot otherwise
|
|
|
|
decide in what size to enqueue audio, this is a helpful suggestion.
|
|
|
|
*/
|
2016-10-10 11:30:00 +00:00
|
|
|
@property (nonatomic, readonly) NSUInteger preferredBufferSize;
|
2016-06-01 23:04:07 +00:00
|
|
|
|
2022-07-14 18:34:11 +00:00
|
|
|
/*!
|
|
|
|
Sets the size of buffers to be posted, in samplrs.
|
|
|
|
*/
|
|
|
|
@property (nonatomic) NSUInteger bufferSize;
|
|
|
|
|
2022-07-09 17:33:46 +00:00
|
|
|
/*!
|
|
|
|
@returns @C YES if this queue is running low or is completely exhausted of new audio buffers.
|
|
|
|
*/
|
|
|
|
@property (atomic, readonly) BOOL isRunningDry;
|
|
|
|
|
2016-01-15 01:33:22 +00:00
|
|
|
@end
|