Use ptrdiff types for databuffer offset/length handling
Should improve addressing for non-32-bit systems
This commit is contained in:
parent
e1965fe7d9
commit
2355d6a4a0
@ -12,14 +12,14 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct ALdatabuffer
|
typedef struct ALdatabuffer
|
||||||
{
|
{
|
||||||
ALubyte *data;
|
ALubyte *data;
|
||||||
ALuint size;
|
ALintptrEXT size;
|
||||||
ALenum state;
|
|
||||||
|
|
||||||
ALenum usage;
|
ALenum state;
|
||||||
|
ALenum usage;
|
||||||
|
|
||||||
/* Index to self */
|
/* Index to self */
|
||||||
ALuint databuffer;
|
ALuint databuffer;
|
||||||
|
|
||||||
struct ALdatabuffer *next;
|
struct ALdatabuffer *next;
|
||||||
} ALdatabuffer;
|
} ALdatabuffer;
|
||||||
@ -28,9 +28,9 @@ ALvoid ALAPIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers);
|
|||||||
ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers);
|
ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers);
|
||||||
ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer);
|
ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer);
|
||||||
|
|
||||||
ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei size,ALenum usage);
|
ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizeiptrEXT size,ALenum usage);
|
||||||
ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint buffer, ALuint start, ALsizei length, const ALvoid *data);
|
ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint buffer, ALintptrEXT start, ALsizeiptrEXT length, const ALvoid *data);
|
||||||
ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint buffer, ALuint start, ALsizei length, ALvoid *data);
|
ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint buffer, ALintptrEXT start, ALsizeiptrEXT length, ALvoid *data);
|
||||||
|
|
||||||
ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue);
|
ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue);
|
||||||
ALvoid ALAPIENTRY alDatabufferfvEXT(ALuint buffer, ALenum eParam, const ALfloat* flValues);
|
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 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 ALAPIENTRY alUnmapDatabufferEXT(ALuint uiBuffer);
|
||||||
|
|
||||||
ALvoid ReleaseALDatabuffers(ALCdevice *device);
|
ALvoid ReleaseALDatabuffers(ALCdevice *device);
|
||||||
|
@ -276,7 +276,7 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
|
|||||||
{
|
{
|
||||||
if(Context->SampleSource)
|
if(Context->SampleSource)
|
||||||
{
|
{
|
||||||
ALuint offset;
|
ALintptrEXT offset;
|
||||||
|
|
||||||
if(Context->SampleSource->state == MAPPED)
|
if(Context->SampleSource->state == MAPPED)
|
||||||
{
|
{
|
||||||
@ -285,7 +285,7 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = (ALuint)data;
|
offset = (ALintptrEXT)data;
|
||||||
data = Context->SampleSource->data + offset;
|
data = Context->SampleSource->data + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +525,7 @@ ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *d
|
|||||||
{
|
{
|
||||||
if(Context->SampleSource)
|
if(Context->SampleSource)
|
||||||
{
|
{
|
||||||
ALuint offset;
|
ALintptrEXT offset;
|
||||||
|
|
||||||
if(Context->SampleSource->state == MAPPED)
|
if(Context->SampleSource->state == MAPPED)
|
||||||
{
|
{
|
||||||
@ -534,7 +534,7 @@ ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *d
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = (ALuint)data;
|
offset = (ALintptrEXT)data;
|
||||||
data = Context->SampleSource->data + offset;
|
data = Context->SampleSource->data + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer)
|
|||||||
*
|
*
|
||||||
* Fill databuffer with data
|
* 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;
|
ALCcontext *Context;
|
||||||
ALdatabuffer *ALBuf;
|
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_WRITE_EXT || usage == AL_DYNAMIC_READ_EXT ||
|
||||||
usage == AL_DYNAMIC_COPY_EXT)
|
usage == AL_DYNAMIC_COPY_EXT)
|
||||||
{
|
{
|
||||||
/* (Re)allocate data */
|
if(size >= 0)
|
||||||
temp = realloc(ALBuf->data, size);
|
|
||||||
if(temp)
|
|
||||||
{
|
{
|
||||||
ALBuf->data = temp;
|
/* (Re)allocate data */
|
||||||
ALBuf->size = size;
|
temp = realloc(ALBuf->data, size);
|
||||||
ALBuf->usage = usage;
|
if(temp)
|
||||||
if(data)
|
{
|
||||||
memcpy(ALBuf->data, data, size);
|
ALBuf->data = temp;
|
||||||
|
ALBuf->size = size;
|
||||||
|
ALBuf->usage = usage;
|
||||||
|
if(data)
|
||||||
|
memcpy(ALBuf->data, data, size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
alSetError(Context, AL_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
alSetError(Context, AL_OUT_OF_MEMORY);
|
alSetError(Context, AL_INVALID_VALUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
alSetError(Context, AL_INVALID_ENUM);
|
alSetError(Context, AL_INVALID_ENUM);
|
||||||
@ -248,7 +253,7 @@ ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei s
|
|||||||
ProcessContext(Context);
|
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;
|
ALCcontext *pContext;
|
||||||
ALdatabuffer *pBuffer;
|
ALdatabuffer *pBuffer;
|
||||||
@ -260,7 +265,7 @@ ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei
|
|||||||
Device = pContext->Device;
|
Device = pContext->Device;
|
||||||
if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL)
|
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)
|
if(pBuffer->state == UNMAPPED)
|
||||||
memcpy(pBuffer->data+start, data, length);
|
memcpy(pBuffer->data+start, data, length);
|
||||||
@ -276,7 +281,7 @@ ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei
|
|||||||
ProcessContext(pContext);
|
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;
|
ALCcontext *pContext;
|
||||||
ALdatabuffer *pBuffer;
|
ALdatabuffer *pBuffer;
|
||||||
@ -288,7 +293,7 @@ ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsiz
|
|||||||
Device = pContext->Device;
|
Device = pContext->Device;
|
||||||
if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL)
|
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)
|
if(pBuffer->state == UNMAPPED)
|
||||||
memcpy(data, pBuffer->data+start, length);
|
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;
|
ALCcontext *pContext;
|
||||||
ALdatabuffer *pBuffer;
|
ALdatabuffer *pBuffer;
|
||||||
@ -577,7 +582,7 @@ ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei len
|
|||||||
Device = pContext->Device;
|
Device = pContext->Device;
|
||||||
if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL)
|
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 ||
|
if(access == AL_READ_ONLY_EXT || access == AL_WRITE_ONLY_EXT ||
|
||||||
access == AL_READ_WRITE_EXT)
|
access == AL_READ_WRITE_EXT)
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#ifndef AL_ALEXT_H
|
#ifndef AL_ALEXT_H
|
||||||
#define AL_ALEXT_H
|
#define AL_ALEXT_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -122,6 +124,8 @@ typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid
|
|||||||
|
|
||||||
#ifndef AL_EXT_sample_buffer_object
|
#ifndef AL_EXT_sample_buffer_object
|
||||||
#define AL_EXT_sample_buffer_object 1
|
#define AL_EXT_sample_buffer_object 1
|
||||||
|
typedef ptrdiff_t ALintptrEXT;
|
||||||
|
typedef ptrdiff_t ALsizeiptrEXT;
|
||||||
#define AL_SAMPLE_SOURCE_EXT 0x1040
|
#define AL_SAMPLE_SOURCE_EXT 0x1040
|
||||||
#define AL_SAMPLE_SINK_EXT 0x1041
|
#define AL_SAMPLE_SINK_EXT 0x1041
|
||||||
#define AL_READ_ONLY_EXT 0x1042
|
#define AL_READ_ONLY_EXT 0x1042
|
||||||
@ -139,9 +143,9 @@ typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid
|
|||||||
typedef ALvoid (AL_APIENTRY*PFNALGENDATABUFFERSEXTPROC)(ALsizei n,ALuint *puiBuffers);
|
typedef ALvoid (AL_APIENTRY*PFNALGENDATABUFFERSEXTPROC)(ALsizei n,ALuint *puiBuffers);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALDELETEDATABUFFERSEXTPROC)(ALsizei n, const ALuint *puiBuffers);
|
typedef ALvoid (AL_APIENTRY*PFNALDELETEDATABUFFERSEXTPROC)(ALsizei n, const ALuint *puiBuffers);
|
||||||
typedef ALboolean (AL_APIENTRY*PFNALISDATABUFFEREXTPROC)(ALuint uiBuffer);
|
typedef ALboolean (AL_APIENTRY*PFNALISDATABUFFEREXTPROC)(ALuint uiBuffer);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERDATAEXTPROC)(ALuint buffer,const ALvoid *data,ALsizei size,ALenum usage);
|
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERDATAEXTPROC)(ALuint buffer,const ALvoid *data,ALsizeiptrEXT size,ALenum usage);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERSUBDATAEXTPROC)(ALuint buffer, ALuint start, ALsizei length, const ALvoid *);
|
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERSUBDATAEXTPROC)(ALuint buffer, ALintptrEXT start, ALsizeiptrEXT length, const ALvoid *);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERSUBDATAEXTPROC)(ALuint buffer, ALuint start, ALsizei length, ALvoid *);
|
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERSUBDATAEXTPROC)(ALuint buffer, ALintptrEXT start, ALsizeiptrEXT length, ALvoid *);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERFEXTPROC)(ALuint buffer, ALenum eParam, ALfloat flValue);
|
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERFEXTPROC)(ALuint buffer, ALenum eParam, ALfloat flValue);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERFVEXTPROC)(ALuint buffer, ALenum eParam, const ALfloat* flValues);
|
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERFVEXTPROC)(ALuint buffer, ALenum eParam, const ALfloat* flValues);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERIEXTPROC)(ALuint buffer, ALenum eParam, ALint lValue);
|
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERIEXTPROC)(ALuint buffer, ALenum eParam, ALint lValue);
|
||||||
@ -151,7 +155,7 @@ typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERFVEXTPROC)(ALuint buffer, ALenum e
|
|||||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERIEXTPROC)(ALuint buffer, ALenum eParam, ALint *plValue);
|
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERIEXTPROC)(ALuint buffer, ALenum eParam, ALint *plValue);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERIVEXTPROC)(ALuint buffer, ALenum eParam, ALint* plValues);
|
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERIVEXTPROC)(ALuint buffer, ALenum eParam, ALint* plValues);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALSELECTDATABUFFEREXTPROC)(ALenum target, ALuint uiBuffer);
|
typedef ALvoid (AL_APIENTRY*PFNALSELECTDATABUFFEREXTPROC)(ALenum target, ALuint uiBuffer);
|
||||||
typedef ALvoid* (AL_APIENTRY*PFNALMAPDATABUFFEREXTPROC)(ALuint uiBuffer, ALuint start, ALsizei length, ALenum access);
|
typedef ALvoid* (AL_APIENTRY*PFNALMAPDATABUFFEREXTPROC)(ALuint uiBuffer, ALintptrEXT start, ALsizeiptrEXT length, ALenum access);
|
||||||
typedef ALvoid (AL_APIENTRY*PFNALUNMAPDATABUFFEREXTPROC)(ALuint uiBuffer);
|
typedef ALvoid (AL_APIENTRY*PFNALUNMAPDATABUFFEREXTPROC)(ALuint uiBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user