[openal] buffer questions
chris.kcat at gmail.com
Fri Jul 17 16:01:07 EDT 2015
On 07/17/2015 07:20 AM, Victorious wrote:
> If a file is loaded into a buffer, is it safe for multiple sources to reuse
> this buffer to play the same file? Each source may have different positions,
> volumes, and start/pause/stop playback at different times.
Yep, that's entirely fine. A buffer represents the sound itself, while a
source represents the playback state of a sound, so you can have
multiple playback states referencing the same sound and each source will
track its own position, volumes, etc.
Anything set on the buffer will be shared (such as loop points using
AL_SOFT_loop_points), while anything set on the source is unique to the
> How much data is there in each buffer object? I'm assuming that if you load
> a file into it, it contains the uncompressed contents of the whole file, in
> which case, how do I calculate the size in bytes of a .ogg after its been
> decoded into a form openal-soft can work with? In the case of streaming with
> Alure, what is the size set for each buffer?
You can tell by querying the buffer's size:
alGetBufferi(buffer, AL_SIZE, &size);
That will give you the size in bytes of the stored audio samples.
Note that you don't have to decode the whole ogg into a single buffer if
you know it's going to be long (e.g. for background music). You can use
a source's buffer queue to only load small potions of it at a time.
More information about the openal