aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenAL32/Include/alBuffer.h2
-rw-r--r--OpenAL32/alBuffer.c11
2 files changed, 10 insertions, 3 deletions
diff --git a/OpenAL32/Include/alBuffer.h b/OpenAL32/Include/alBuffer.h
index e89d3c96..b6d77436 100644
--- a/OpenAL32/Include/alBuffer.h
+++ b/OpenAL32/Include/alBuffer.h
@@ -90,6 +90,8 @@ typedef struct ALbuffer {
ATOMIC(ALsizei) PackAlign;
ALbitfieldSOFT MappedAccess;
+ ALsizei MappedOffset;
+ ALsizei MappedSize;
/* Number of times buffer was attached to a source (deletion can only occur when 0) */
RefCount ref;
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index b2302933..d5e6790a 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -244,6 +244,8 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei
retval = (ALbyte*)albuf->data + offset;
albuf->MappedAccess = access;
+ albuf->MappedOffset = offset;
+ albuf->MappedSize = length;
unlock_done:
WriteUnlock(&albuf->lock);
@@ -273,7 +275,11 @@ AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer)
if(albuf->MappedAccess == 0)
alSetError(context, AL_INVALID_OPERATION);
else
+ {
albuf->MappedAccess = 0;
+ albuf->MappedOffset = 0;
+ albuf->MappedSize = 0;
+ }
WriteUnlock(&albuf->lock);
done:
@@ -298,9 +304,8 @@ AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, A
WriteLock(&albuf->lock);
if(albuf->MappedAccess == 0 || !(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT))
alSetError(context, AL_INVALID_OPERATION);
- /* TODO: Should check mapped range. */
- else if(offset < 0 || offset >= albuf->OriginalSize ||
- length <= 0 || length > albuf->OriginalSize - offset)
+ else if(offset < albuf->MappedOffset || offset >= albuf->MappedOffset+albuf->MappedSize ||
+ length <= 0 || length > albuf->MappedOffset+albuf->MappedSize-offset)
alSetError(context, AL_INVALID_VALUE);
else
{