11-23-2012 02:17 AM
> Are you sure that you have tried it with a looping sound source?
Yes, I am sure. I just tested it again by forcing all the sound in my games to be looping. I've been using this for a while on many platforms, it does work. My guess is that you are not doing everything like me. Are you sure you are not using other high level functions like alutInit in your code?
11-23-2012 08:33 AM
11-23-2012 08:54 AM
Are you doing it in a different thread? Can you compile a small project with the pb, I'll see if I can find the pb... but might be hard to find the time...
JC
11-23-2012 10:38 AM
11-23-2012 10:39 AM
Just one last question: how do you activate the "suspend" and what is your device?
11-23-2012 03:25 PM
11-23-2012 04:09 PM
I just realise that My func enter background is only call on iOS when the os is putting my app in the background. Actually, when the game lost focus I'm doing something different. Sorry about that.
After searching the web, it looks like alcSuspendContext doesn't work nicely everywhere.
You should have a list of all your sample playing, So, you might go through each of them and pause them with alSourcePause, when you come back , you go throught all of them and call alSourcePlay to restart them from where they were paused.
11-23-2012 09:32 PM
Yeah, well....I don't have any long sounds that are not looped so I'm going with muting with alListener.
There are other problems with this approach. I do not know how bb10 mixes sounds on a low level, but having an openal thread running when you switch to other games or play audio or do any kind of mixing should screw up the system in certain cases.
Imagine opening 10 games, all of them running their openAL threads and mixing audio.....
If the openal code is open source for bb10, I'd be happy to fix it. Had to do it for android port of openal soft...
Johan
11-24-2012 03:01 AM
>Imagine opening 10 games, all of them running their openAL threads and mixing audio
If you pause every open channels, the thread will do the minimum amount of work (it is still running but actually doing nothing subtential).
I think Apple is handling this nicely, by letting the dev choosing if their apps is running or not in the background. I don't have any app that need to run in the background. At the moment, if I detect that they lost their focus, I put the apps to sleep, same thing with my streaming thread. Basically, trying to save as much CPU as possible.
11-24-2012 11:24 AM
>If you pause every open channels, the thread will do the minimum amount of work (it is still running >but actually doing nothing subtential).
Yeah! You would think that, but it all depends on the implementation. The android port of openal soft did not do that
.
Most implementations just poll for new things to mix and avoid mixing if there are no sources playing, but that might even be worse because you have a thread doing basically this:
while(1) {
if(stuffToMix) {
mix()
}
}
This while loop should use more CPU if stuffToMix is false rather than if it is true, because mix() should block because of hardware/system calls.
So....10 games running should result in 10 while(1) loops fighting for cpu time.
Yeah apple suspends their openal thread if you lock screen/press home button, but they do not do this if you receive a phone call and you will lose the openal context if you do.
Johan
Johan