使用在iOS中引入64位处理器之前编写的一些Core Audio代码。该应用程序在32位处理器上编译并运行良好,但是当我尝试在iPhone 5s上运行时,我得到两个编译器错误。
AQRecorderState ars;
static void AQInputCallback(void *aqRecorderState, // AQRecorderState struct
AudioQueueRef inQ,
AudioQueueBufferRef inBuffer,
const AudioTimeStamp *timestamp,
unsigned long inNumPackets,
const AudioStreamPacketDescription *mDataFormat){
AQRecorderState *pArs = (AQRecorderState *)aqRecorderState;
if (inNumPackets == 0 && pArs->mDataFormat.mBytesPerPacket != 0)
inNumPackets = inBuffer->mAudioDataByteSize / pArs->mDataFormat.mBytesPerPacket;
// This line returns an error "No matching function call for 'AudioFileWritePackets'"
if (AudioFileWritePackets(pArs->mAudioFile,
false,
inBuffer->mAudioDataByteSize,
mDataFormat,
pArs->mCurrentPacket,
&inNumPackets,
inBuffer->mAudioData) == noErr){
pArs->mCurrentPacket += inNumPackets; // advance packet index pointer
}
// don't re-queue the sound buffers if stop has been pressed
if (!pArs->mIsRunning)
return;
// send the buffer back to the queue for more data
AudioQueueEnqueueBuffer(pArs->mQueue, inBuffer, 0, NULL);
}
尝试创建新的音频队列时出现相同的错误。我相信这是因为AQInputCallback线......
// Error: No matching function for call to 'AudioQueueNewInput'
AudioQueueNewInput(&ars.mDataFormat,
AQInputCallback,
&ars,
NULL,
kCFRunLoopCommonModes,
0,
&ars.mQueue);
感谢您的帮助!我已经多次阅读了学习核心音频书,并搜索了SO和互联网几天试图解决这个问题。
答案 0 :(得分:1)
第一个错误可能是由inNumPackets引起的,其定义为unsigned long
。在32位进程中long
是32位,而在64位进程中long
是64位。 AudioFileWritePackets
中的参数需要UInt32*
。你可以通过一个临时变量来进行调用:
UInt32 inNumPacketsTmp = inNumPackets;
if (AudioFileWritePackets(pArs->mAudioFile,
false,
inBuffer->mAudioDataByteSize,
mDataFormat,
pArs->mCurrentPacket,
&inNumPacketsTemp,
inBuffer->mAudioData) == noErr){
inNumPackets = inNumPacketsTmp;
pArs->mCurrentPacket += inNumPackets; // advance packet index pointer
}
我不确定第二个。