Re: Openal Conext switch
Eric Wing <[email protected]>
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <[email protected]> |
On 8/18/10, Susmith M R (RBEI/ECF1) <[email protected]> wrote: > > Hi all, > I have created one openal based streamer in iphone. OpenAL initialization > part ( ie. Opening the device, creating the context and making the context ) > is done in Iphone HMI part ( .mm files ). In the openal streamer, I have a > thread which is always running when the data is available in my queue. This > streamer will use the context set by the iphone hmi and execute all the al > commands. > But when some interruption comes (Screen Lock,sleep), AudioSession will > analyze it and do the openal context suspend or resume. This time also the > streamer thread will be executing the al commands. When the context become > suspended or becomes null what will happen to the alcommands? > I read some documents from iphone programming that al command will still > continue to run without effect. But is there any possible way to get a > notification from the openal side or audiosession side that my context is > null? Since my application is in a infinite poll loop, I can't always check > "whether the context is null or not null? Is there any possible solution to > this? > > Best Regards, > Susmith MR On iPhone, alcSuspendContext() is actually no-op, so don't expect it to do anything for you at the moment. To handle an AudioSession interruption, setting the current context to NULL is the part that happens to actually do anything in the current implementation. But when you do this, I believe your subsequent calls to AL commands will trigger OpenAL errors (use alGetError() to see them). The commands will not actually work. I haven't seen a program actually crash because of these, but you probably should avoid them. I think the only real solution to this is to check if the current context is NULL before you invoke any AL commands. You can call alcGetCurrentContext() to find out if the context is NULL. I talk a little bit about this in my book at the end of Chapter 10. Also as a novelty, I show how to queue commands using NSInvocation, to be invoked later when the context becomes valid again. -Eric http://playcontrol.net/iphonegamebook/ _______________________________________________ Openal mailing list [email protected] http://opensource.creative.com/mailman/listinfo/openal