[英]Core Audio error when running on 64-bit processor
處理在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和Internet上搜索了好幾天以試圖弄清這一點。
第一個錯誤可能是由於inNumPackets所致,它被定義為unsigned long
。 在32位進程中, long
為32位,而在64位進程中, long
為64位。 AudioFileWritePackets
的參數需要一個UInt32*
。 您可以在temp變量之間來回進行調用:
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
}
我不確定第二個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.