OpenAL source continues playing after stopped and deleted
Asked Answered
K

3

6

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?

Kreitman answered 29/8, 2011 at 23:14 Comment(3)
How are you associating each touch event with its corresponding OpenAL sound? Could you be missing turning off one of them?Pete
Could you maybe post the code in your toucheEnded method?Federation
At least you may set gain to 0 before you stop sound. If it continues to play then you definitely miss it.Doall
L
2

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.

Lilas answered 24/6, 2012 at 2:47 Comment(1)
Hi Michael, the same issue happens here. Did you find any solution? So far, my solution is to set a timer 0.03 seconds ahead, and on the timer's callback I check if the source is not playing and the queued buffer count > 0, then I set the buffer to nil and this stops the sound. But this also results in a dirty 'click' sound, as the sound is "hard" stopped and not faded out with reverb as it should.Prindle
P
1

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!

Prindle answered 6/10, 2012 at 20:2 Comment(0)
T
0

The touches[Moved|Ended] are fired when one OR MORE fingers move or end touching. iOS ?has? had a hard limit of 5 fingers any more than that and the events seem to get a bit wonky. If you're colliding with this limit you may need to rethink your implementation.

Since you don't give any implementation details it's hard to assume what error your code may have. I don't know how you are verify all your AL sources have stopped. Perhaps you should increment a global variable when you Start a source and decrement it when you Stop a source, then inspect the variable and make sure it's 0 (IMHO you'll likely see that it's > 0). The max source limit for iOS is 32 but you said you didn't receive an openAL errors... so you are likely not hitting that.

Thamora answered 25/10, 2011 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.