[PATCH] Improve buffer attaching/detaching

nikki

17-11-2009 14:38:15

Hey!

I had a problem with stop() that kept saying 'invalid value pointer in unqueueBuffers'. This little change I found with help of a guy on IRC seems to fix it. You might be interested:-

Index: src/OgreALSound.cpp
===================================================================
--- src/OgreALSound.cpp (revision 130)
+++ src/OgreALSound.cpp (working copy)
@@ -1022,28 +1022,18 @@

void Sound::queueBuffers()
{
- alSourceQueueBuffers(mSource, mNumBuffers, mBuffers);
+ if(mNumBuffers == 1)
+ alSourcei(mSource, AL_BUFFER, mBuffers[0]);
+ else
+ alSourceQueueBuffers(mSource, mNumBuffers, mBuffers);
CheckError(alGetError(), "Failed to bind Buffer");
}

void Sound::unqueueBuffers()
{
- /*
- ** If the sound doesn't have a state yet it causes an
- ** error when you try to unqueue the buffers! :S In
- ** order to get around this we stop the source even if
- ** it wasn't playing.
- */
alSourceStop(mSource);
+ alSourcei(mSource, AL_BUFFER, 0);
CheckError(alGetError(), "Failed to stop sound");
-
- int queued;
- alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
- CheckError(alGetError(), "Failed to get Source");
-
- alSourceUnqueueBuffers(mSource, queued, mBuffers);
- CheckError(alGetError(), "Failed to unqueue Buffers");
-

mBuffersQueued = false;
}


Thanks for working on OgreAL, it's a great library! :)

Phobius

04-01-2010 07:48:20

Awesome. Thank you, i'll take a look at your patch soon and will consider integrating. Much obliged.

nikki

04-09-2010 22:45:16

So, did you integrate it? :)

Phobius

17-09-2010 10:58:59

I don't think so. Let me get a leg up on the backlog in the forum. I'm trying to keep things afloat and doing a miserable job.