Re: Why use more than 2 buffers?
Jason Daly <[email protected]>
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <[email protected]> |
Chris Robinson wrote: > On Thursday 10 December 2009 2:31:16 pm Nate Foreman wrote: > >> We all know that OpenAl sources are capable of queuing multiple buffers >> for playback. The question is, why would you ever need to queue more >> than 2 buffers at a given time? Aren't two buffers sufficient for the >> double-buffering technique used to continuously streaming audio data? >> > > It depends on how your code is structured and the app's needs. When streaming > compressed files, it could help to have smaller buffers so you don't waste too > much time decoding a large chunk during a frame. It also helps to buffer in > small amounts if you need to regularly check on other components of the app > and can't wait too long to fill in more data. And it usually helps to have a > significant length of audio buffered so the source won't accidentally stall if > you can't process the queue in time. The smaller the buffers are, the more > you'll need to protect against stalls. > I tried for quite a while to get a VoIP-type application working with two buffers, but still have an acceptable latency. Plus, with two fixed-sized buffers, it was difficult to figure out what to do when you ran out of incoming audio. Did they stop talking (in which case I should fill the rest of the buffer with silence and queue it), or is there just network congestion (in which case I should wait for more data and restart the stream when I get it). Ultimately, it was much simpler (and much cleaner code) to just allocate, fill, and queue a buffer for each packet of audio, and then unqueue and delete it when it was done. Possibly less efficient, but much easier to read, maintain, and modify. --"J" _______________________________________________ Openal mailing list [email protected] http://opensource.creative.com/mailman/listinfo/openal