aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-03-18 14:46:33 -0700
committerChris Robinson <[email protected]>2010-03-18 14:46:33 -0700
commit2355d6a4a043a82ad40eae193893beb4bcd2efa0 (patch)
tree268e4254097b23e3a59a2cea71088645530c6c75 /OpenAL32
parente1965fe7d90a2dee4f60907500947d411d39dd49 (diff)
Use ptrdiff types for databuffer offset/length handling
Should improve addressing for non-32-bit systems
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alDatabuffer.h18
-rw-r--r--OpenAL32/alBuffer.c8
-rw-r--r--OpenAL32/alDatabuffer.c37
3 files changed, 34 insertions, 29 deletions
diff --git a/OpenAL32/Include/alDatabuffer.h b/OpenAL32/Include/alDatabuffer.h
index f50450f0..82594265 100644
--- a/OpenAL32/Include/alDatabuffer.h
+++ b/OpenAL32/Include/alDatabuffer.h
@@ -12,14 +12,14 @@ extern "C" {
typedef struct ALdatabuffer
{
- ALubyte *data;
- ALuint size;
- ALenum state;
+ ALubyte *data;
+ ALintptrEXT size;
- ALenum usage;
+ ALenum state;
+ ALenum usage;
/* Index to self */
- ALuint databuffer;
+ ALuint databuffer;
struct ALdatabuffer *next;
} ALdatabuffer;
@@ -28,9 +28,9 @@ ALvoid ALAPIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers);
ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers);
ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer);
-ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei size,ALenum usage);
-ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint buffer, ALuint start, ALsizei length, const ALvoid *data);
-ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint buffer, ALuint start, ALsizei length, ALvoid *data);
+ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizeiptrEXT size,ALenum usage);
+ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint buffer, ALintptrEXT start, ALsizeiptrEXT length, const ALvoid *data);
+ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint buffer, ALintptrEXT start, ALsizeiptrEXT length, ALvoid *data);
ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue);
ALvoid ALAPIENTRY alDatabufferfvEXT(ALuint buffer, ALenum eParam, const ALfloat* flValues);
@@ -43,7 +43,7 @@ ALvoid ALAPIENTRY alGetDatabufferivEXT(ALuint buffer, ALenum eParam, ALint* plVa
ALvoid ALAPIENTRY alSelectDatabufferEXT(ALenum target, ALuint uiBuffer);
-ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei length, ALenum access);
+ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALintptrEXT start, ALsizeiptrEXT length, ALenum access);
ALvoid ALAPIENTRY alUnmapDatabufferEXT(ALuint uiBuffer);
ALvoid ReleaseALDatabuffers(ALCdevice *device);
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index b7650ec2..cd1886df 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -276,7 +276,7 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
{
if(Context->SampleSource)
{
- ALuint offset;
+ ALintptrEXT offset;
if(Context->SampleSource->state == MAPPED)
{
@@ -285,7 +285,7 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
return;
}
- offset = (ALuint)data;
+ offset = (ALintptrEXT)data;
data = Context->SampleSource->data + offset;
}
@@ -525,7 +525,7 @@ ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *d
{
if(Context->SampleSource)
{
- ALuint offset;
+ ALintptrEXT offset;
if(Context->SampleSource->state == MAPPED)
{
@@ -534,7 +534,7 @@ ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *d
return;
}
- offset = (ALuint)data;
+ offset = (ALintptrEXT)data;
data = Context->SampleSource->data + offset;
}
diff --git a/OpenAL32/alDatabuffer.c b/OpenAL32/alDatabuffer.c
index b7de80db..c9283250 100644
--- a/OpenAL32/alDatabuffer.c
+++ b/OpenAL32/alDatabuffer.c
@@ -202,7 +202,7 @@ ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer)
*
* Fill databuffer with data
*/
-ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei size,ALenum usage)
+ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizeiptrEXT size,ALenum usage)
{
ALCcontext *Context;
ALdatabuffer *ALBuf;
@@ -223,18 +223,23 @@ ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei s
usage == AL_DYNAMIC_WRITE_EXT || usage == AL_DYNAMIC_READ_EXT ||
usage == AL_DYNAMIC_COPY_EXT)
{
- /* (Re)allocate data */
- temp = realloc(ALBuf->data, size);
- if(temp)
+ if(size >= 0)
{
- ALBuf->data = temp;
- ALBuf->size = size;
- ALBuf->usage = usage;
- if(data)
- memcpy(ALBuf->data, data, size);
+ /* (Re)allocate data */
+ temp = realloc(ALBuf->data, size);
+ if(temp)
+ {
+ ALBuf->data = temp;
+ ALBuf->size = size;
+ ALBuf->usage = usage;
+ if(data)
+ memcpy(ALBuf->data, data, size);
+ }
+ else
+ alSetError(Context, AL_OUT_OF_MEMORY);
}
else
- alSetError(Context, AL_OUT_OF_MEMORY);
+ alSetError(Context, AL_INVALID_VALUE);
}
else
alSetError(Context, AL_INVALID_ENUM);
@@ -248,7 +253,7 @@ ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei s
ProcessContext(Context);
}
-ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei length, const ALvoid *data)
+ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALintptrEXT start, ALsizeiptrEXT length, const ALvoid *data)
{
ALCcontext *pContext;
ALdatabuffer *pBuffer;
@@ -260,7 +265,7 @@ ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei
Device = pContext->Device;
if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL)
{
- if(length >= 0 && start+length <= pBuffer->size)
+ if(start >= 0 && length >= 0 && start+length <= pBuffer->size)
{
if(pBuffer->state == UNMAPPED)
memcpy(pBuffer->data+start, data, length);
@@ -276,7 +281,7 @@ ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei
ProcessContext(pContext);
}
-ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei length, ALvoid *data)
+ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALintptrEXT start, ALsizeiptrEXT length, ALvoid *data)
{
ALCcontext *pContext;
ALdatabuffer *pBuffer;
@@ -288,7 +293,7 @@ ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsiz
Device = pContext->Device;
if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL)
{
- if(length >= 0 && start+length <= pBuffer->size)
+ if(start >= 0 && length >= 0 && start+length <= pBuffer->size)
{
if(pBuffer->state == UNMAPPED)
memcpy(data, pBuffer->data+start, length);
@@ -564,7 +569,7 @@ ALvoid ALAPIENTRY alSelectDatabufferEXT(ALenum target, ALuint uiBuffer)
}
-ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei length, ALenum access)
+ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALintptrEXT start, ALsizeiptrEXT length, ALenum access)
{
ALCcontext *pContext;
ALdatabuffer *pBuffer;
@@ -577,7 +582,7 @@ ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei len
Device = pContext->Device;
if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL)
{
- if(length >= 0 && start+length <= pBuffer->size)
+ if(start >= 0 && length >= 0 && start+length <= pBuffer->size)
{
if(access == AL_READ_ONLY_EXT || access == AL_WRITE_ONLY_EXT ||
access == AL_READ_WRITE_EXT)