Add alBufferSamplesSOFT, as an initial start to AL_SOFT_buffer_samples

This commit is contained in:
Chris Robinson
2011-03-16 11:29:22 -07:00
parent 9cee723e92
commit 2f7de9d696
3 changed files with 76 additions and 2 deletions
+2 -2
View File
@@ -893,7 +893,7 @@ ALboolean DecomposeDevFormat(ALenum format, enum DevFmtChannels *chans,
return AL_FALSE;
}
static ALboolean IsValidType(ALenum type)
ALboolean IsValidType(ALenum type)
{
switch(type)
{
@@ -912,7 +912,7 @@ static ALboolean IsValidType(ALenum type)
return AL_FALSE;
}
static ALboolean IsValidChannels(ALenum channels)
ALboolean IsValidChannels(ALenum channels)
{
switch(channels)
{
+13
View File
@@ -45,6 +45,16 @@ ALC_API void ALC_APIENTRY alcRenderSamples(ALCdevice *device, ALCvoid *buffer, A
#endif
#endif
#ifndef AL_SOFT_buffer_samples
#define AL_SOFT_buffer_samples 1
typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
#ifdef AL_ALEXT_PROTOTYPES
AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
ALuint samplerate, ALenum internalformat, ALsizei frames,
ALenum channels, ALenum type, const ALvoid *data);
#endif
#endif
#ifndef AL_EXT_sample_buffer_object
#define AL_EXT_sample_buffer_object 1
typedef ptrdiff_t ALintptrEXT;
@@ -530,6 +540,9 @@ void SetRTPriority(void);
void SetDefaultChannelOrder(ALCdevice *device);
void SetDefaultWFXChannelOrder(ALCdevice *device);
ALboolean IsValidType(ALenum type);
ALboolean IsValidChannels(ALenum type);
void al_print(const char *fname, unsigned int line, const char *fmt, ...)
PRINTF_STYLE(3,4);
#define AL_PRINT(...) al_print(__FILE__, __LINE__, __VA_ARGS__)
+61
View File
@@ -471,6 +471,67 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const
}
AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
ALuint samplerate, ALenum internalformat, ALsizei frames,
ALenum channels, ALenum type, const ALvoid *data)
{
enum FmtChannels DstChannels;
enum FmtType DstType;
ALCcontext *Context;
ALCdevice *device;
ALbuffer *ALBuf;
ALenum err;
Context = GetContextSuspended();
if(!Context) return;
if(Context->SampleSource)
{
ALintptrEXT offset;
if(Context->SampleSource->state == MAPPED)
{
alSetError(Context, AL_INVALID_OPERATION);
ProcessContext(Context);
return;
}
offset = (const ALubyte*)data - (ALubyte*)NULL;
data = Context->SampleSource->data + offset;
}
device = Context->Device;
if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
alSetError(Context, AL_INVALID_NAME);
else if(ALBuf->refcount != 0)
alSetError(Context, AL_INVALID_VALUE);
else if(frames < 0 || samplerate == 0)
alSetError(Context, AL_INVALID_VALUE);
else if(DecomposeFormat(internalformat, &DstChannels, &DstType) == AL_FALSE)
alSetError(Context, AL_INVALID_ENUM);
else if(IsValidType(type) == AL_FALSE || IsValidChannels(channels) == AL_FALSE)
alSetError(Context, AL_INVALID_ENUM);
else if(channels != (ALenum)DstChannels)
alSetError(Context, AL_INVALID_ENUM);
else
{
err = AL_NO_ERROR;
if(type == UserFmtIMA4)
{
if((frames%65) == 0) frames /= 65;
else err = AL_INVALID_VALUE;
}
if(err == AL_NO_ERROR)
err = LoadData(ALBuf, samplerate, internalformat, frames,
channels, type, data);
if(err != AL_NO_ERROR)
alSetError(Context, err);
}
ProcessContext(Context);
}
AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue)
{
ALCcontext *pContext;