ringBuffers = [AudioQueueBufferRef](repeating: AudioQueueBufferRef(), count:inflightBuffersCount)
says init() is unavailable: use 'nil' literal
but if it is
ringBuffers = [AudioQueueBufferRef](repeating: nil, count: inflightBuffersCount)
it says
main.swift:152:29: Expression type '[AudioQueueBufferRef]' is ambiguous without more context
if it is
var ringBuffers = [AudioQueueBufferRef!](repeating:nil, count:3)
let status = AudioQueueAllocateBuffer(inQueue!, bufferSize, &ringBuffers[0])
print("\(status.description)")
prints
vm_map failed: 0x4 ((os/kern) invalid argument)
4
I think assigning nil
is not right
Stream description I have used is
let inFormat = AudioStreamBasicDescription(
mSampleRate: Double(sampleRate),
mFormatID: kAudioFormatLinearPCM,
mFormatFlags: kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked,
mBytesPerPacket: UInt32(numChannels * MemoryLayout<UInt16>.size),
mFramesPerPacket: 1,
mBytesPerFrame: UInt32(numChannels * MemoryLayout<UInt16>.size),
mChannelsPerFrame: UInt32(numChannels),
mBitsPerChannel: UInt32(8 * (MemoryLayout<UInt16>.size)),
mReserved: UInt32(0)
)
AudioQueueNewOutput(&inFormat, AQOutputCallback, &player, nil, nil, 0, &inQueue)