Ensure AudioIODevice plays everything and stops


#1

Hello,

I am playing some sound using AudioIODeviceCallback descendant which provides sample data to

AudioIODevice.  At some point samples are exhausted an I would like to stop the AudioIODevice, but

I would like to make sure that all samples that were sent will finish playing, so I probably should not stop() AudioIODevice immediately.

 

So the questions are:

Does AudioIODevice finish playing all in-system buffers on stop() or it stops immediately (documentation says the device will wait for

the callback to return, but it is unknown if existing buffer is discarded or not)?

If it does not, how to make it play all buffers and then stop()?

 

Sorry if it is also a noob question.

Thanks,

Stepan.


#2

It's totally device-dependent.

Personally, I'd just leave the device running and not worry about it. But if you really do need to close it for some reason, have a timer that closes it a couple of seconds after the activity ceases.