aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-21 10:32:48 -0800
committerChris Robinson <[email protected]>2018-01-21 10:32:48 -0800
commitdcb934fc2e46728d9a9d04e8e1e583518942a238 (patch)
treee7ce88fb900616496eead34964f15da6e0813e1a
parentc2c38469304b15a5fa91282084ffe3aea9e97588 (diff)
Avoid repeating some code
-rw-r--r--OpenAL32/alBuffer.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index 1c9b2650..72750360 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -288,29 +288,23 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
if(!access || (access&~(AL_MAP_READ_BIT_SOFT|AL_MAP_WRITE_BIT_SOFT)) != 0)
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+
WriteLock(&albuf->lock);
if(((access&AL_MAP_READ_BIT_SOFT) && !(albuf->Access&AL_MAP_READ_BIT_SOFT)) ||
((access&AL_MAP_WRITE_BIT_SOFT) && !(albuf->Access&AL_MAP_WRITE_BIT_SOFT)))
- {
- WriteUnlock(&albuf->lock);
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
- }
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
if(offset < 0 || offset >= albuf->OriginalSize ||
length <= 0 || length > albuf->OriginalSize - offset)
- {
- WriteUnlock(&albuf->lock);
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
- }
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
if(ReadRef(&albuf->ref) != 0 || albuf->MappedAccess != 0)
- {
- WriteUnlock(&albuf->lock);
- SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
- }
+ SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, unlock_done);
retval = (ALbyte*)albuf->data + offset;
albuf->MappedAccess = access;
if((access&AL_MAP_WRITE_BIT_SOFT) && !(access&AL_MAP_READ_BIT_SOFT))
memset(retval, 0x55, length);
+
+unlock_done:
WriteUnlock(&albuf->lock);
done: