[Core Audio Output] Refine output function a bit
Refine the output function a bit, including adding some minor safety checks, in case the caller requests zero samples, or requests a format with zero channels. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
ca6a2f41df
commit
2716ca41b0
|
@ -679,12 +679,16 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
|||
|
||||
_au.outputProvider = ^AUAudioUnitStatus(AudioUnitRenderActionFlags *_Nonnull actionFlags, const AudioTimeStamp *_Nonnull timestamp, AUAudioFrameCount frameCount, NSInteger inputBusNumber, AudioBufferList *_Nonnull inputData) {
|
||||
// This expects multiple buffers, so:
|
||||
if(!frameCount) return 0;
|
||||
|
||||
int i;
|
||||
const int channels = format->mChannelsPerFrame;
|
||||
if(!channels) return 0;
|
||||
|
||||
const int channelsminusone = channels - 1;
|
||||
float buffers[frameCount * format->mChannelsPerFrame];
|
||||
float buffers[frameCount * channels];
|
||||
uint8_t bufferlistbuffer[sizeof(AudioBufferList) + sizeof(AudioBuffer) * channelsminusone];
|
||||
AudioBufferList *ioData = (AudioBufferList *)(bufferlistbuffer);
|
||||
AudioBufferList *ioData = (AudioBufferList *)(&bufferlistbuffer[0]);
|
||||
|
||||
ioData->mNumberBuffers = channels;
|
||||
|
||||
|
|
Loading…
Reference in New Issue