Stop and play AudioQueue fast

I have an audio queue that I play, stopping, pausing correctly, but I find that the AudioQueueStop () function is time consuming.

I would like to immediately stop and then start the audio queue again, and I was wondering what the fastest way to do this.

In my project, I have several audio bursts that I keep around to play certain sounds over and over. There is a situation where I have to stop some of these sounds, and then immediately play them and many more times. This is not so bad if there are only a few audio queues that I do, but it starts for a long time, if there is a lot that I need to stop and restart.

I could fake it by calling a stop in the audio queue and then creating a new one with the same sound, but wondered if there was a better way to do this.

+3
source share
1 answer

AudioQueuecan be dirty for this kind of thing. The middle buffer cannot be stopped, and this means that the current buffer will continue to play. In addition, you have to deal with latency issues.

For quick stop and low latency playback, I would recommend using RemoteIO AudioUnit.

You can find a great tutorial with code here:

Using a RemoteIO Audio Device

+2
source

Source: https://habr.com/ru/post/1783730/


All Articles