Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenAL source continues playing after stopped and deleted

Tags:

ios

openal

Our ipad application plays a bunch of OpenAL sources in parallel, one for each ongoing touch. The sources are created and started on touchesMoved, and stopped on touchesEnded or touchesCancelled.

Things seem to work fine, except for a bug where sometimes one source seems to continue playing after the touch ends. This seems to happen only when generating a lot of touch events.

I have verified that when this happens, all my AL sources have been stopped with alSourceStop and have been destroyed with alDeleteSources. OpenAL is not reporting any error. Yet the sound doesn't stop.

I'm starting to think this might be a bug in the iOS implementation of OpenAL. Has anyone seen something like that?

like image 205
Johan Bilien Avatar asked Aug 29 '11 23:08

Johan Bilien


2 Answers

I'm having the same OpenAL issue myself with the new reverb features enabled on an iPad 2 and iOS 5. I can absolute confirm that Play/Stop commands for the same sound are paired up, and the issue occurs even if you don't reuse sources. Delaying stop doesn't help, nor does monitoring for state transition on a spawned thread with GCD. No idea how to proceed, but thought I'd pass along my observations while debugging this issue.

like image 155
Michael Eskin Avatar answered Oct 07 '22 04:10

Michael Eskin


you may find the following solution helpful. I have been experiencing the same problem with my App, and so far, the best solution I have found is to simply create an "silence" openal source (a source with a buffer of silence, that is - full of zeroes), and play it always after I stop a sound.

This seems to fix the problem of sounds that continues playing even after a stop command, though it does introduce a small 'click' occasionally. In any case, I found a small 'click' more tolerable than having the sound continue when it's supposed to be stopped...

Hope this helps somebody out there!

like image 44
urish Avatar answered Oct 07 '22 04:10

urish