aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alBuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r--OpenAL32/alBuffer.c196
1 files changed, 105 insertions, 91 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index 754368b7..922c379c 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -66,7 +66,7 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
if(!context) return;
if(!(n >= 0))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, 0, "Generating negative buffers", done);
for(cur = 0;cur < n;cur++)
{
@@ -98,7 +98,7 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
LockBuffersWrite(device);
if(!(n >= 0))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, 0, "Deleting negative buffers", done);
for(i = 0;i < n;i++)
{
@@ -107,9 +107,9 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
/* Check for valid Buffer ID */
if((ALBuf=LookupBuffer(device, buffers[i])) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffers[i], "Invalid buffer ID", done);
if(ReadRef(&ALBuf->ref) != 0)
- SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
+ SETERR_GOTO(context, AL_INVALID_OPERATION, buffers[i], "Deleting in-use buffer", done);
}
for(i = 0;i < n;i++)
@@ -161,16 +161,19 @@ AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
- if(!(size >= 0 && freq > 0) || (flags&INVALID_STORAGE_MASK) != 0)
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
+ if(!(size >= 0)) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Negative storage size", done);
+ if(!(freq > 0)) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Invalid sample rate", done);
+ if((flags&INVALID_STORAGE_MASK) != 0)
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Invalid storage flags", done);
if((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer,
+ "Declaring persistently mapped storage without read or write access", done);
if(DecomposeUserFormat(format, &srcchannels, &srctype) == AL_FALSE)
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ SETERR_GOTO(context, AL_INVALID_ENUM, buffer, "Invalid format", done);
align = SanitizeAlignment(srctype, ATOMIC_LOAD_SEQ(&albuf->UnpackAlign));
- if(align < 1) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(align < 1) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Invalid unpack alignment", done);
switch(srctype)
{
@@ -215,21 +218,32 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
- if(!(access&MAP_READ_WRITE_FLAGS) || (access&~MAP_ACCESS_FLAGS) != 0)
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
+ if((access&~MAP_ACCESS_FLAGS) != 0)
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Invalid map flags", done);
+ if(!(access&MAP_READ_WRITE_FLAGS))
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer,
+ "Mapping buffer without read or write access", done);
WriteLock(&albuf->lock);
- if((ReadRef(&albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT)) ||
- albuf->MappedAccess != 0)
- SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, unlock_done);
- 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_PERSISTENT_BIT_SOFT) && !(albuf->Access&AL_MAP_PERSISTENT_BIT_SOFT)))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
+ if(ReadRef(&albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT))
+ SETERR_GOTO(context, AL_INVALID_OPERATION, buffer,
+ "Mapping in-use buffer without persistent mapping", unlock_done);
+ if(albuf->MappedAccess != 0)
+ SETERR_GOTO(context, AL_INVALID_OPERATION, buffer, "Mapping already-mapped buffer",
+ unlock_done);
+ if((access&AL_MAP_READ_BIT_SOFT) && !(albuf->Access&AL_MAP_READ_BIT_SOFT))
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer,
+ "Mapping buffer for reading without read access", unlock_done);
+ if((access&AL_MAP_WRITE_BIT_SOFT) && !(albuf->Access&AL_MAP_WRITE_BIT_SOFT))
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer,
+ "Mapping buffer for writing without write access", unlock_done);
+ if((access&AL_MAP_PERSISTENT_BIT_SOFT) && !(albuf->Access&AL_MAP_PERSISTENT_BIT_SOFT))
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer,
+ "Mapping buffer persistently without persistent access", unlock_done);
if(offset < 0 || offset >= albuf->OriginalSize ||
length <= 0 || length > albuf->OriginalSize - offset)
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Mapping out of range", unlock_done);
retval = (ALbyte*)albuf->data + offset;
albuf->MappedAccess = access;
@@ -258,7 +272,7 @@ AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer)
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
WriteLock(&albuf->lock);
if(albuf->MappedAccess == 0)
@@ -288,7 +302,7 @@ AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, A
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
WriteLock(&albuf->lock);
if(albuf->MappedAccess == 0 || !(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT))
@@ -332,21 +346,22 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
- if(!(length >= 0 && offset >= 0))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
if(DecomposeUserFormat(format, &srcchannels, &srctype) == AL_FALSE)
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ SETERR_GOTO(context, AL_INVALID_ENUM, buffer, "Invalid format", done);
WriteLock(&albuf->lock);
align = SanitizeAlignment(srctype, ATOMIC_LOAD_SEQ(&albuf->UnpackAlign));
- if(align < 1) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
+ if(align < 1) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Invalid unpack alignment", done);
if((long)srcchannels != (long)albuf->FmtChannels || srctype != albuf->OriginalType)
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, unlock_done);
+ SETERR_GOTO(context, AL_INVALID_ENUM, buffer, "Unpacking data with mismatched format",
+ unlock_done);
if(align != albuf->OriginalAlign)
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Unpacking data with mismatched alignment",
+ unlock_done);
if(albuf->MappedAccess != 0)
- SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, unlock_done);
+ SETERR_GOTO(context, AL_INVALID_OPERATION, buffer, "Unpacking data into mapped buffer",
+ unlock_done);
num_chans = ChannelsFromFmt(albuf->FmtChannels);
frame_size = num_chans * BytesFromFmt(albuf->FmtType);
@@ -357,9 +372,11 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons
else
byte_align = align * frame_size;
- if(offset > albuf->OriginalSize || length > albuf->OriginalSize-offset ||
- (offset%byte_align) != 0 || (length%byte_align) != 0)
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, unlock_done);
+ if(offset < 0 || length < 0 || offset > albuf->OriginalSize ||
+ length > albuf->OriginalSize-offset)
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Data sub-range out of range", unlock_done);
+ if((offset%byte_align) != 0 || (length%byte_align) != 0)
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Invalid sub-range alignment", unlock_done);
/* offset -> byte offset, length -> sample count */
offset = offset/byte_align * frame_size;
@@ -452,12 +469,12 @@ AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat UNUSED(va
device = context->Device;
LockBuffersRead(device);
if(LookupBuffer(device, buffer) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer float property");
}
done:
@@ -477,12 +494,12 @@ AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat UNUSED(v
device = context->Device;
LockBuffersRead(device);
if(LookupBuffer(device, buffer) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer 3-float property");
}
done:
@@ -502,14 +519,13 @@ AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *v
device = context->Device;
LockBuffersRead(device);
if(LookupBuffer(device, buffer) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(values))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!values) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer float-vector property");
}
done:
@@ -530,24 +546,26 @@ AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value)
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
switch(param)
{
case AL_UNPACK_BLOCK_ALIGNMENT_SOFT:
if(!(value >= 0))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer,
+ "Negative buffer unpack block alignment", done);
ATOMIC_STORE_SEQ(&albuf->UnpackAlign, value);
break;
case AL_PACK_BLOCK_ALIGNMENT_SOFT:
if(!(value >= 0))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Negative buffer pack block alignment",
+ done);
ATOMIC_STORE_SEQ(&albuf->PackAlign, value);
break;
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer integer property");
}
done:
@@ -566,12 +584,12 @@ AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint UNUSED(val
device = context->Device;
if(LookupBuffer(device, buffer) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer 3-integer property");
}
done:
@@ -602,10 +620,9 @@ AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *val
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(values))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!values) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
case AL_LOOP_POINTS_SOFT:
@@ -613,13 +630,14 @@ AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *val
if(ReadRef(&albuf->ref) != 0)
{
WriteUnlock(&albuf->lock);
- SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
+ SETERR_GOTO(context, AL_INVALID_OPERATION, buffer,
+ "Modifying in-use buffer loop points", done);
}
if(values[0] >= values[1] || values[0] < 0 ||
values[1] > albuf->SampleLen)
{
WriteUnlock(&albuf->lock);
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "Invalid loop point range", done);
}
albuf->LoopStart = values[0];
@@ -628,7 +646,7 @@ AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *val
break;
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer integer-vector property");
}
done:
@@ -649,14 +667,13 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *val
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(value))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!value) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer float property");
}
done:
@@ -676,14 +693,14 @@ AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *valu
device = context->Device;
LockBuffersRead(device);
if(LookupBuffer(device, buffer) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(value1 && value2 && value3))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!value1 || !value2 || !value3)
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer 3-float property");
}
done:
@@ -710,14 +727,13 @@ AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *valu
device = context->Device;
LockBuffersRead(device);
if(LookupBuffer(device, buffer) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(values))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!values) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer float-vector property");
}
done:
@@ -738,10 +754,9 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(value))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!value) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
case AL_FREQUENCY:
@@ -772,7 +787,7 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value
break;
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer integer property");
}
done:
@@ -792,14 +807,14 @@ AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1
device = context->Device;
LockBuffersRead(device);
if(LookupBuffer(device, buffer) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(value1 && value2 && value3))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!value1 || !value2 || !value3)
+ SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer 3-integer property");
}
done:
@@ -835,10 +850,9 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values
device = context->Device;
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
- SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ SETERR_GOTO(context, AL_INVALID_NAME, buffer, "Invalid buffer ID", done);
- if(!(values))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ if(!values) SETERR_GOTO(context, AL_INVALID_VALUE, buffer, "NULL pointer", done);
switch(param)
{
case AL_LOOP_POINTS_SOFT:
@@ -849,7 +863,7 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values
break;
default:
- SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
+ alSetError(context, AL_INVALID_ENUM, buffer, "Invalid buffer integer-vector property");
}
done:
@@ -884,7 +898,7 @@ static void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei
case UserFmtBFormat3D: DstChannels = FmtBFormat3D; break;
}
if(UNLIKELY((long)SrcChannels != (long)DstChannels))
- SET_ERR_AND_RETURN(context, AL_INVALID_ENUM, ALBuf->id, "Invalid format");
+ SETERR_RETURN(context, AL_INVALID_ENUM, ALBuf->id, "Invalid format",);
/* IMA4 and MSADPCM convert to 16-bit short. */
switch(SrcType)
@@ -902,23 +916,23 @@ static void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei
if(access != 0)
{
if(UNLIKELY((long)SrcType != (long)DstType))
- SET_ERR_AND_RETURN(context, AL_INVALID_VALUE, ALBuf->id,
- "Format cannot be mapped or preserved");
+ SETERR_RETURN(context, AL_INVALID_VALUE, ALBuf->id,
+ "Format cannot be mapped or preserved",);
}
NumChannels = ChannelsFromFmt(DstChannels);
FrameSize = NumChannels * BytesFromFmt(DstType);
if(UNLIKELY(frames > INT_MAX/FrameSize))
- SET_ERR_AND_RETURN(context, AL_OUT_OF_MEMORY, ALBuf->id, "Buffer size too large");
+ SETERR_RETURN(context, AL_OUT_OF_MEMORY, ALBuf->id, "Buffer size too large",);
newsize = frames*FrameSize;
WriteLock(&ALBuf->lock);
if(UNLIKELY(ReadRef(&ALBuf->ref) != 0 || ALBuf->MappedAccess != 0))
{
WriteUnlock(&ALBuf->lock);
- SET_ERR_AND_RETURN(context, AL_INVALID_OPERATION, ALBuf->id,
- "Modifying storage for in-use buffer");
+ SETERR_RETURN(context, AL_INVALID_OPERATION, ALBuf->id,
+ "Modifying storage for in-use buffer",);
}
if((access&AL_PRESERVE_DATA_BIT_SOFT))
@@ -927,14 +941,14 @@ static void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei
if(UNLIKELY(ALBuf->FmtChannels != DstChannels || ALBuf->OriginalType != SrcType))
{
WriteUnlock(&ALBuf->lock);
- SET_ERR_AND_RETURN(context, AL_INVALID_VALUE, ALBuf->id,
- "Preserving data of mismatched format");
+ SETERR_RETURN(context, AL_INVALID_VALUE, ALBuf->id,
+ "Preserving data of mismatched format",);
}
if(UNLIKELY(ALBuf->OriginalAlign != align))
{
WriteUnlock(&ALBuf->lock);
- SET_ERR_AND_RETURN(context, AL_INVALID_VALUE, ALBuf->id,
- "Preserving data of mismatched alignment");
+ SETERR_RETURN(context, AL_INVALID_VALUE, ALBuf->id,
+ "Preserving data of mismatched alignment",);
}
}
@@ -952,7 +966,7 @@ static void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei
if(UNLIKELY(!temp && newsize))
{
WriteUnlock(&ALBuf->lock);
- SET_ERR_AND_RETURN(context, AL_OUT_OF_MEMORY, ALBuf->id, "Failed to allocate storage");
+ SETERR_RETURN(context, AL_OUT_OF_MEMORY, ALBuf->id, "Failed to allocate storage",);
}
if((access&AL_PRESERVE_DATA_BIT_SOFT))
{
@@ -1190,7 +1204,7 @@ ALbuffer *NewBuffer(ALCcontext *context)
buffer = al_calloc(16, sizeof(ALbuffer));
if(!buffer)
- SET_ERROR_AND_RETURN_VALUE(context, AL_OUT_OF_MEMORY, NULL);
+ SETERR_RETURN(context, AL_OUT_OF_MEMORY, 0, "Failed to allocate buffer object", NULL);
RWLockInit(&buffer->lock);
buffer->Access = 0;
buffer->MappedAccess = 0;
@@ -1204,7 +1218,7 @@ ALbuffer *NewBuffer(ALCcontext *context)
memset(buffer, 0, sizeof(ALbuffer));
al_free(buffer);
- SET_ERROR_AND_RETURN_VALUE(context, err, NULL);
+ SETERR_RETURN(context, err, 0, "Failed to set buffer ID", NULL);
}
return buffer;