Re: OpenAl for streaming
Eric Wing <[email protected]>
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <[email protected]> |
On 7/27/10, Susmith M R (RBEI/ECF1) <[email protected]> wrote: > Hi everyone, > > I am developing an OpenAL based application for iPhone. > > When I use alSourceUnqueueBuffers in a loop I get the same unqueued BufferID > for the immediately-next alSourceUnqueueBuffers command. Since I am using a > bufferID list to reuse the bufferIDs for my application, there is no need to > recreate or delete the buffers. I have already created a set of buffers > during the initialization of my application. After unqueuing the buffer from > the OpenAl queue I use the unqueued bufferIDs to fill new buffer data using > albufferdata and then queue it to OpenAL. I don't know when exactly the > buffer will be freed. Please refer > http://old.nabble.com/Why-does-alDeleteBuffers-gives-a-AL_INVALID_OPERATION-error--td22632832.html. > Can this result in any internal conflict in OpenAL state? alBufferData and > alSourceQueueBuffer are not returning any error. > > Is there any way to know the completion of the command > alSourceUnqueueBuffers? > Reusing the buffer is fine. I think of it like malloc and free. You use malloc to allocate a block of memory. You write over and over again to that same block of memory for reuse. But when you are finally done, you need to free that block of memory. If you stick to standard OpenAL, I don't think you need to expect alSourceUnqueueBuffers to have a race condition unless Apple has a bug, in which case you should file a bug report. However, if you are using the iPhone OpenAL extension, alBufferDataStatic, then you have to worry about alDeleteBuffers failing. It is not just limited to alSourceUnqueueBuffers either. alDeleteBuffers will be your pinch point. You will need to call alDeleteBuffers and check alGetError() to see if it failed (because Apple overloaded the function for this case). Then you must react accordingly (after the fact) if there is a failure. Or you could avoid using the alBufferDataStatic extension. I highly recommend my book, "Beginning iPhone Games Development" in which I extensively cover OpenAL. Coincidentally, the longest chapter in the book is on audio streaming and there is a full blown OpenAL implementation that includes streaming. I also spend considerable energy explaining the sharp knives associated with the alBufferDataStatic extension on iOS. (The Creative/Xbox implementation which also offers the extension is apparently immune to these problems.) http://playcontrol.net/iphonegamebook/ -Eric _______________________________________________ Openal mailing list [email protected] http://opensource.creative.com/mailman/listinfo/openal