From 2f7de9d696fc58f31c4caf7ee6ee36428235aea7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Mar 2011 11:29:22 -0700 Subject: Add alBufferSamplesSOFT, as an initial start to AL_SOFT_buffer_samples --- OpenAL32/alBuffer.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'OpenAL32/alBuffer.c') diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 74abe3bd..6ffa58f9 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -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; -- cgit v1.2.3