aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alBuffer.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2007-12-28 22:41:14 -0800
committerChris Robinson <[email protected]>2007-12-28 22:41:14 -0800
commit5f8e65e09941c9c5d48e2277a8b1be1e35f04a9a (patch)
treec0b71503e829f3cf2dcda7aaea081da4610a357c /OpenAL32/alBuffer.c
parentd90b36cf1147b0b14068db55a7510ffb0d2d2641 (diff)
Implement AL_EXT_FLOAT32
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r--OpenAL32/alBuffer.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index ab5b60d8..d1a8c359 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -282,6 +282,10 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_MONO16);
break;
+ case AL_FORMAT_MONO_FLOAT32:
+ LoadData(ALBuf, data, size, freq, format, AL_FORMAT_MONO16);
+ break;
+
case AL_FORMAT_STEREO8:
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_STEREO16);
break;
@@ -290,6 +294,10 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_STEREO16);
break;
+ case AL_FORMAT_STEREO_FLOAT32:
+ LoadData(ALBuf, data, size, freq, format, AL_FORMAT_STEREO16);
+ break;
+
case AL_FORMAT_MONO_IMA4:
// Here is where things vary:
// nVidia and Apple use 64+1 samples per block => block_size=36 bytes
@@ -913,6 +921,26 @@ static void LoadData(ALbuffer *ALBuf, const ALubyte *data, ALsizei size, ALuint
alSetError(AL_OUT_OF_MEMORY);
break;
+ case 4:
+ size /= sizeof(ALfloat);
+
+ // Allocate 8 extra samples
+ ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort)));
+ if (ALBuf->data)
+ {
+ for (i = 0;i < size;i++)
+ ALBuf->data[i] = (ALshort)(((ALfloat*)data)[i] * 32767.5f - 0.5);
+ memset(&(ALBuf->data[size]), 0, 16*NewChannels);
+
+ ALBuf->format = NewFormat;
+ ALBuf->eOriginalFormat = OrigFormat;
+ ALBuf->size = size*1*sizeof(ALshort);
+ ALBuf->frequency = freq;
+ }
+ else
+ alSetError(AL_OUT_OF_MEMORY);
+ break;
+
default:
assert(0);
}