Stopping and Quickly Replaying an AudioQueue

匆匆过客 提交于 2020-01-13 16:26:50

问题


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.

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.


回答1:


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.

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

You can find a great tutorial with code here:

Using RemoteIO audio unit



来源:https://stackoverflow.com/questions/4609480/stopping-and-quickly-replaying-an-audioqueue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!