diff options
author | Chris Robinson <[email protected]> | 2010-05-21 15:52:35 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-05-21 15:52:35 -0700 |
commit | 58e5404d61757bcc254fe9008defa5a7a71d5138 (patch) | |
tree | 9e8736c1f515860e22f1093dfe97313af9a635ba /OpenAL32 | |
parent | 3676fdc4db55e04e70851d2818f8ca5f5b44e761 (diff) |
Loop points should be specified in sample offsets
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alBuffer.c | 47 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 11 |
2 files changed, 27 insertions, 31 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 8da73d82..b19ac5d9 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -339,11 +339,11 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid ALBuf->size = newsize*NewBytes; ALBuf->frequency = freq; + ALBuf->LoopStart = 0; + ALBuf->LoopEnd = newsize / NewChannels; + ALBuf->OriginalSize = size; ALBuf->OriginalAlign = OrigBytes * 2; - - ALBuf->LoopStart = 0; - ALBuf->LoopEnd = size; } else alSetError(Context, AL_OUT_OF_MEMORY); @@ -415,11 +415,11 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid ALBuf->size = newsize*NewBytes; ALBuf->frequency = freq; + ALBuf->LoopStart = 0; + ALBuf->LoopEnd = newsize / OrigChans; + ALBuf->OriginalSize = size; ALBuf->OriginalAlign = 36 * OrigChans; - - ALBuf->LoopStart = 0; - ALBuf->LoopEnd = size; } else alSetError(Context, AL_OUT_OF_MEMORY); @@ -462,11 +462,11 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid ALBuf->size = size*NewBytes; ALBuf->frequency = freq; + ALBuf->LoopStart = 0; + ALBuf->LoopEnd = size / Channels; + ALBuf->OriginalSize = size; ALBuf->OriginalAlign = 1 * Channels; - - ALBuf->LoopStart = 0; - ALBuf->LoopEnd = size; } else alSetError(Context, AL_OUT_OF_MEMORY); @@ -499,11 +499,11 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid ALBuf->size = newsize*NewBytes; ALBuf->frequency = freq; + ALBuf->LoopStart = 0; + ALBuf->LoopEnd = newsize / NewChannels; + ALBuf->OriginalSize = size; ALBuf->OriginalAlign = 1 * OrigChans; - - ALBuf->LoopStart = 0; - ALBuf->LoopEnd = size; } else alSetError(Context, AL_OUT_OF_MEMORY); @@ -834,16 +834,19 @@ AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* pl if(ALBuf->refcount > 0) alSetError(pContext, AL_INVALID_OPERATION); else if(plValues[0] < 0 || plValues[1] < 0 || - plValues[0] > ALBuf->OriginalSize || - plValues[1] > ALBuf->OriginalSize || - (plValues[0]%ALBuf->OriginalAlign) || - (plValues[0]%ALBuf->OriginalAlign) || - plValues[0] >= plValues[1]) + plValues[0] >= plValues[1] || ALBuf->size == 0) alSetError(pContext, AL_INVALID_VALUE); else { - ALBuf->LoopStart = plValues[0]; - ALBuf->LoopEnd = plValues[1]; + ALint maxlen = ALBuf->size / aluBytesFromFormat(ALBuf->format) / + aluChannelsFromFormat(ALBuf->format); + if(plValues[0] > maxlen || plValues[1] > maxlen) + alSetError(pContext, AL_INVALID_VALUE); + else + { + ALBuf->LoopStart = plValues[0]; + ALBuf->LoopEnd = plValues[1]; + } } break; @@ -1130,12 +1133,12 @@ static ALenum LoadData(ALbuffer *ALBuf, const ALvoid *data, ALsizei size, ALuint ALBuf->size = newsize*NewBytes; ALBuf->frequency = freq; + ALBuf->LoopStart = 0; + ALBuf->LoopEnd = newsize / NewChannels; + ALBuf->OriginalSize = size; ALBuf->OriginalAlign = OrigBytes * OrigChannels; - ALBuf->LoopStart = 0; - ALBuf->LoopEnd = size; - return AL_NO_ERROR; } diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 5f3ba7f0..139eb75b 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -553,8 +553,6 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) // Add the buffer to the queue (as long as it is NOT the NULL buffer) if(lValue != 0) { - ALuint channels; - // Source is now in STATIC mode Source->lSourceType = AL_STATIC; @@ -566,13 +564,8 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) Source->queue = BufferListItem; Source->BuffersInQueue = 1; - channels = aluChannelsFromFormat(buffer->format); - Source->LoopStart = FramesFromBytes(buffer->LoopStart, - buffer->eOriginalFormat, - channels); - Source->LoopEnd = FramesFromBytes(buffer->LoopEnd, - buffer->eOriginalFormat, - channels); + Source->LoopStart = buffer->LoopStart; + Source->LoopEnd = buffer->LoopEnd; // Increment reference counter for buffer buffer->refcount++; |