diff options
author | Chris Robinson <[email protected]> | 2011-03-16 12:24:53 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-03-16 12:24:53 -0700 |
commit | 5621ee42398c19480c3c88193252d273922d181b (patch) | |
tree | 9b19605ae716aee7632a5c34e410029dda8f1331 /OpenAL32/alBuffer.c | |
parent | f5c4e67aef6c630d748ce3100428b9c6ce372715 (diff) |
Buffers made with alBufferSamplesSOFT always reference the internal format
This is not necessarily the same as the format of the originating data
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r-- | OpenAL32/alBuffer.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index b9bada1f..cb8af518 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -34,7 +34,7 @@ #include "alThunk.h" -static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels chans, enum UserFmtType type, const ALvoid *data); +static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels chans, enum UserFmtType type, const ALvoid *data, ALboolean storesrc); static void ConvertInput(ALvoid *dst, enum FmtType dstType, const ALvoid *src, enum UserFmtType srcType, ALsizei len); static void ConvertInputIMA4(ALvoid *dst, enum FmtType dstType, const ALvoid *src, ALint chans, ALsizei len); @@ -331,7 +331,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid err = AL_INVALID_VALUE; else err = LoadData(ALBuf, freq, format, size/FrameSize, - SrcChannels, SrcType, data); + SrcChannels, SrcType, data, AL_TRUE); if(err != AL_NO_ERROR) alSetError(Context, err); } break; @@ -353,7 +353,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid err = AL_INVALID_VALUE; else err = LoadData(ALBuf, freq, NewFormat, size/FrameSize, - SrcChannels, SrcType, data); + SrcChannels, SrcType, data, AL_TRUE); if(err != AL_NO_ERROR) alSetError(Context, err); } break; @@ -382,7 +382,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid err = AL_INVALID_VALUE; else err = LoadData(ALBuf, freq, NewFormat, size/FrameSize, - SrcChannels, SrcType, data); + SrcChannels, SrcType, data, AL_TRUE); if(err != AL_NO_ERROR) alSetError(Context, err); } break; @@ -523,7 +523,7 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, } if(err == AL_NO_ERROR) err = LoadData(ALBuf, samplerate, internalformat, frames, - channels, type, data); + channels, type, data, AL_FALSE); if(err != AL_NO_ERROR) alSetError(Context, err); } @@ -1648,7 +1648,7 @@ static void ConvertInputIMA4(ALvoid *dst, enum FmtType dstType, const ALvoid *sr * Currently, the new format must have the same channel configuration as the * original format. */ -static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels SrcChannels, enum UserFmtType SrcType, const ALvoid *data) +static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels SrcChannels, enum UserFmtType SrcType, const ALvoid *data, ALboolean storesrc) { ALuint NewChannels, NewBytes; enum FmtChannels DstChannels; @@ -1682,10 +1682,13 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f ConvertInputIMA4(ALBuf->data, DstType, data, OrigChannels, newsize/(65*NewChannels*NewBytes)); - ALBuf->OriginalChannels = SrcChannels; - ALBuf->OriginalType = SrcType; - ALBuf->OriginalSize = frames * 36 * OrigChannels; - ALBuf->OriginalAlign = 36 * OrigChannels; + if(storesrc) + { + ALBuf->OriginalChannels = SrcChannels; + ALBuf->OriginalType = SrcType; + ALBuf->OriginalSize = frames * 36 * OrigChannels; + ALBuf->OriginalAlign = 36 * OrigChannels; + } } else { @@ -1706,12 +1709,22 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f if(data != NULL) ConvertInput(ALBuf->data, DstType, data, SrcType, newsize/NewBytes); - ALBuf->OriginalChannels = SrcChannels; - ALBuf->OriginalType = SrcType; - ALBuf->OriginalSize = frames * OrigBytes * OrigChannels; - ALBuf->OriginalAlign = OrigBytes * OrigChannels; + if(storesrc) + { + ALBuf->OriginalChannels = SrcChannels; + ALBuf->OriginalType = SrcType; + ALBuf->OriginalSize = frames * OrigBytes * OrigChannels; + ALBuf->OriginalAlign = OrigBytes * OrigChannels; + } } + if(!storesrc) + { + ALBuf->OriginalChannels = DstChannels; + ALBuf->OriginalType = DstType; + ALBuf->OriginalSize = frames * NewBytes * NewChannels; + ALBuf->OriginalAlign = NewBytes * NewChannels; + } ALBuf->Frequency = freq; ALBuf->FmtChannels = DstChannels; ALBuf->FmtType = DstType; |