

Playback is finished when the source becomes stopped. See the alstream example for one way to do it.įor a normal buffer, you read and decode the whole sound, load it into one buffer, then set the buffer on the source and play the source. Playback is finished when the source stops and you have no more audio to fill. When queued onto a source and played, you regularly check for processed buffers, and when one becomes processed, you unqueue it, fill it with more audio, and queue it back on to the source as the other queued buffers play. For longer things like music, you generally want to stream it, because having it all decoded at once can take a lot of memory, but having it all loaded at once makes management and reuse a bit easier (especially if the sound is going to be played often, maybe even multiple times at once).įor streaming, you'll need to use a buffer queue, generally 2 or 3 buffers each with a little bit of decoded audio. What exactly to do depends if you want to load and decode the whole file at once, or if you want to stream it so only a small part of it is decoded in memory at a given time.

I hope there is a relatively accurate way to remind the application staff that the file has been played over;Īlsourcef(sourcei AL_SOURCE_TYPE,AL_STREAMING) ĪlGenSourcei(sourcei,AL_SOURCE_STATE,&state) Why I detect the state of openal sound source? Because there are multiple buffers (algenbuffers (8, alint buffer ) in my sound source, I'm not sure It is just play-finished after I pull the data into the openal sound source(by :alBufferData ,alQueueBuffers) If the state is stopped, it is considered that the file is played over I don't know if this is accurate Īlthough the developers of UI layer can judge whether it is over by time, I still want to implement it in SDK layer When my thread fills all the data (to be played) into the source buffer of openal, I will detect the state of openal-source. I'm not sure whether this development is accurate at present: I need a notification (callback)of the end of file playback I bind eight ALint nodes to a sound source. I want to make a common function of music player Prepare to use openal on Windows & Linux & MAC
