Why does alDeleteBuffers gives a AL_INVALID_OPERATION error?

View: New views
4 Messages — Rating Filter:   Alert me  

Why does alDeleteBuffers gives a AL_INVALID_OPERATION error?

by Mentalray :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm using OpenAL for an iPhone application, but I'm having a weird issue.  At some point I need to clear all of the queued buffers from one source.  Here's how I proceed (simplified version of the code):

alSourceStop( sourceId );
alGetSourcei( sourceId, AL_BUFFERS_PROCESSED, &numProcessed );
while( numProcessed-- ) {
    alSourceUnqueueBuffers( sourceId, 1, &bufferId );
    alDeleteBuffers( 1, bufferId ); // this fails with AL_INVALID_OPERATION
}

From what I understand, AL_INVALID_OPERATION is returned from alDeleteBuffers when the buffer is still in use.  This is not the case here.

I there any other things that I should check?

Any help would be appreciated,
Martin

Re: Why does alDeleteBuffers gives a AL_INVALID_OPERATION error?

by Chris Robinson-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Saturday 21 March 2009 6:24:33 am Mentalray wrote:

> Hi,
>
> I'm using OpenAL for an iPhone application, but I'm having a weird issue.
> At some point I need to clear all of the queued buffers from one source.
> Here's how I proceed (simplified version of the code):
>
> alSourceStop( sourceId );
> alGetSourcei( sourceId, AL_BUFFERS_PROCESSED, &numProcessed );
> while( numProcessed-- ) {
>     alSourceUnqueueBuffers( sourceId, 1, &bufferId );
>     alDeleteBuffers( 1, bufferId ); // this fails with AL_INVALID_OPERATION
> }
>
> >From what I understand, AL_INVALID_OPERATION is returned from
>
> alDeleteBuffers when the buffer is still in use.  This is not the case
> here.

That should be:
alDeleteBuffers( 1, &bufferId );
since it takes a pointer to a list of buffers (though since you only specify
1, it's a list of one, hence a pointer to a single buffer).
_______________________________________________
Openal-devel mailing list
Openal-devel@...
http://opensource.creative.com/mailman/listinfo/openal-devel

Re: Why does alDeleteBuffers gives a AL_INVALID_OPERATION error?

by Mentalray :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Mar 21, 2009 at 1:36 PM, Chris Robinson <chris.kcat@...> wrote:
> alSourceStop( sourceId );
> alGetSourcei( sourceId, AL_BUFFERS_PROCESSED, &numProcessed );
> while( numProcessed-- ) {
>     alSourceUnqueueBuffers( sourceId, 1, &bufferId );
>     alDeleteBuffers( 1, bufferId ); // this fails with AL_INVALID_OPERATION
> }
>

That should be:
alDeleteBuffers( 1, &bufferId );
since it takes a pointer to a list of buffers (though since you only specify
1, it's a list of one, hence a pointer to a single buffer).

I'm sorry, I didn't transcript the original program properly.  I'm actually passing &bufferId to the alDeleteBuffers function, but I still get the error.

I've noticed something weird though.  If I add a sleep (I used a 1 sec sleep) between the alSourceUnqueueBuffers and the alDeleteBuffers function, it works fine.  The problem only seem to occur if the delete function occurs too fast.

I'm really perplexed by this.  Does it sounds like an implementation bug?

Many thanks for your help,
Martin 

_______________________________________________
Openal-devel mailing list
Openal-devel@...
http://opensource.creative.com/mailman/listinfo/openal-devel

Re: Why does alDeleteBuffers gives a AL_INVALID_OPERATION error?

by Chris Robinson-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Saturday 21 March 2009 8:14:17 pm Martin Cote wrote:
> I'm sorry, I didn't transcript the original program properly.  I'm actually
> passing &bufferId to the alDeleteBuffers function, but I still get the
> error.
>
> I've noticed something weird though.  If I add a sleep (I used a 1 sec
> sleep) between the alSourceUnqueueBuffers and the alDeleteBuffers function,
> it works fine.  The problem only seem to occur if the delete function
> occurs too fast.

Ah, I see. Yeah, that does sound like an issue I've heard of before. For some
reason, the iPhone version of OpenAL seems to delay the actual command, as if
it was acting in another thread/process. So the Unqueue command returned and
gave you the buffer, but the buffer was not actually unqueued yet.
Unfortunately, the next command on the buffer doesn't wait for previous
commands to finish, so when you call alDeleteBuffer, it's still technically
queued on the source.

I'm not sure if this is a bug or a design decision on Apple's part, but given
the lack of alFlush/alFinish commands, it leaves the programmer in a bind
since there is no way in standard OpenAL to force previous commands to
complete or determine when they have finished. Resting can work since it gives
time for the command to finish, but it's hardly ideal.
_______________________________________________
Openal-devel mailing list
Openal-devel@...
http://opensource.creative.com/mailman/listinfo/openal-devel