diff options
-rw-r--r-- | alc/alc.cpp | 64 | ||||
-rw-r--r-- | alc/alcmain.h | 12 | ||||
-rw-r--r-- | alc/alu.cpp | 8 | ||||
-rw-r--r-- | alc/panning.cpp | 22 |
4 files changed, 53 insertions, 53 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 7841df28..a40a4d7d 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1653,7 +1653,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) ALCsizei hrtf_id{-1}; ALCuint oldFreq; - if((!attrList || !attrList[0]) && device->Type == Loopback) + if((!attrList || !attrList[0]) && device->Type == DeviceType::Loopback) { WARN("Missing attributes for loopback device\n"); return ALC_INVALID_VALUE; @@ -1758,7 +1758,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) } #undef TRACE_ATTR - const bool loopback{device->Type == Loopback}; + const bool loopback{device->Type == DeviceType::Loopback}; if(loopback) { if(!schans || !stype || !freq) @@ -1895,7 +1895,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) * Update device format request if HRTF is requested */ device->HrtfStatus = ALC_HRTF_DISABLED_SOFT; - if(device->Type != Loopback) + if(device->Type != DeviceType::Loopback) { if(auto hrtfopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf")) { @@ -2437,7 +2437,7 @@ ALCcontext::~ALCcontext() void ALCcontext::init() { - if(DefaultEffect.type != AL_EFFECT_NULL && mDevice->Type == Playback) + if(DefaultEffect.type != AL_EFFECT_NULL && mDevice->Type == DeviceType::Playback) { mDefaultSlot = std::unique_ptr<ALeffectslot>{new ALeffectslot{}}; if(mDefaultSlot->init() == AL_NO_ERROR) @@ -2722,8 +2722,8 @@ END_API_FUNC static inline ALCsizei NumAttrsForDevice(ALCdevice *device) { - if(device->Type == Capture) return 9; - if(device->Type != Loopback) return 29; + if(device->Type == DeviceType::Capture) return 9; + if(device->Type != DeviceType::Loopback) return 29; if(device->FmtChans == DevFmtAmbi3D) return 35; return 29; @@ -2773,7 +2773,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 0; } - if(device->Type == Capture) + if(device->Type == DeviceType::Capture) { switch(param) { @@ -2852,7 +2852,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> values[i++] = ALC_FREQUENCY; values[i++] = static_cast<int>(device->Frequency); - if(device->Type != Loopback) + if(device->Type != DeviceType::Loopback) { values[i++] = ALC_REFRESH; values[i++] = static_cast<int>(device->Frequency / device->UpdateSize); @@ -2927,7 +2927,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 1; case ALC_REFRESH: - if(device->Type == Loopback) + if(device->Type == DeviceType::Loopback) { alcSetError(device, ALC_INVALID_DEVICE); return 0; @@ -2939,7 +2939,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 1; case ALC_SYNC: - if(device->Type == Loopback) + if(device->Type == DeviceType::Loopback) { alcSetError(device, ALC_INVALID_DEVICE); return 0; @@ -2948,7 +2948,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 1; case ALC_FORMAT_CHANNELS_SOFT: - if(device->Type != Loopback) + if(device->Type != DeviceType::Loopback) { alcSetError(device, ALC_INVALID_DEVICE); return 0; @@ -2957,7 +2957,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 1; case ALC_FORMAT_TYPE_SOFT: - if(device->Type != Loopback) + if(device->Type != DeviceType::Loopback) { alcSetError(device, ALC_INVALID_DEVICE); return 0; @@ -2966,7 +2966,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 1; case ALC_AMBISONIC_LAYOUT_SOFT: - if(device->Type != Loopback || device->FmtChans != DevFmtAmbi3D) + if(device->Type != DeviceType::Loopback || device->FmtChans != DevFmtAmbi3D) { alcSetError(device, ALC_INVALID_DEVICE); return 0; @@ -2975,7 +2975,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 1; case ALC_AMBISONIC_SCALING_SOFT: - if(device->Type != Loopback || device->FmtChans != DevFmtAmbi3D) + if(device->Type != DeviceType::Loopback || device->FmtChans != DevFmtAmbi3D) { alcSetError(device, ALC_INVALID_DEVICE); return 0; @@ -2984,7 +2984,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int> return 1; case ALC_AMBISONIC_ORDER_SOFT: - if(device->Type != Loopback || device->FmtChans != DevFmtAmbi3D) + if(device->Type != DeviceType::Loopback || device->FmtChans != DevFmtAmbi3D) { alcSetError(device, ALC_INVALID_DEVICE); return 0; @@ -3062,7 +3062,7 @@ START_API_FUNC alcSetError(dev.get(), ALC_INVALID_VALUE); return; } - if(!dev || dev->Type == Capture) + if(!dev || dev->Type == DeviceType::Capture) { auto ivals = al::vector<int>(static_cast<ALuint>(size)); size_t got{GetIntegerv(dev.get(), pname, ivals)}; @@ -3086,7 +3086,7 @@ START_API_FUNC values[i++] = ALC_FREQUENCY; values[i++] = dev->Frequency; - if(dev->Type != Loopback) + if(dev->Type != DeviceType::Loopback) { values[i++] = ALC_REFRESH; values[i++] = dev->Frequency / dev->UpdateSize; @@ -3268,7 +3268,7 @@ START_API_FUNC */ std::unique_lock<std::recursive_mutex> listlock{ListLock}; DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type == Capture || !dev->Connected.load(std::memory_order_relaxed)) + if(!dev || dev->Type == DeviceType::Capture || !dev->Connected.load(std::memory_order_relaxed)) { listlock.unlock(); alcSetError(dev.get(), ALC_INVALID_DEVICE); @@ -3493,7 +3493,7 @@ START_API_FUNC deviceName = nullptr; } - DeviceRef device{new ALCdevice{Playback}}; + DeviceRef device{new ALCdevice{DeviceType::Playback}}; /* Set output format */ device->FmtChans = DevFmtChannelsDefault; @@ -3671,7 +3671,7 @@ START_API_FUNC alcSetError(nullptr, ALC_INVALID_DEVICE); return ALC_FALSE; } - if((*iter)->Type == Capture) + if((*iter)->Type == DeviceType::Capture) { alcSetError(*iter, ALC_INVALID_DEVICE); return ALC_FALSE; @@ -3739,7 +3739,7 @@ START_API_FUNC deviceName = nullptr; } - DeviceRef device{new ALCdevice{Capture}}; + DeviceRef device{new ALCdevice{DeviceType::Capture}}; auto decompfmt = DecomposeDevFormat(format); if(!decompfmt) @@ -3794,7 +3794,7 @@ START_API_FUNC alcSetError(nullptr, ALC_INVALID_DEVICE); return ALC_FALSE; } - if((*iter)->Type != Capture) + if((*iter)->Type != DeviceType::Capture) { alcSetError(*iter, ALC_INVALID_DEVICE); return ALC_FALSE; @@ -3817,7 +3817,7 @@ ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device) START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type != Capture) + if(!dev || dev->Type != DeviceType::Capture) { alcSetError(dev.get(), ALC_INVALID_DEVICE); return; @@ -3845,7 +3845,7 @@ ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device) START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type != Capture) + if(!dev || dev->Type != DeviceType::Capture) alcSetError(dev.get(), ALC_INVALID_DEVICE); else { @@ -3861,7 +3861,7 @@ ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type != Capture) + if(!dev || dev->Type != DeviceType::Capture) { alcSetError(dev.get(), ALC_INVALID_DEVICE); return; @@ -3909,7 +3909,7 @@ START_API_FUNC return nullptr; } - DeviceRef device{new ALCdevice{Loopback}}; + DeviceRef device{new ALCdevice{DeviceType::Loopback}}; device->SourcesMax = 256; device->AuxiliaryEffectSlotMax = 64; @@ -3966,7 +3966,7 @@ ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type != Loopback) + if(!dev || dev->Type != DeviceType::Loopback) alcSetError(dev.get(), ALC_INVALID_DEVICE); else if(freq <= 0) alcSetError(dev.get(), ALC_INVALID_VALUE); @@ -3989,7 +3989,7 @@ FORCE_ALIGN ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, AL START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type != Loopback) + if(!dev || dev->Type != DeviceType::Loopback) alcSetError(dev.get(), ALC_INVALID_DEVICE); else if(samples < 0 || (samples > 0 && buffer == nullptr)) alcSetError(dev.get(), ALC_INVALID_VALUE); @@ -4008,7 +4008,7 @@ ALC_API void ALC_APIENTRY alcDevicePauseSOFT(ALCdevice *device) START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type != Playback) + if(!dev || dev->Type != DeviceType::Playback) alcSetError(dev.get(), ALC_INVALID_DEVICE); else { @@ -4026,7 +4026,7 @@ ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device) START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type != Playback) + if(!dev || dev->Type != DeviceType::Playback) { alcSetError(dev.get(), ALC_INVALID_DEVICE); return; @@ -4061,7 +4061,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum START_API_FUNC { DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type == Capture) + if(!dev || dev->Type == DeviceType::Capture) alcSetError(dev.get(), ALC_INVALID_DEVICE); else switch(paramName) { @@ -4086,7 +4086,7 @@ START_API_FUNC { std::unique_lock<std::recursive_mutex> listlock{ListLock}; DeviceRef dev{VerifyDevice(device)}; - if(!dev || dev->Type == Capture) + if(!dev || dev->Type == DeviceType::Capture) { listlock.unlock(); alcSetError(dev.get(), ALC_INVALID_DEVICE); diff --git a/alc/alcmain.h b/alc/alcmain.h index b53e5f8d..a641f4c8 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -50,17 +50,17 @@ struct bs2b; #define DEFAULT_NUM_UPDATES 3 -enum DeviceType { +enum class DeviceType { Playback, Capture, Loopback }; -enum RenderMode { - NormalRender, - StereoPair, - HrtfRender +enum class RenderMode { + Normal, + Pairwise, + Hrtf }; @@ -248,7 +248,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> { al::vector<FilterSubList> FilterList; /* Rendering mode. */ - RenderMode mRenderMode{NormalRender}; + RenderMode mRenderMode{RenderMode::Normal}; /* The average speaker distance as determined by the ambdec configuration, * HRTF data set, or the NFC-HOA reference delay. Only used for NFC. diff --git a/alc/alu.cpp b/alc/alu.cpp index d8368d04..978f6d62 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -876,7 +876,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con auto calc_coeffs = [xpos,ypos,zpos](RenderMode mode) { - if(mode != StereoPair) + if(mode != RenderMode::Pairwise) return CalcDirectionCoeffs({xpos, ypos, zpos}, 0.0f); /* Clamp Y, in case rounding errors caused it to end up outside @@ -1015,7 +1015,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con } } } - else if(Device->mRenderMode == HrtfRender) + else if(Device->mRenderMode == RenderMode::Hrtf) { /* Full HRTF rendering. Skip the virtual channels and render to the * real outputs. @@ -1123,7 +1123,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con */ auto calc_coeffs = [xpos,ypos,zpos,Spread](RenderMode mode) { - if(mode != StereoPair) + if(mode != RenderMode::Pairwise) return CalcDirectionCoeffs({xpos, ypos, zpos}, Spread); const float ev{std::asin(clampf(ypos, -1.0f, 1.0f))}; const float az{std::atan2(xpos, -zpos)}; @@ -1183,7 +1183,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con continue; } - const auto coeffs = CalcAngleCoeffs((Device->mRenderMode == StereoPair) + const auto coeffs = CalcAngleCoeffs((Device->mRenderMode == RenderMode::Pairwise) ? ScaleAzimuthFront(chans[c].angle, 3.0f) : chans[c].angle, chans[c].elevation, Spread); diff --git a/alc/panning.cpp b/alc/panning.cpp index 9df866d4..964d56e8 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -758,7 +758,7 @@ void InitHrtfPanning(ALCdevice *device) /* Don't bother with HOA when using full HRTF rendering. Nothing needs it, * and it eases the CPU/memory load. */ - device->mRenderMode = HrtfRender; + device->mRenderMode = RenderMode::Hrtf; ALuint ambi_order{1}; if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf-mode")) { @@ -768,9 +768,9 @@ void InitHrtfPanning(ALCdevice *device) ALuint order; }; static const HrtfModeEntry hrtf_modes[]{ - { "full", HrtfRender, 1 }, - { "ambi1", NormalRender, 1 }, - { "ambi2", NormalRender, 2 }, + { "full", RenderMode::Hrtf, 1 }, + { "ambi1", RenderMode::Normal, 1 }, + { "ambi2", RenderMode::Normal, 2 }, }; const char *mode{modeopt->c_str()}; @@ -796,7 +796,7 @@ void InitHrtfPanning(ALCdevice *device) ((ambi_order%10) == 1) ? "st" : ((ambi_order%10) == 2) ? "nd" : ((ambi_order%10) == 3) ? "rd" : "th", - (device->mRenderMode == HrtfRender) ? "+ Full " : "", + (device->mRenderMode == RenderMode::Hrtf) ? "+ Full " : "", device->HrtfName.c_str()); al::span<const AngularPoint> AmbiPoints{AmbiPoints1O}; @@ -851,7 +851,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, HrtfRequestMode hrtf_appreq device->mHrtfState = nullptr; device->mHrtf = nullptr; device->HrtfName.clear(); - device->mRenderMode = NormalRender; + device->mRenderMode = RenderMode::Normal; if(device->FmtChans != DevFmtStereo) { @@ -916,7 +916,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, HrtfRequestMode hrtf_appreq } bool headphones{device->IsHeadphones}; - if(device->Type != Loopback) + if(device->Type != DeviceType::Loopback) { if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "stereo-mode")) { @@ -992,9 +992,9 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, HrtfRequestMode hrtf_appreq no_hrtf: old_hrtf = nullptr; - device->mRenderMode = StereoPair; + device->mRenderMode = RenderMode::Pairwise; - if(device->Type != Loopback) + if(device->Type != DeviceType::Loopback) { if(auto cflevopt = ConfigValueInt(device->DeviceName.c_str(), nullptr, "cf_level")) { @@ -1015,11 +1015,11 @@ no_hrtf: { const char *mode{encopt->c_str()}; if(al::strcasecmp(mode, "uhj") == 0) - device->mRenderMode = NormalRender; + device->mRenderMode = RenderMode::Normal; else if(al::strcasecmp(mode, "panpot") != 0) ERR("Unexpected stereo-encoding: %s\n", mode); } - if(device->mRenderMode == NormalRender) + if(device->mRenderMode == RenderMode::Normal) { device->Uhj_Encoder = std::make_unique<Uhj2Encoder>(); TRACE("UHJ enabled\n"); |