我正在使用MixerHostAudio同时加载多个音频文件。
我无法加载整个文件到内存,因为应用程序崩溃!
有没有人能帮我实现一个缓冲这些文件的算法?
或者至少给我举个例子?
我设法做到了这一点:
I PinPointed在其中调用渲染函数的代码:
UInt32 numberOfPacketsToRead = (UInt32) totalFramesInFile;
result = ExtAudioFileRead (audioFileObject, &numberOfPacketsToRead, bufferList);
free (bufferList);
if (noErr != result) {
[self printErrorMessage: @"ExtAudioFileRead failure - " withStatus: result];
// If reading from the file failed, then free the memory for the sound buffer.
free (soundStructArray[audioFile].audioDataLeft);
soundStructArray[audioFile].audioDataLeft = 0;
if (2 == channelCount) {
free (soundStructArray[audioFile].audioDataRight);
soundStructArray[audioFile].audioDataRight = 0;
}
ExtAudioFileDispose (audioFileObject);
return;
}-现在我只遗漏了缓冲完成时的部分,我可以告诉程序获取下一个块……
有什么想法吗?
谢谢
赫尔南
发布于 2011-09-14 17:45:58
您需要使用环形缓冲区来处理您的音频。
这里有一个简单的例子。
ring buffer
https://stackoverflow.com/questions/6103597
复制相似问题