首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在iOS的多通道混音器中实现缓冲?

如何在iOS的多通道混音器中实现缓冲?
EN

Stack Overflow用户
提问于 2011-05-24 06:07:50
回答 1查看 598关注 0票数 1

我正在使用MixerHostAudio同时加载多个音频文件。

我无法加载整个文件到内存,因为应用程序崩溃!

有没有人能帮我实现一个缓冲这些文件的算法?

或者至少给我举个例子?

我设法做到了这一点:

I PinPointed在其中调用渲染函数的代码:

代码语言:javascript
复制
    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;
    }

-现在我只遗漏了缓冲完成时的部分,我可以告诉程序获取下一个块……

有什么想法吗?

谢谢

赫尔南

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-14 17:45:58

您需要使用环形缓冲区来处理您的音频。

这里有一个简单的例子。

ring buffer

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6103597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档