1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-03 11:30:02 +00:00

Eliminate AudioQueueBufferMaxLength.

This commit is contained in:
Thomas Harte 2022-07-13 15:24:43 -04:00
parent 75f3f1a77f
commit dcb68c16fe

View File

@ -10,8 +10,6 @@
@import AudioToolbox;
#include <stdatomic.h>
#define AudioQueueBufferMaxLength 8192
#define OSSGuard(x) { \
const OSStatus status = x; \
assert(!status); \
@ -45,9 +43,11 @@
_samplingRate = samplingRate;
// Determine preferred buffer size as being the first power of two less than
_preferredBufferSize = AudioQueueBufferMaxLength;
while((Float64)_preferredBufferSize*100.0 > samplingRate) _preferredBufferSize >>= 1;
// Determine preferred buffer size as being the first power of two
// not less than 1/100th of a second.
_preferredBufferSize = 1;
const NSUInteger oneHundredthOfRate = (NSUInteger)(samplingRate / 100.0);
while(_preferredBufferSize < oneHundredthOfRate) _preferredBufferSize <<= 1;
// Describe a 16bit stream of the requested sampling rate.
AudioStreamBasicDescription outputDescription;