Add alBufferSubSamplesSOFT

This commit is contained in:
Chris Robinson 2011-03-16 12:13:17 -07:00
parent 2f7de9d696
commit f5c4e67aef
2 changed files with 68 additions and 0 deletions

View File

@ -48,10 +48,14 @@ ALC_API void ALC_APIENTRY alcRenderSamples(ALCdevice *device, ALCvoid *buffer, A
#ifndef AL_SOFT_buffer_samples #ifndef AL_SOFT_buffer_samples
#define AL_SOFT_buffer_samples 1 #define AL_SOFT_buffer_samples 1
typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*); typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
#ifdef AL_ALEXT_PROTOTYPES #ifdef AL_ALEXT_PROTOTYPES
AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
ALuint samplerate, ALenum internalformat, ALsizei frames, ALuint samplerate, ALenum internalformat, ALsizei frames,
ALenum channels, ALenum type, const ALvoid *data); ALenum channels, ALenum type, const ALvoid *data);
AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
ALsizei offset, ALsizei frames,
ALenum channels, ALenum type, const ALvoid *data);
#endif #endif
#endif #endif

View File

@ -531,6 +531,70 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
ProcessContext(Context); ProcessContext(Context);
} }
AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
ALsizei offset, ALsizei frames,
ALenum channels, ALenum type, const ALvoid *data)
{
ALCcontext *Context;
ALCdevice *device;
ALbuffer *ALBuf;
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(frames < 0 || offset < 0 || (frames > 0 && data == NULL))
alSetError(Context, AL_INVALID_VALUE);
else if(channels != (ALenum)ALBuf->FmtChannels ||
IsValidType(type) == AL_FALSE)
alSetError(Context, AL_INVALID_ENUM);
else
{
ALuint FrameSize = FrameSizeFromFmt(ALBuf->FmtChannels, ALBuf->FmtType);
ALuint FrameCount = ALBuf->size / FrameSize;
if((ALuint)offset > FrameCount || (ALuint)frames > FrameCount-offset)
alSetError(Context, AL_INVALID_VALUE);
else if(type == UserFmtIMA4 && (frames%65) != 0)
alSetError(Context, AL_INVALID_VALUE);
else if(type == UserFmtIMA4)
{
/* offset -> byte offset, length -> block count */
offset *= FrameSize;
frames /= 65;
ConvertInputIMA4(&((ALubyte*)ALBuf->data)[offset],
ALBuf->FmtType, data,
ChannelsFromFmt(ALBuf->FmtChannels),
frames);
}
else
{
/* offset -> byte offset */
offset *= FrameSize;
ConvertInput(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType,
data, type, frames*ChannelsFromUserFmt(channels));
}
}
ProcessContext(Context);
}
AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue) AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue)
{ {