[Openal] Switching buffers dynamically

Jason Daly jdaly at ist.ucf.edu
Sat May 9 21:14:32 PDT 2009


bpazolli wrote:
> Hey, I am trying to switch buffer data dynamically (i.e. during program
> execution). I tried just using an alBufferData command to link new data to
> the existing buffer; that didn't work. I then tried deleting the buffer &
> source using their respective alDelete commands and then building new ones
> with the new buffer date; that didn't work. So I am at a loss as to how I
> can actually switch. Do I have to stop playback or some other step? I don't
> know.
>   

alBufferData works fine for updating a buffer's data during execution.  
Most likely, your buffer is still assigned to a source while you're 
trying to change it, which isn't permitted.  If you're statically 
assigning the buffer to a source, remove it with alSourcei(sid, 
AL_BUFFER, 0).  If you're using the buffer queue, unqueue the buffer 
(using alUnqueueBuffers() ).

If that's not the problem, check the error code after the alBufferData 
command (call alGetError before the alBufferData call to reset the error 
state, then call it again after the alBufferData call to get the error 
code).

--"J"



More information about the Openal mailing list