Avoid repeating some code
This commit is contained in:
parent
c2c3846930
commit
dcb934fc2e
@ -288,29 +288,23 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei
|
|||||||
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
|
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
|
||||||
if(!access || (access&~(AL_MAP_READ_BIT_SOFT|AL_MAP_WRITE_BIT_SOFT)) != 0)
|
if(!access || (access&~(AL_MAP_READ_BIT_SOFT|AL_MAP_WRITE_BIT_SOFT)) != 0)
|
||||||
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
|
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
|
||||||
|
|
||||||
WriteLock(&albuf->lock);
|
WriteLock(&albuf->lock);
|
||||||
if(((access&AL_MAP_READ_BIT_SOFT) && !(albuf->Access&AL_MAP_READ_BIT_SOFT)) ||
|
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)))
|
((access&AL_MAP_WRITE_BIT_SOFT) && !(albuf->Access&AL_MAP_WRITE_BIT_SOFT)))
|
||||||
{
|
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
|
||||||
WriteUnlock(&albuf->lock);
|
|
||||||
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
|
|
||||||
}
|
|
||||||
if(offset < 0 || offset >= albuf->OriginalSize ||
|
if(offset < 0 || offset >= albuf->OriginalSize ||
|
||||||
length <= 0 || length > albuf->OriginalSize - offset)
|
length <= 0 || length > albuf->OriginalSize - offset)
|
||||||
{
|
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
|
||||||
WriteUnlock(&albuf->lock);
|
|
||||||
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
|
|
||||||
}
|
|
||||||
if(ReadRef(&albuf->ref) != 0 || albuf->MappedAccess != 0)
|
if(ReadRef(&albuf->ref) != 0 || albuf->MappedAccess != 0)
|
||||||
{
|
SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, unlock_done);
|
||||||
WriteUnlock(&albuf->lock);
|
|
||||||
SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = (ALbyte*)albuf->data + offset;
|
retval = (ALbyte*)albuf->data + offset;
|
||||||
albuf->MappedAccess = access;
|
albuf->MappedAccess = access;
|
||||||
if((access&AL_MAP_WRITE_BIT_SOFT) && !(access&AL_MAP_READ_BIT_SOFT))
|
if((access&AL_MAP_WRITE_BIT_SOFT) && !(access&AL_MAP_READ_BIT_SOFT))
|
||||||
memset(retval, 0x55, length);
|
memset(retval, 0x55, length);
|
||||||
|
|
||||||
|
unlock_done:
|
||||||
WriteUnlock(&albuf->lock);
|
WriteUnlock(&albuf->lock);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Loading…
Reference in New Issue
Block a user