问题
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