Some basic questions about OpenAL buffers

I just started working with OpenAL, and everything seems fine so far, I tried some lessons, I managed to download and play some sounds, but before I start implementing something more complicated, I would like to make sure that I understand how Work OpenAL.

Basically, my goal is to create a simple system where I can give commands such as "play this and this, stop playing" without worrying about anything. Suppose that the program should work with 150 sounds, only 250 MB when unpacking to PCM, and all this is available at the beginning.

OpenAL has sources and buffers. I understand that I must have a source pool and reuse them. What I do not understand and could not find anywhere is what the buffers actually are. Are they a limited resource or just plain storage, possibly converted to a format that can be played easily but still in ordinary memory?

In the described situation, I have to:

  • A) create 150 buffers at the beginning and fill them with only 250 MB of data, some of which can be hourly sounds, store them throughout the program and play them if necessary, or
  • B) load 250 MB into memory and load each sound into the buffer right before playing in small pieces and release them right after?

If A, what is the purpose of streaming data to small buffers and then their queues?

If B, how many buffers and how much data are safe in them? Should I also create a buffer pool and reuse them?

In addition, I have an additional question about the buffer. I understand that I can either set the source buffer (as a property) or put it in the queue (will they both be wrong?). I was surprised, although apparently I also need to unlock them. Why does this not happen automatically as soon as the buffer is played? And do I need to unlock them in the same order in which they were queued?

Thank you for helping me understand this.

+4
source share

All Articles