diff options
author | Chris Robinson <[email protected]> | 2011-03-16 11:29:22 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-03-16 11:29:22 -0700 |
commit | 2f7de9d696fc58f31c4caf7ee6ee36428235aea7 (patch) | |
tree | 101370af52952e3de75931214e7aa35d7af4df61 /OpenAL32/alBuffer.c | |
parent | 9cee723e928c1c39233cf80828557f4b76530642 (diff) |
Add alBufferSamplesSOFT, as an initial start to AL_SOFT_buffer_samples
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r-- | OpenAL32/alBuffer.c | 61 |
1 files changed, 61 insertions, 0 deletions
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; |