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
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device

Suspending OpenAL

OpenAL works fine on BB10, but suspending the OpenAL thread seems not to do anything, I'm doing the following:

ALCcontext* context = alcGetCurrentContext();
if(context != NULL) {
    alcSuspendContext(context);
    alcMakeContextCurrent(NULL);
}

 

Is there anything else that needs to be done in order for this to work? I want to pause OpenAL when the window is inactive.

 

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

Re: Suspending OpenAL

Here is what I do when my apps enter into background...

ALContext is my OpenAl context that I keep in memory

 

// enter background 

alcMakeContextCurrent(NULL);

alcProcessContext(ALContext);

 

// exit background

alcMakeContextCurrent(ALContext);

alcProcessContext(ALContext);

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

Re: Suspending OpenAL

So that just seems to work? alcProcessContext is meant to be used to initiate a context. Is alcSuspendContext no-op for you as well?

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

Re: Suspending OpenAL

I don't use alcSuspendContext.

BTW, I'm using my OpenAL engine on PC/Mac/iOS/BB10 and this seems to work everywhere. I can't remember where I find this, but I didn't make it myself, so this is probably th recommand way to do it.

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

Re: Suspending OpenAL

Does this work on iOS? I use alcSuspendContext on iOS and Android. Anyways will look into this, will get back to this thread if it does not work.

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

Re: Suspending OpenAL

> Does this work on iOS?

I am using the exact same code on all these platforms for OpenAL.

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

Re: Suspending OpenAL

It doesn't work for me. If I have a looping source, it just continues to loop. This is what I'm doing:

ALCcontext* context = alcGetCurrentContext();
if(context != NULL) {
        alcMakeContextCurrent(NULL);
        alcProcessContext(context);
}

 

If you set every sound source to looping and run this code, does it stop the sounds and suspend the openal thread?

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

Re: Suspending OpenAL

It does work for me for everything.

 

The only difference I have with you is that I am storing the context at creation time (you call context = alcGetCurrentContext(); instead).

I've packed the Audio files from my engine, so you might to see what the difference between you and me:

http://www.ovogame.com/Misc/VDAudio.zip

 

JC

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

Re: Suspending OpenAL

Thanks JC, I will have a look at it.

 

This is how I'm creating a context:

ALboolean result = alutInit(NULL, NULL);

 

alutInit should run the same lines as you do in OpenSys, the important one being alcMakeContextCurrent(ALContext, because that is the ptr that alcGetCurrentContext() returns.

 

Strange, will create the context without alut and see if there is any difference.

 

 

Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device

Re: Suspending OpenAL

I'm doing the same thing as you and it still does not work. Are you sure that you have tried it with a looping sound source?

 

Johan