title: Circular buffers in OpenAL
body: <p>In DirectSound, there was a very distinct concept of <a href="http://books.google.ca/books?id=0TAE5me0GhwC&amp;pg=PA135&amp;lpg=PA135&amp;dq=directsound+circular+buffer&amp;source=bl&amp;ots=_6JyGW_VOW&amp;sig=vrhu57_gGQIUlu9yQKAmUZRG8cU&amp;hl=en&amp;sa=X&amp;ei=Z3DOUOqeEqigyAGYsoD4Cw&amp;ved=0CDUQ6AEwAQ#v=onepage&amp;q=directsound%20circular%20buffer&amp;f=false" rel="nofollow noreferrer">circular buffers</a></p>
  
  <p>In particular there was a current read position, a current write position, and clear methods to GetPosition and lock the buffer and start writing.</p>
  
  <p><img src="https://i.stack.imgur.com/XHG9H.png" alt="enter image description here"></p>
  
  <p>I'm looking for a similar concept in OpenAL, but all I can find is looping an <code>AL_STREAMING</code> buffer, and using <code>AL_SAMPLE_OFFSET</code> to determine the current read position (and write say, 15 samples after that?)</p>
  
  <p>OpenAL docs are down right now, but accessible <a href="http://web.archive.org/web/20110513043311/http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf" rel="nofollow noreferrer">here</a>.</p>
  
  <p>What is a safe way to declare a sound buffer that gets written to by the application <em>as it is playing</em>?  Am I right about using a looping streaming buffer?</p>