Question: Here's the code:

```
ALint cProcessedBuffers = 0;

ALenum alError = AL_NO_ERROR;
alGetSourcei(m_OpenALSourceId, AL_BUFFERS_PROCESSED, &cProcessedBuffers);
if((alError = alGetError()) != AL_NO_ERROR) 
{
    throw "AudioClip::ProcessPlayedBuffers - error returned from alGetSroucei()";  
}   

alError = AL_NO_ERROR;    
if (cProcessedBuffers > 0)
{
    alSourceUnqueueBuffers(m_OpenALSourceId, cProcessedBuffers, arrBuffers);
    if((alError = alGetError()) != AL_NO_ERROR) 
    {
        throw "AudioClip::ProcessPlayedBuffers - error returned from alSourceUnqueueBuffers()";  
    }   
}

```

The call to alGetSourcei returns with cProcessedBuffers > 0, but the following call to alSourceUnqueueBuffers fails with an INVALID\_OPERATION. This in an erratic error that does not always occur. The program containing this sample code is a single-threaded app running in a tight loop (typically would be sync'ed with a display loop, but in this case I'm not using a timed callback of any sort).

Answer: 
---

Try `alSourceStop(m_OpenALSourceId)` first.
Then `alUnqueueBuffers()`, and after that, Restart playing by `alSourcePlay(m_OpenALSourceId)`.

I solved the same problem by this way. But I don't know why have to do so in
Mentioned in [this SO thread](https://stackoverflow.com/questions/10581409/openal-alsourceunqueuebuffers-alsourceunqueuebuffers),

**If you have AL\_LOOPING enabled on a streaming source the unqueue operation will fail.** 

The looping flag has some sort of lock on the buffers when enabled. The answer by @MyMiracle hints at this as well, stopping the sound releases that hold, but it's not necessary..

AL\_LOOPING is not meant to be set on a streaming source, as *you* manage the source data in the queue. Keep queuing, it will keep playing. Queue from the beginning of the data, it will loop.