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?

Johan Bilien
  • 412
  • 2
  • 12

3 Answers3

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.

  • 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. – urish Jun 30 '12 at 12:16
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!

urish
  • 8,943
  • 8
  • 54
  • 75
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.

Louis Ricci
  • 20,804
  • 5
  • 48
  • 62