I'm creating an AudioBufferList in Swift. In C, AudioBufferList contains a variable-length array of AudioBuffer objects, while in Swift it instead has a field of type '(AudioBuffer)'.
I'm setting up the AudioBufferList in the following way:
var buffer = [UInt8](count: 1024, repeatedValue: 0)
var audioBufferList = AudioBufferList(
mNumberBuffers: 1,
mBuffers: AudioBuffer(
mNumberChannels: 2,
mDataByteSize: UInt32(buffer.count),
mData: &buffer
)
)
This is working in practice, but I'd like to confirm this is actually correct and is how AudioBufferList is intended to be used in Swift. My searches on the topic have turned up a couple examples similar to the above, but I haven't found any official documentation or authoritative statement that this is how it's supposed to be done. (My concern is that maybe this can't really be expected to work reliably at this time, and that it's only due to circumstance that it's working for me currently.)
Just for peace of mind, can anyone confirm that the above is correct and, provided everything else is done correctly, can be counted on to work?