diff options
author | Chris Robinson <[email protected]> | 2021-01-22 00:00:10 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-01-22 00:00:10 -0800 |
commit | 5ff5fd8eccbdc5888b350059cb1f341a33ddf05f (patch) | |
tree | 3ffac7ebb7c57e050a1decae43a40a834b48cb57 /alc/alc.cpp | |
parent | 5729e1004da8dd8760fe3fa217faec4d3cd80427 (diff) |
Use a standard bitset for bitfield flags
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r-- | alc/alc.cpp | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 2b9eb2df..e7c85525 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1804,9 +1804,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) /* If a context is already running on the device, stop playback so the * device attributes can be updated. */ - if(device->Flags.get<DeviceRunning>()) + if(device->Flags.test(DeviceRunning)) device->Backend->stop(); - device->Flags.unset<DeviceRunning>(); + device->Flags.reset(DeviceRunning); UpdateClockBase(device); @@ -1833,7 +1833,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) freq = ConfigValueUInt(devname, nullptr, "frequency").value_or(freq); if(freq < 1) - device->Flags.unset<FrequencyRequest>(); + device->Flags.reset(FrequencyRequest); else { freq = clampu(freq, MIN_OUTPUT_RATE, MAX_OUTPUT_RATE); @@ -1843,7 +1843,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) device->BufferSize = static_cast<uint>(device->BufferSize*scale + 0.5); device->Frequency = freq; - device->Flags.set<FrequencyRequest>(); + device->Flags.set(FrequencyRequest); } if(auto persizeopt = ConfigValueUInt(devname, nullptr, "period_size")) @@ -1878,7 +1878,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) new_sends = numSends; } - if(device->Flags.get<DeviceRunning>()) + if(device->Flags.test(DeviceRunning)) return ALC_NO_ERROR; device->AvgSpeakerDist = 0.0f; @@ -1927,7 +1927,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) if(hrtf_userreq == Hrtf_Enable || (hrtf_userreq != Hrtf_Disable && hrtf_appreq == Hrtf_Enable)) { device->FmtChans = DevFmtStereo; - device->Flags.set<ChannelsRequest>(); + device->Flags.set(ChannelsRequest); } } @@ -1936,9 +1936,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) oldType = device->FmtType; TRACE("Pre-reset: %s%s, %s%s, %s%uhz, %u / %u buffer\n", - device->Flags.get<ChannelsRequest>()?"*":"", DevFmtChannelsString(device->FmtChans), - device->Flags.get<SampleTypeRequest>()?"*":"", DevFmtTypeString(device->FmtType), - device->Flags.get<FrequencyRequest>()?"*":"", device->Frequency, + device->Flags.test(ChannelsRequest)?"*":"", DevFmtChannelsString(device->FmtChans), + device->Flags.test(SampleTypeRequest)?"*":"", DevFmtTypeString(device->FmtType), + device->Flags.test(FrequencyRequest)?"*":"", device->Frequency, device->UpdateSize, device->BufferSize); try { @@ -1951,22 +1951,22 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) return ALC_INVALID_DEVICE; } - if(device->FmtChans != oldChans && device->Flags.get<ChannelsRequest>()) + if(device->FmtChans != oldChans && device->Flags.test(ChannelsRequest)) { ERR("Failed to set %s, got %s instead\n", DevFmtChannelsString(oldChans), DevFmtChannelsString(device->FmtChans)); - device->Flags.unset<ChannelsRequest>(); + device->Flags.reset(ChannelsRequest); } - if(device->FmtType != oldType && device->Flags.get<SampleTypeRequest>()) + if(device->FmtType != oldType && device->Flags.test(SampleTypeRequest)) { ERR("Failed to set %s, got %s instead\n", DevFmtTypeString(oldType), DevFmtTypeString(device->FmtType)); - device->Flags.unset<SampleTypeRequest>(); + device->Flags.reset(SampleTypeRequest); } - if(device->Frequency != oldFreq && device->Flags.get<FrequencyRequest>()) + if(device->Frequency != oldFreq && device->Flags.test(FrequencyRequest)) { WARN("Failed to set %uhz, got %uhz instead\n", oldFreq, device->Frequency); - device->Flags.unset<FrequencyRequest>(); + device->Flags.reset(FrequencyRequest); } TRACE("Post-reset: %s, %s, %uhz, %u / %u buffer\n", @@ -2263,12 +2263,12 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) } mixer_mode.leave(); - if(!device->Flags.get<DevicePaused>()) + if(!device->Flags.test(DevicePaused)) { try { auto backend = device->Backend.get(); backend->start(); - device->Flags.set<DeviceRunning>(); + device->Flags.set(DeviceRunning); } catch(al::backend_exception& e) { device->handleDisconnect("%s", e.what()); @@ -3367,10 +3367,10 @@ START_API_FUNC ALCdevice *Device{ctx->mDevice.get()}; std::lock_guard<std::mutex> _{Device->StateLock}; - if(!ctx->deinit() && Device->Flags.get<DeviceRunning>()) + if(!ctx->deinit() && Device->Flags.test(DeviceRunning)) { Device->Backend->stop(); - Device->Flags.unset<DeviceRunning>(); + Device->Flags.reset(DeviceRunning); } } END_API_FUNC @@ -3545,7 +3545,7 @@ START_API_FUNC { device->FmtChans = iter->chans; device->mAmbiOrder = iter->order; - device->Flags.set<ChannelsRequest>(); + device->Flags.set(ChannelsRequest); } } if(auto typeopt = ConfigValueStr(deviceName, nullptr, "sample-type")) @@ -3573,7 +3573,7 @@ START_API_FUNC else { device->FmtType = iter->type; - device->Flags.set<SampleTypeRequest>(); + device->Flags.set(SampleTypeRequest); } } @@ -3589,7 +3589,7 @@ START_API_FUNC device->UpdateSize = static_cast<uint>(device->UpdateSize*scale + 0.5); device->BufferSize = static_cast<uint>(device->BufferSize*scale + 0.5); device->Frequency = freq; - device->Flags.set<FrequencyRequest>(); + device->Flags.set(FrequencyRequest); } if(auto persizeopt = ConfigValueUInt(deviceName, nullptr, "period_size")) @@ -3698,9 +3698,9 @@ START_API_FUNC } orphanctxs.clear(); - if(dev->Flags.get<DeviceRunning>()) + if(dev->Flags.test(DeviceRunning)) dev->Backend->stop(); - dev->Flags.unset<DeviceRunning>(); + dev->Flags.reset(DeviceRunning); return ALC_TRUE; } @@ -3746,7 +3746,9 @@ START_API_FUNC device->Frequency = frequency; device->FmtChans = decompfmt->chans; device->FmtType = decompfmt->type; - device->Flags.set<FrequencyRequest, ChannelsRequest, SampleTypeRequest>(); + device->Flags.set(FrequencyRequest); + device->Flags.set(ChannelsRequest); + device->Flags.set(SampleTypeRequest); device->UpdateSize = static_cast<uint>(samples); device->BufferSize = static_cast<uint>(samples); @@ -3800,9 +3802,9 @@ START_API_FUNC listlock.unlock(); std::lock_guard<std::mutex> _{dev->StateLock}; - if(dev->Flags.get<DeviceRunning>()) + if(dev->Flags.test(DeviceRunning)) dev->Backend->stop(); - dev->Flags.unset<DeviceRunning>(); + dev->Flags.reset(DeviceRunning); return ALC_TRUE; } @@ -3821,12 +3823,12 @@ START_API_FUNC std::lock_guard<std::mutex> _{dev->StateLock}; if(!dev->Connected.load(std::memory_order_acquire)) alcSetError(dev.get(), ALC_INVALID_DEVICE); - else if(!dev->Flags.get<DeviceRunning>()) + else if(!dev->Flags.test(DeviceRunning)) { try { auto backend = dev->Backend.get(); backend->start(); - dev->Flags.set<DeviceRunning>(); + dev->Flags.set(DeviceRunning); } catch(al::backend_exception& e) { dev->handleDisconnect("%s", e.what()); @@ -3845,9 +3847,9 @@ START_API_FUNC else { std::lock_guard<std::mutex> _{dev->StateLock}; - if(dev->Flags.get<DeviceRunning>()) + if(dev->Flags.test(DeviceRunning)) dev->Backend->stop(); - dev->Flags.unset<DeviceRunning>(); + dev->Flags.reset(DeviceRunning); } } END_API_FUNC @@ -4007,10 +4009,10 @@ START_API_FUNC else { std::lock_guard<std::mutex> _{dev->StateLock}; - if(dev->Flags.get<DeviceRunning>()) + if(dev->Flags.test(DeviceRunning)) dev->Backend->stop(); - dev->Flags.unset<DeviceRunning>(); - dev->Flags.set<DevicePaused>(); + dev->Flags.reset(DeviceRunning); + dev->Flags.set(DevicePaused); } } END_API_FUNC @@ -4027,16 +4029,16 @@ START_API_FUNC } std::lock_guard<std::mutex> _{dev->StateLock}; - if(!dev->Flags.get<DevicePaused>()) + if(!dev->Flags.test(DevicePaused)) return; - dev->Flags.unset<DevicePaused>(); + dev->Flags.reset(DevicePaused); if(dev->mContexts.load()->empty()) return; try { auto backend = dev->Backend.get(); backend->start(); - dev->Flags.set<DeviceRunning>(); + dev->Flags.set(DeviceRunning); } catch(al::backend_exception& e) { dev->handleDisconnect("%s", e.what()); @@ -4092,9 +4094,9 @@ START_API_FUNC /* Force the backend to stop mixing first since we're resetting. Also reset * the connected state so lost devices can attempt recover. */ - if(dev->Flags.get<DeviceRunning>()) + if(dev->Flags.test(DeviceRunning)) dev->Backend->stop(); - dev->Flags.unset<DeviceRunning>(); + dev->Flags.reset(DeviceRunning); if(!dev->Connected.load(std::memory_order_relaxed)) { /* Make sure disconnection is finished before continuing on. */ |