aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c4
-rw-r--r--OpenAL32/Include/alMain.h13
-rw-r--r--OpenAL32/alBuffer.c61
3 files changed, 76 insertions, 2 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 3d157ca1..8b4ef439 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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)
{
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 75ebc488..e684d999 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -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__)
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;