Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
Ovogame
Posts: 54
Registered: ‎10-19-2012
My Device: Playbook, DevAlpha

Re: Suspending OpenAL

> 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?

 

 

http://www.ovogame.com/bb
Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device

Re: Suspending OpenAL

No I changed them to pure openal but unfortunantly it still does not work, I'm doing the exact same setup code as you.
Please use plain text.
Regular Contributor
Ovogame
Posts: 54
Registered: ‎10-19-2012
My Device: Playbook, DevAlpha

Re: Suspending OpenAL

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

http://www.ovogame.com/bb
Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device

Re: Suspending OpenAL

Yeah time is running out for me here, don't think that I have time to debug this further but I will see this weekend if I have time to create small example.

No extra threads, the game does everything on the main thread
Please use plain text.
Regular Contributor
Ovogame
Posts: 54
Registered: ‎10-19-2012
My Device: Playbook, DevAlpha

Re: Suspending OpenAL

Just one last question: how do you activate the "suspend" and what is your device?

http://www.ovogame.com/bb
Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device

Re: Suspending OpenAL

I activate it by when I get the WINDOW_INACTIVE event.

I have an alpha device
Please use plain text.
Regular Contributor
Ovogame
Posts: 54
Registered: ‎10-19-2012
My Device: Playbook, DevAlpha

Re: Suspending OpenAL

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.

http://www.ovogame.com/bb
Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device

Re: Suspending OpenAL

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

Please use plain text.
Regular Contributor
Ovogame
Posts: 54
Registered: ‎10-19-2012
My Device: Playbook, DevAlpha

Re: Suspending OpenAL

>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.

http://www.ovogame.com/bb
Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device

Re: Suspending OpenAL

>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 :smileysad:.

 

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

Please use plain text.