diff options
author | Chris Robinson <[email protected]> | 2020-08-28 00:09:46 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-08-28 00:09:46 -0700 |
commit | 1f486f820e97fd5ce1da40a87aa3b743800fb5b0 (patch) | |
tree | 04e70d2410fcaad3167899b81b2661b57c0488fe /alc/buffer_storage.h | |
parent | ecf30de36f6487c1f8a19ae0d03ba810078706f4 (diff) |
Use a separate structure for buffer storage
Diffstat (limited to 'alc/buffer_storage.h')
-rw-r--r-- | alc/buffer_storage.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/alc/buffer_storage.h b/alc/buffer_storage.h index b10cea4c..4a5b8b5c 100644 --- a/alc/buffer_storage.h +++ b/alc/buffer_storage.h @@ -2,6 +2,11 @@ #define ALC_BUFFER_FORMATS_H #include "AL/al.h" +#include "AL/alext.h" + +#include "albyte.h" +#include "inprogext.h" +#include "vector.h" /* Storable formats */ @@ -25,9 +30,44 @@ enum FmtChannels : unsigned char { FmtBFormat3D, }; +enum class AmbiLayout : unsigned char { + FuMa = AL_FUMA_SOFT, + ACN = AL_ACN_SOFT, +}; +enum class AmbiScaling : unsigned char { + FuMa = AL_FUMA_SOFT, + SN3D = AL_SN3D_SOFT, + N3D = AL_N3D_SOFT, +}; + ALuint BytesFromFmt(FmtType type) noexcept; ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept; inline ALuint FrameSizeFromFmt(FmtChannels chans, FmtType type, ALuint ambiorder) noexcept { return ChannelsFromFmt(chans, ambiorder) * BytesFromFmt(type); } + +struct BufferStorage { + al::vector<al::byte,16> mData; + + LPALBUFFERCALLBACKTYPESOFT mCallback{nullptr}; + void *mUserData{nullptr}; + + ALuint mSampleRate{0u}; + FmtChannels mChannels{}; + FmtType mType{}; + ALuint mSampleLen{0u}; + + AmbiLayout mAmbiLayout{AmbiLayout::FuMa}; + AmbiScaling mAmbiScaling{AmbiScaling::FuMa}; + ALuint mAmbiOrder{0u}; + + inline ALuint bytesFromFmt() const noexcept { return BytesFromFmt(mType); } + inline ALuint channelsFromFmt() const noexcept + { return ChannelsFromFmt(mChannels, mAmbiOrder); } + inline ALuint frameSizeFromFmt() const noexcept { return channelsFromFmt() * bytesFromFmt(); } + + inline bool isBFormat() const noexcept + { return mChannels == FmtBFormat2D || mChannels == FmtBFormat3D; } +}; + #endif /* ALC_BUFFER_FORMATS_H */ |