mirror of
https://github.com/love2d/megasource.git
synced 2026-08-17 11:11:35 +02:00
Update OpenAL-soft to 1.23.1-bc7cb17.
This commit is contained in:
@@ -2,55 +2,16 @@
|
||||
#define CORE_BUFFER_STORAGE_H
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
|
||||
#include "albyte.h"
|
||||
#include "alnumeric.h"
|
||||
#include "alspan.h"
|
||||
#include "ambidefs.h"
|
||||
#include "storage_formats.h"
|
||||
|
||||
|
||||
using uint = unsigned int;
|
||||
|
||||
/* Storable formats */
|
||||
enum FmtType : unsigned char {
|
||||
FmtUByte,
|
||||
FmtShort,
|
||||
FmtFloat,
|
||||
FmtDouble,
|
||||
FmtMulaw,
|
||||
FmtAlaw,
|
||||
};
|
||||
enum FmtChannels : unsigned char {
|
||||
FmtMono,
|
||||
FmtStereo,
|
||||
FmtRear,
|
||||
FmtQuad,
|
||||
FmtX51, /* (WFX order) */
|
||||
FmtX61, /* (WFX order) */
|
||||
FmtX71, /* (WFX order) */
|
||||
FmtBFormat2D,
|
||||
FmtBFormat3D,
|
||||
FmtUHJ2, /* 2-channel UHJ, aka "BHJ", stereo-compatible */
|
||||
FmtUHJ3, /* 3-channel UHJ, aka "THJ" */
|
||||
FmtUHJ4, /* 4-channel UHJ, aka "PHJ" */
|
||||
FmtSuperStereo, /* Stereo processed with Super Stereo. */
|
||||
};
|
||||
|
||||
enum class AmbiLayout : unsigned char {
|
||||
FuMa,
|
||||
ACN,
|
||||
};
|
||||
enum class AmbiScaling : unsigned char {
|
||||
FuMa,
|
||||
SN3D,
|
||||
N3D,
|
||||
UHJ,
|
||||
};
|
||||
|
||||
uint BytesFromFmt(FmtType type) noexcept;
|
||||
uint ChannelsFromFmt(FmtChannels chans, uint ambiorder) noexcept;
|
||||
inline uint FrameSizeFromFmt(FmtChannels chans, FmtType type, uint ambiorder) noexcept
|
||||
{ return ChannelsFromFmt(chans, ambiorder) * BytesFromFmt(type); }
|
||||
|
||||
constexpr bool IsBFormat(FmtChannels chans) noexcept
|
||||
{ return chans == FmtBFormat2D || chans == FmtBFormat3D; }
|
||||
|
||||
@@ -79,21 +40,32 @@ struct BufferStorage {
|
||||
CallbackType mCallback{nullptr};
|
||||
void *mUserData{nullptr};
|
||||
|
||||
al::span<std::byte> mData;
|
||||
|
||||
uint mSampleRate{0u};
|
||||
FmtChannels mChannels{FmtMono};
|
||||
FmtType mType{FmtShort};
|
||||
uint mSampleLen{0u};
|
||||
uint mBlockAlign{0u};
|
||||
|
||||
AmbiLayout mAmbiLayout{AmbiLayout::FuMa};
|
||||
AmbiScaling mAmbiScaling{AmbiScaling::FuMa};
|
||||
uint mAmbiOrder{0u};
|
||||
|
||||
inline uint bytesFromFmt() const noexcept { return BytesFromFmt(mType); }
|
||||
inline uint channelsFromFmt() const noexcept
|
||||
[[nodiscard]] auto bytesFromFmt() const noexcept -> uint { return BytesFromFmt(mType); }
|
||||
[[nodiscard]] auto channelsFromFmt() const noexcept -> uint
|
||||
{ return ChannelsFromFmt(mChannels, mAmbiOrder); }
|
||||
inline uint frameSizeFromFmt() const noexcept { return channelsFromFmt() * bytesFromFmt(); }
|
||||
[[nodiscard]] auto frameSizeFromFmt() const noexcept -> uint
|
||||
{ return channelsFromFmt() * bytesFromFmt(); }
|
||||
|
||||
inline bool isBFormat() const noexcept { return IsBFormat(mChannels); }
|
||||
[[nodiscard]] auto blockSizeFromFmt() const noexcept -> uint
|
||||
{
|
||||
if(mType == FmtIMA4) return ((mBlockAlign-1)/2 + 4) * channelsFromFmt();
|
||||
if(mType == FmtMSADPCM) return ((mBlockAlign-2)/2 + 7) * channelsFromFmt();
|
||||
return frameSizeFromFmt();
|
||||
};
|
||||
|
||||
[[nodiscard]] auto isBFormat() const noexcept -> bool { return IsBFormat(mChannels); }
|
||||
};
|
||||
|
||||
#endif /* CORE_BUFFER_STORAGE_H */
|
||||
|
||||
Reference in New Issue
Block a user