diff options
author | Chris Robinson <[email protected]> | 2019-12-09 20:45:11 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-12-09 20:45:11 -0800 |
commit | a1de05fed7eeb5859ecf95605260cc4e3e10befd (patch) | |
tree | 0edb83e53903808b3c6f9b18d73a7409a6a81777 | |
parent | e43c2bba61e2bb78d3d4bb7cbbb510c3e363dfcd (diff) |
Avoid global macros for format-secific types
-rw-r--r-- | alc/hrtf.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index 702355bd..b39ef9ee 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -826,14 +826,13 @@ std::unique_ptr<HrtfStore> LoadHrtf01(std::istream &data, const char *filename) &reinterpret_cast<ALubyte(&)[2]>(delays[0]), filename); } -#define SAMPLETYPE_S16 0 -#define SAMPLETYPE_S24 1 - -#define CHANTYPE_LEFTONLY 0 -#define CHANTYPE_LEFTRIGHT 1 - std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) { + constexpr ALubyte SampleType_S16{0}; + constexpr ALubyte SampleType_S24{1}; + constexpr ALubyte ChanType_LeftOnly{0}; + constexpr ALubyte ChanType_LeftRight{1}; + ALuint rate{GetLE_ALuint(data)}; ALubyte sampleType{GetLE_ALubyte(data)}; ALubyte channelType{GetLE_ALubyte(data)}; @@ -846,12 +845,12 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) } ALboolean failed{AL_FALSE}; - if(sampleType > SAMPLETYPE_S24) + if(sampleType > SampleType_S24) { ERR("Unsupported sample type: %d\n", sampleType); failed = AL_TRUE; } - if(channelType > CHANTYPE_LEFTRIGHT) + if(channelType > ChanType_LeftRight) { ERR("Unsupported channel type: %d\n", channelType); failed = AL_TRUE; @@ -936,14 +935,14 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) auto coeffs = al::vector<std::array<ALfloat,2>>(irSize*irTotal); auto delays = al::vector<std::array<ALubyte,2>>(irTotal); - if(channelType == CHANTYPE_LEFTONLY) + if(channelType == ChanType_LeftOnly) { - if(sampleType == SAMPLETYPE_S16) + if(sampleType == SampleType_S16) { for(auto &val : coeffs) val[0] = GetLE_ALshort(data) / 32768.0f; } - else if(sampleType == SAMPLETYPE_S24) + else if(sampleType == SampleType_S24) { for(auto &val : coeffs) val[0] = static_cast<float>(GetLE_ALint24(data)) / 8388608.0f; @@ -965,9 +964,9 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) delays[i][0] <<= HRIR_DELAY_FRACBITS; } } - else if(channelType == CHANTYPE_LEFTRIGHT) + else if(channelType == ChanType_LeftRight) { - if(sampleType == SAMPLETYPE_S16) + if(sampleType == SampleType_S16) { for(auto &val : coeffs) { @@ -975,7 +974,7 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) val[1] = GetLE_ALshort(data) / 32768.0f; } } - else if(sampleType == SAMPLETYPE_S24) + else if(sampleType == SampleType_S24) { for(auto &val : coeffs) { @@ -1013,7 +1012,7 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) if(failed) return nullptr; - if(channelType == CHANTYPE_LEFTONLY) + if(channelType == ChanType_LeftOnly) { /* Mirror the left ear responses to the right ear. */ size_t ebase{0}; |