From 219f818b165d6997d6a2f1f8f0c5f88ba68a5db2 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 24 May 2019 13:32:20 -0700 Subject: Use al::byte for ADPCM decoders --- OpenAL32/alBuffer.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'OpenAL32/alBuffer.cpp') diff --git a/OpenAL32/alBuffer.cpp b/OpenAL32/alBuffer.cpp index 700c0de9..738133f5 100644 --- a/OpenAL32/alBuffer.cpp +++ b/OpenAL32/alBuffer.cpp @@ -185,7 +185,7 @@ const ALchar *NameFromUserFmtType(UserFmtType type) * * Loads the specified data into the buffer, using the specified format. */ -void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, UserFmtChannels SrcChannels, UserFmtType SrcType, const ALvoid *data, ALbitfieldSOFT access) +void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, UserFmtChannels SrcChannels, UserFmtType SrcType, const al::byte *SrcData, ALbitfieldSOFT access) { if(UNLIKELY(ReadRef(&ALBuf->ref) != 0 || ALBuf->MappedAccess != 0)) SETERR_RETURN(context, AL_INVALID_OPERATION,, "Modifying storage for in-use buffer %u", @@ -287,7 +287,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U newsize = RoundUp(newsize, 16); if(newsize != ALBuf->mData.size()) { - auto newdata = al::vector(newsize); + auto newdata = al::vector(newsize, al::byte{}); if((access&AL_PRESERVE_DATA_BIT_SOFT)) { const size_t tocopy{minz(newdata.size(), ALBuf->mData.size())}; @@ -299,25 +299,24 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U if(SrcType == UserFmtIMA4) { assert(DstType == FmtShort); - if(data != nullptr && !ALBuf->mData.empty()) + if(SrcData != nullptr && !ALBuf->mData.empty()) Convert_ALshort_ALima4(reinterpret_cast(ALBuf->mData.data()), - static_cast(data), NumChannels, frames, align); + SrcData, NumChannels, frames, align); ALBuf->OriginalAlign = align; } else if(SrcType == UserFmtMSADPCM) { assert(DstType == FmtShort); - if(data != nullptr && !ALBuf->mData.empty()) + if(SrcData != nullptr && !ALBuf->mData.empty()) Convert_ALshort_ALmsadpcm(reinterpret_cast(ALBuf->mData.data()), - static_cast(data), NumChannels, frames, align); + SrcData, NumChannels, frames, align); ALBuf->OriginalAlign = align; } else { assert(static_cast(SrcType) == static_cast(DstType)); - if(data != nullptr && !ALBuf->mData.empty()) - std::copy_n(static_cast(data), frames*FrameSize, - ALBuf->mData.begin()); + if(SrcData != nullptr && !ALBuf->mData.empty()) + std::copy_n(SrcData, frames*FrameSize, ALBuf->mData.begin()); ALBuf->OriginalAlign = 1; } ALBuf->OriginalSize = size; @@ -560,7 +559,8 @@ START_API_FUNC if(UNLIKELY(!success)) alSetError(context.get(), AL_INVALID_ENUM, "Invalid format 0x%04x", format); else - LoadData(context.get(), albuf, freq, size, srcchannels, srctype, data, flags); + LoadData(context.get(), albuf, freq, size, srcchannels, srctype, + static_cast(data), flags); } } END_API_FUNC @@ -745,14 +745,13 @@ START_API_FUNC void *dst = albuf->mData.data() + offset; if(srctype == UserFmtIMA4 && albuf->mFmtType == FmtShort) Convert_ALshort_ALima4(static_cast(dst), - static_cast(data), num_chans, length, align); + static_cast(data), num_chans, length, align); else if(srctype == UserFmtMSADPCM && albuf->mFmtType == FmtShort) Convert_ALshort_ALmsadpcm(static_cast(dst), - static_cast(data), num_chans, length, align); + static_cast(data), num_chans, length, align); else { - assert(static_cast(srctype) == - static_cast(albuf->mFmtType)); + assert(static_cast(srctype) == static_cast(albuf->mFmtType)); memcpy(dst, data, length * frame_size); } } -- cgit v1.2.3