停止并快速重播AudioQueue [英] Stopping and Quickly Replaying an AudioQueue

查看:224
本文介绍了停止并快速重播AudioQueue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在播放,停止,暂停的音频队列,但是我发现AudioQueueStop()函数需要花费很长时间才能执行.

I've got an audio queue that I've got playing, stopping, pausing correctly but I'm finding the AudioQueueStop() function to be taking a long time to execute.

我想立即停止然后重新开始播放音频队列,并且想知道最快的方法是什么.

I'd like to immediately stop and then restart playing an audio queue and was wondering what the quickest way to do so would be.

在我的项目中,我有多个音频队列,可以反复播放特定的声音.在某些情况下,我必须停止其中的某些声音,然后立即播放它们,并立即播放更多声音.如果我只对几个音频队列执行操作,还不错,但是如果我需要停止并重新启动许多音频队列,则开始会花费很长时间.

In my project I have multiple audio queues that I keep around to play specific sounds over and over. There is a situation where I must stop some of those sounds and then immediately play them and many more at once. It isn't so bad if there are only a couple of audio queues that I do this to but it starts taking a long long time if there are many that I need to stop and restart.

我可以通过在音频队列上调用stop来伪造它,然后创建一个具有相同声音的新声音,但是我想知道是否有更好的方法可以做到这一点.

I could fake it by calling stop on an audio queue and then creating a new one with the same sound but was wondering if there was a better way to do so.

推荐答案

AudioQueue对于此类内容可能会比较混乱.停止队列中间缓冲区很困难,这意味着当前缓冲区将继续播放.另外,您还必须处理延迟问题.

AudioQueue can be messy for that sort of stuff. It's difficult to stop the queue mid-buffer, and that means the current buffer will continue to play. Plus you have to deal with latency issues.

为实现快速停止和低延迟播放,我建议您使用RemoteIO AudioUnit.

For fast stop and playback with low latency, I'd advise using the RemoteIO AudioUnit.

您可以在此处找到包含代码的出色教程:

You can find a great tutorial with code here:

使用RemoteIO音频单元

这篇关于停止并快速重播AudioQueue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆