From b0919240ab73f2e340f26a913baf7524b35a4c85 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 27 Nov 2020 19:18:17 -0800 Subject: Move some sources to a separate directory To begin separating the ALC interfaces from internal ones. --- CMakeLists.txt | 6 ++- alc/alc.cpp | 62 +----------------------------- alc/alcmain.h | 7 +--- alc/alu.cpp | 2 +- alc/bformatdec.h | 2 +- alc/bufferline.h | 15 -------- alc/converter.h | 2 +- alc/devformat.h | 100 ------------------------------------------------ alc/front_stablizer.h | 2 +- alc/hrtf.h | 2 +- alc/panning.cpp | 2 +- alc/voice.cpp | 2 +- alc/voice.h | 2 +- core/bufferline.h | 14 +++++++ core/devformat.cpp | 65 +++++++++++++++++++++++++++++++ core/devformat.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++ 16 files changed, 197 insertions(+), 191 deletions(-) delete mode 100644 alc/bufferline.h delete mode 100644 alc/devformat.h create mode 100644 core/bufferline.h create mode 100644 core/devformat.cpp create mode 100644 core/devformat.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 59637da0..31ef66a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,6 +627,10 @@ set(OPENAL_OBJS al/state.cpp ) set(ALC_OBJS + core/bufferline.h + core/devformat.cpp + core/devformat.h + alc/alc.cpp alc/alcmain.h alc/alu.cpp @@ -644,7 +648,6 @@ set(ALC_OBJS alc/bsinc_defs.h alc/bsinc_tables.cpp alc/bsinc_tables.h - alc/bufferline.h alc/buffer_storage.cpp alc/buffer_storage.h alc/compat.h @@ -652,7 +655,6 @@ set(ALC_OBJS alc/converter.h alc/cpu_caps.cpp alc/cpu_caps.h - alc/devformat.h alc/effectslot.cpp alc/effectslot.h alc/effects/base.h diff --git a/alc/alc.cpp b/alc/alc.cpp index 623fd688..7cf6c5a9 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -80,8 +80,8 @@ #include "bformatdec.h" #include "bs2b.h" #include "compat.h" +#include "core/devformat.h" #include "cpu_caps.h" -#include "devformat.h" #include "effects/base.h" #include "filters/nfc.h" #include "filters/splitter.h" @@ -1309,66 +1309,6 @@ BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, LPVOID /*reserved*/) /************************************************ * Device format information ************************************************/ -const ALCchar *DevFmtTypeString(DevFmtType type) noexcept -{ - switch(type) - { - case DevFmtByte: return "Int8"; - case DevFmtUByte: return "UInt8"; - case DevFmtShort: return "Int16"; - case DevFmtUShort: return "UInt16"; - case DevFmtInt: return "Int32"; - case DevFmtUInt: return "UInt32"; - case DevFmtFloat: return "Float32"; - } - return "(unknown type)"; -} -const ALCchar *DevFmtChannelsString(DevFmtChannels chans) noexcept -{ - switch(chans) - { - case DevFmtMono: return "Mono"; - case DevFmtStereo: return "Stereo"; - case DevFmtQuad: return "Quadraphonic"; - case DevFmtX51: return "5.1 Surround"; - case DevFmtX51Rear: return "5.1 Surround (Rear)"; - case DevFmtX61: return "6.1 Surround"; - case DevFmtX71: return "7.1 Surround"; - case DevFmtAmbi3D: return "Ambisonic 3D"; - } - return "(unknown channels)"; -} - -uint BytesFromDevFmt(DevFmtType type) noexcept -{ - switch(type) - { - case DevFmtByte: return sizeof(int8_t); - case DevFmtUByte: return sizeof(uint8_t); - case DevFmtShort: return sizeof(int16_t); - case DevFmtUShort: return sizeof(uint16_t); - case DevFmtInt: return sizeof(int32_t); - case DevFmtUInt: return sizeof(uint32_t); - case DevFmtFloat: return sizeof(float); - } - return 0; -} -uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept -{ - switch(chans) - { - case DevFmtMono: return 1; - case DevFmtStereo: return 2; - case DevFmtQuad: return 4; - case DevFmtX51: return 6; - case DevFmtX51Rear: return 6; - case DevFmtX61: return 7; - case DevFmtX71: return 8; - case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1); - } - return 0; -} - namespace { struct DevFmtPair { DevFmtChannels chans; DevFmtType type; }; diff --git a/alc/alcmain.h b/alc/alcmain.h index abeb0201..41906bde 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -23,8 +23,8 @@ #include "alspan.h" #include "ambidefs.h" #include "atomic.h" -#include "bufferline.h" -#include "devformat.h" +#include "core/bufferline.h" +#include "core/devformat.h" #include "filters/splitter.h" #include "hrtf.h" #include "inprogext.h" @@ -366,9 +366,6 @@ struct ALCdevice : public al::intrusive_ref { extern int RTPrioLevel; void SetRTPriority(void); -const ALCchar *DevFmtTypeString(DevFmtType type) noexcept; -const ALCchar *DevFmtChannelsString(DevFmtChannels chans) noexcept; - /** * Returns the index for the given channel name (e.g. FrontCenter), or * INVALID_CHANNEL_INDEX if it doesn't exist. diff --git a/alc/alu.cpp b/alc/alu.cpp index 7e7dabf9..10069fd1 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -59,8 +59,8 @@ #include "atomic.h" #include "bformatdec.h" #include "bs2b.h" +#include "core/devformat.h" #include "cpu_caps.h" -#include "devformat.h" #include "effects/base.h" #include "filters/biquad.h" #include "filters/nfc.h" diff --git a/alc/bformatdec.h b/alc/bformatdec.h index 03249c55..280ca2fc 100644 --- a/alc/bformatdec.h +++ b/alc/bformatdec.h @@ -11,7 +11,7 @@ #include "almalloc.h" #include "alspan.h" #include "ambidefs.h" -#include "devformat.h" +#include "core/devformat.h" #include "filters/splitter.h" struct AmbDecConf; diff --git a/alc/bufferline.h b/alc/bufferline.h deleted file mode 100644 index 79f0996c..00000000 --- a/alc/bufferline.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ALC_BUFFERLINE_H -#define ALC_BUFFERLINE_H - -#include - -/* Size for temporary storage of buffer data, in floats. Larger values need - * more memory, while smaller values may need more iterations. The value needs - * to be a sensible size, however, as it constrains the max stepping value used - * for mixing, as well as the maximum number of samples per mixing iteration. - */ -#define BUFFERSIZE 1024 - -using FloatBufferLine = std::array; - -#endif /* ALC_BUFFERLINE_H */ diff --git a/alc/converter.h b/alc/converter.h index 17da3aae..a97d1ea5 100644 --- a/alc/converter.h +++ b/alc/converter.h @@ -10,7 +10,7 @@ #include "almalloc.h" #include "alnumeric.h" #include "alu.h" -#include "devformat.h" +#include "core/devformat.h" #include "voice.h" diff --git a/alc/devformat.h b/alc/devformat.h deleted file mode 100644 index b02ad025..00000000 --- a/alc/devformat.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef ALC_DEVFORMAT_H -#define ALC_DEVFORMAT_H - -#include - - -using uint = unsigned int; - -enum Channel { - FrontLeft = 0, - FrontRight, - FrontCenter, - LFE, - BackLeft, - BackRight, - BackCenter, - SideLeft, - SideRight, - - TopFrontLeft, - TopFrontCenter, - TopFrontRight, - TopCenter, - TopBackLeft, - TopBackCenter, - TopBackRight, - - MaxChannels -}; - - -/* Device formats */ -enum DevFmtType : unsigned char { - DevFmtByte, - DevFmtUByte, - DevFmtShort, - DevFmtUShort, - DevFmtInt, - DevFmtUInt, - DevFmtFloat, - - DevFmtTypeDefault = DevFmtFloat -}; -enum DevFmtChannels : unsigned char { - DevFmtMono, - DevFmtStereo, - DevFmtQuad, - DevFmtX51, - DevFmtX61, - DevFmtX71, - DevFmtAmbi3D, - - /* Similar to 5.1, except using rear channels instead of sides */ - DevFmtX51Rear, - - DevFmtChannelsDefault = DevFmtStereo -}; -#define MAX_OUTPUT_CHANNELS 16 - -/* DevFmtType traits, providing the type, etc given a DevFmtType. */ -template -struct DevFmtTypeTraits { }; - -template<> -struct DevFmtTypeTraits { using Type = int8_t; }; -template<> -struct DevFmtTypeTraits { using Type = uint8_t; }; -template<> -struct DevFmtTypeTraits { using Type = int16_t; }; -template<> -struct DevFmtTypeTraits { using Type = uint16_t; }; -template<> -struct DevFmtTypeTraits { using Type = int32_t; }; -template<> -struct DevFmtTypeTraits { using Type = uint32_t; }; -template<> -struct DevFmtTypeTraits { using Type = float; }; - - -uint BytesFromDevFmt(DevFmtType type) noexcept; -uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept; -inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept -{ return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); } - -enum class DevAmbiLayout : bool { - FuMa, - ACN, - - Default = ACN -}; - -enum class DevAmbiScaling : unsigned char { - FuMa, - SN3D, - N3D, - - Default = SN3D -}; - -#endif /* ALC_DEVFORMAT_H */ diff --git a/alc/front_stablizer.h b/alc/front_stablizer.h index 5e7c267f..066a70af 100644 --- a/alc/front_stablizer.h +++ b/alc/front_stablizer.h @@ -5,7 +5,7 @@ #include #include "almalloc.h" -#include "bufferline.h" +#include "core/bufferline.h" #include "filters/splitter.h" diff --git a/alc/hrtf.h b/alc/hrtf.h index 64f0e994..9bbe36b7 100644 --- a/alc/hrtf.h +++ b/alc/hrtf.h @@ -10,7 +10,7 @@ #include "alspan.h" #include "ambidefs.h" #include "atomic.h" -#include "bufferline.h" +#include "core/bufferline.h" #include "filters/splitter.h" #include "intrusive_ptr.h" #include "vector.h" diff --git a/alc/panning.cpp b/alc/panning.cpp index adc7db30..86a71a24 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -51,7 +51,7 @@ #include "ambidefs.h" #include "bformatdec.h" #include "bs2b.h" -#include "devformat.h" +#include "core/devformat.h" #include "front_stablizer.h" #include "hrtf.h" #include "logging.h" diff --git a/alc/voice.cpp b/alc/voice.cpp index 4fe84234..174e8545 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -46,8 +46,8 @@ #include "alspan.h" #include "alstring.h" #include "alu.h" +#include "core/devformat.h" #include "cpu_caps.h" -#include "devformat.h" #include "filters/biquad.h" #include "filters/nfc.h" #include "filters/splitter.h" diff --git a/alc/voice.h b/alc/voice.h index 5900d849..5ae7a945 100644 --- a/alc/voice.h +++ b/alc/voice.h @@ -7,7 +7,7 @@ #include "alspan.h" #include "alu.h" #include "buffer_storage.h" -#include "devformat.h" +#include "core/devformat.h" #include "filters/biquad.h" #include "filters/nfc.h" #include "filters/splitter.h" diff --git a/core/bufferline.h b/core/bufferline.h new file mode 100644 index 00000000..07983140 --- /dev/null +++ b/core/bufferline.h @@ -0,0 +1,14 @@ +#ifndef CORE_BUFFERLINE_H +#define CORE_BUFFERLINE_H + +#include + +/* Size for temporary storage of buffer data, in floats. Larger values need + * more memory and are harder on cache, while smaller values may need more + * iterations for mixing. + */ +#define BUFFERSIZE 1024 + +using FloatBufferLine = std::array; + +#endif /* CORE_BUFFERLINE_H */ diff --git a/core/devformat.cpp b/core/devformat.cpp new file mode 100644 index 00000000..d13ef3c6 --- /dev/null +++ b/core/devformat.cpp @@ -0,0 +1,65 @@ + +#include "config.h" + +#include "devformat.h" + + +uint BytesFromDevFmt(DevFmtType type) noexcept +{ + switch(type) + { + case DevFmtByte: return sizeof(int8_t); + case DevFmtUByte: return sizeof(uint8_t); + case DevFmtShort: return sizeof(int16_t); + case DevFmtUShort: return sizeof(uint16_t); + case DevFmtInt: return sizeof(int32_t); + case DevFmtUInt: return sizeof(uint32_t); + case DevFmtFloat: return sizeof(float); + } + return 0; +} +uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept +{ + switch(chans) + { + case DevFmtMono: return 1; + case DevFmtStereo: return 2; + case DevFmtQuad: return 4; + case DevFmtX51: return 6; + case DevFmtX51Rear: return 6; + case DevFmtX61: return 7; + case DevFmtX71: return 8; + case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1); + } + return 0; +} + +const char *DevFmtTypeString(DevFmtType type) noexcept +{ + switch(type) + { + case DevFmtByte: return "Int8"; + case DevFmtUByte: return "UInt8"; + case DevFmtShort: return "Int16"; + case DevFmtUShort: return "UInt16"; + case DevFmtInt: return "Int32"; + case DevFmtUInt: return "UInt32"; + case DevFmtFloat: return "Float32"; + } + return "(unknown type)"; +} +const char *DevFmtChannelsString(DevFmtChannels chans) noexcept +{ + switch(chans) + { + case DevFmtMono: return "Mono"; + case DevFmtStereo: return "Stereo"; + case DevFmtQuad: return "Quadraphonic"; + case DevFmtX51: return "5.1 Surround"; + case DevFmtX51Rear: return "5.1 Surround (Rear)"; + case DevFmtX61: return "6.1 Surround"; + case DevFmtX71: return "7.1 Surround"; + case DevFmtAmbi3D: return "Ambisonic 3D"; + } + return "(unknown channels)"; +} diff --git a/core/devformat.h b/core/devformat.h new file mode 100644 index 00000000..bcd42539 --- /dev/null +++ b/core/devformat.h @@ -0,0 +1,103 @@ +#ifndef CORE_DEVFORMAT_H +#define CORE_DEVFORMAT_H + +#include + + +using uint = unsigned int; + +enum Channel { + FrontLeft = 0, + FrontRight, + FrontCenter, + LFE, + BackLeft, + BackRight, + BackCenter, + SideLeft, + SideRight, + + TopFrontLeft, + TopFrontCenter, + TopFrontRight, + TopCenter, + TopBackLeft, + TopBackCenter, + TopBackRight, + + MaxChannels +}; + + +/* Device formats */ +enum DevFmtType : unsigned char { + DevFmtByte, + DevFmtUByte, + DevFmtShort, + DevFmtUShort, + DevFmtInt, + DevFmtUInt, + DevFmtFloat, + + DevFmtTypeDefault = DevFmtFloat +}; +enum DevFmtChannels : unsigned char { + DevFmtMono, + DevFmtStereo, + DevFmtQuad, + DevFmtX51, + DevFmtX61, + DevFmtX71, + DevFmtAmbi3D, + + /* Similar to 5.1, except using rear channels instead of sides */ + DevFmtX51Rear, + + DevFmtChannelsDefault = DevFmtStereo +}; +#define MAX_OUTPUT_CHANNELS 16 + +/* DevFmtType traits, providing the type, etc given a DevFmtType. */ +template +struct DevFmtTypeTraits { }; + +template<> +struct DevFmtTypeTraits { using Type = int8_t; }; +template<> +struct DevFmtTypeTraits { using Type = uint8_t; }; +template<> +struct DevFmtTypeTraits { using Type = int16_t; }; +template<> +struct DevFmtTypeTraits { using Type = uint16_t; }; +template<> +struct DevFmtTypeTraits { using Type = int32_t; }; +template<> +struct DevFmtTypeTraits { using Type = uint32_t; }; +template<> +struct DevFmtTypeTraits { using Type = float; }; + + +uint BytesFromDevFmt(DevFmtType type) noexcept; +uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept; +inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept +{ return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); } + +const char *DevFmtTypeString(DevFmtType type) noexcept; +const char *DevFmtChannelsString(DevFmtChannels chans) noexcept; + +enum class DevAmbiLayout : bool { + FuMa, + ACN, + + Default = ACN +}; + +enum class DevAmbiScaling : unsigned char { + FuMa, + SN3D, + N3D, + + Default = SN3D +}; + +#endif /* CORE_DEVFORMAT_H */ -- cgit v1.2.3