AudioQueueBufferRef in SimplePCMRecorder showing error in swift 3

I want to associate Alexa with an iPhone because I use a sample written in swift 2.2 on Github

So I need to convert it to Swift 3.0

Migrating from Swift 2.2 to Swift 3.0 from xcode, which resolved almost all errors, now the only error that is left is related to AudioQueueBufferRef

Swift 2.2:

self.recorderState = RecorderState(
            setupComplete: false,
            dataFormat: AudioStreamBasicDescription(),
            queue: UnsafeMutablePointer<AudioQueueRef>.alloc(1),
            buffers: Array<AudioQueueBufferRef>(count: numberBuffers, repeatedValue: nil),
            recordFile: AudioFileID(),
            bufferByteSize: 0,
            currentPacket: 0,
            isRunning: false,
            recordPacket: 0,
            errorHandler: nil)

Swift 3.0: (option only buffers)

let audioBufferQueue = Array<AudioQueueBufferRef>(repeating: nil, count: numberBuffers)

and in swift 2.2 it works fine, but in swift 3.0 an error is displayed

/ Users / macbookpro / Downloads / iOS-Alexa-master copy / iOS Alexa / AVS / SimplePCMRecorder.swift: 28: 32: The type of the expression "Array" (aka 'Array>') is ambiguous, more context

SimplePCM Recorder of Swift 2.2 on Github

google stackoverflow, . google , .

- , ?

+4
1

Swift 3 AudioQueueBufferRef? AudioQueueBufferRef:

let buffers = Array<AudioQueueBufferRef?>(repeating: nil, count: numberBuffers)

// and allocate each buffer
for i in 0 ..< buffers.count {
  AudioQueueAllocateBuffer(inQueue!, bufferSize, &buffers[i])
}
0

Source: https://habr.com/ru/post/1672802/


All Articles