From 16d0e79db7a5e99a9859cfaacb718dfae862cb2a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 20 Nov 2018 02:42:49 -0800 Subject: [PATCH] Add compile-time traits for FmtType enum values --- OpenAL32/Include/alBuffer.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/OpenAL32/Include/alBuffer.h b/OpenAL32/Include/alBuffer.h index f264caa5..a99c06fc 100644 --- a/OpenAL32/Include/alBuffer.h +++ b/OpenAL32/Include/alBuffer.h @@ -8,9 +8,6 @@ #include "inprogext.h" #include "atomic.h" -#ifdef __cplusplus -extern "C" { -#endif /* User formats */ enum UserFmtType { @@ -65,6 +62,24 @@ enum FmtChannels { }; #define MAX_INPUT_CHANNELS (8) +/* DevFmtType traits, providing the type, etc given a DevFmtType. */ +template +struct FmtTypeTraits { }; + +template<> +struct FmtTypeTraits { using Type = ALubyte; }; +template<> +struct FmtTypeTraits { using Type = ALshort; }; +template<> +struct FmtTypeTraits { using Type = ALfloat; }; +template<> +struct FmtTypeTraits { using Type = ALdouble; }; +template<> +struct FmtTypeTraits { using Type = ALubyte; }; +template<> +struct FmtTypeTraits { using Type = ALubyte; }; + + ALsizei BytesFromFmt(enum FmtType type); ALsizei ChannelsFromFmt(enum FmtChannels chans); inline ALsizei FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type) @@ -107,8 +122,4 @@ typedef struct ALbuffer { ALvoid ReleaseALBuffers(ALCdevice *device); -#ifdef __cplusplus -} -#endif - #endif -- 2.11.4.GIT