2017-05-14 13 views
0

주파수를 재생하려면 https://github.com/AlesTsurko/LearningCoreAudioWithSwift2.0/tree/master/CH05_Player 을 따르고 있지만 Swift2를 사용하고 있습니다. Get microphone input using Audio Queue in Swift 3은 많은 문제를 해결했지만 녹화 용입니다.Swift3 AudioToolbox : PCM에서 AudioQueueAllocateBuffer를 재생하는 방법은 무엇입니까?

I 그것은 오류를

main.swift:152:29: Expression type '[AudioQueueBufferRef]' is ambiguous without more context 
main.swift:153:20: Cannot pass immutable value as inout argument: implicit conversion from 'AudioQueueBufferRef' to 'AudioQueueBufferRef?' requires a temporary 

--After Spads 'answer--

var ringBuffers = [AudioQueueBufferRef?](repeating:nil, count:3) 
let status = AudioQueueAllocateBuffer(inQueue!, bufferSize, &ringBuffers[0]) 
print("\(status.description)") 

인쇄

제공

var ringBuffers = [AudioQueueBufferRef](repeating:nil, count:3) 
AudioQueueAllocateBuffer(inQueue!, bufferSize, &ringBuffers[0]) 

오디오 큐 버퍼 할당에 붙어

vm_map failed: 0x4 ((os/kern) invalid argument) 
4 
내가 사용한

오디오 설명은 AudioQueueBufferRef의 배열이 안

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) 

답변

1

입니까? 대신 AudioQueueBufferRef

var ringBuffers = [AudioQueueBufferRef?](repeating:nil, count:3) 
AudioQueueAllocateBuffer(inQueue!, bufferSize, &ringBuffers[0]) 
+0

의 그것이 내가 코드 – neckTwi

+0

를 마무리 다시 얻을 것이다 ... 모든 그게 전부 보이지만 vm_map 실패'주고 먹으 렴 : 0x4로에게 ((OS/컨) 잘못된 인수) '런타임 오류와' – neckTwi

+1

을 감안할 AudioQueueAllocateBuffer' 질문에 대한 업데이트 AudioQueueBufferRef로 컴파일 할 수 없습니다! . AudioQueueBufferRef가되어야합니까? – Spads