aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/alc.cpp')
-rw-r--r--Alc/alc.cpp84
1 files changed, 41 insertions, 43 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index aeac5354..dfd4ef23 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -1617,9 +1617,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
/* If a context is already running on the device, stop playback so
* the device attributes can be updated.
*/
- if((device->Flags&DEVICE_RUNNING))
+ if(device->Flags.get(DeviceRunning))
device->Backend->stop();
- device->Flags &= ~DEVICE_RUNNING;
+ device->Flags.unset(DeviceRunning);
}
auto numMono = static_cast<ALsizei>(device->NumMonoSources);
@@ -1734,9 +1734,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
}
}
- if((device->Flags&DEVICE_RUNNING))
+ if(device->Flags.get(DeviceRunning))
device->Backend->stop();
- device->Flags &= ~DEVICE_RUNNING;
+ device->Flags.unset(DeviceRunning);
UpdateClockBase(device);
@@ -1748,7 +1748,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
ConfigValueUInt(devname, nullptr, "frequency", &freq);
if(freq < 1)
- device->Flags &= ~DEVICE_FREQUENCY_REQUEST;
+ device->Flags.unset(FrequencyRequest);
else
{
freq = maxi(freq, MIN_OUTPUT_RATE);
@@ -1759,7 +1759,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->Frequency;
device->Frequency = freq;
- device->Flags |= DEVICE_FREQUENCY_REQUEST;
+ device->Flags.set(FrequencyRequest);
}
ConfigValueUInt(devname, nullptr, "period_size", &device->UpdateSize);
@@ -1807,7 +1807,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
new_sends = numSends;
}
- if((device->Flags&DEVICE_RUNNING))
+ if(device->Flags.get(DeviceRunning))
return ALC_NO_ERROR;
device->Uhj_Encoder = nullptr;
@@ -1862,7 +1862,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{
device->FmtChans = DevFmtStereo;
device->Frequency = hrtf->sampleRate;
- device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST;
+ device->Flags.set(ChannelsRequest, FrequencyRequest);
if(HrtfEntry *oldhrtf{device->mHrtf})
oldhrtf->DecRef();
device->mHrtf = hrtf;
@@ -1881,9 +1881,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
oldType = device->FmtType;
TRACE("Pre-reset: %s%s, %s%s, %s%uhz, %u / %u buffer\n",
- (device->Flags&DEVICE_CHANNELS_REQUEST)?"*":"", DevFmtChannelsString(device->FmtChans),
- (device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)?"*":"", DevFmtTypeString(device->FmtType),
- (device->Flags&DEVICE_FREQUENCY_REQUEST)?"*":"", device->Frequency,
+ device->Flags.get(ChannelsRequest)?"*":"", DevFmtChannelsString(device->FmtChans),
+ device->Flags.get(SampleTypeRequest)?"*":"", DevFmtTypeString(device->FmtType),
+ device->Flags.get(FrequencyRequest)?"*":"", device->Frequency,
device->UpdateSize, device->BufferSize);
try {
@@ -1895,22 +1895,22 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
return ALC_INVALID_DEVICE;
}
- if(device->FmtChans != oldChans && (device->Flags&DEVICE_CHANNELS_REQUEST))
+ if(device->FmtChans != oldChans && device->Flags.get(ChannelsRequest))
{
ERR("Failed to set %s, got %s instead\n", DevFmtChannelsString(oldChans),
DevFmtChannelsString(device->FmtChans));
- device->Flags &= ~DEVICE_CHANNELS_REQUEST;
+ device->Flags.unset(ChannelsRequest);
}
- if(device->FmtType != oldType && (device->Flags&DEVICE_SAMPLE_TYPE_REQUEST))
+ if(device->FmtType != oldType && device->Flags.get(SampleTypeRequest))
{
ERR("Failed to set %s, got %s instead\n", DevFmtTypeString(oldType),
DevFmtTypeString(device->FmtType));
- device->Flags &= ~DEVICE_SAMPLE_TYPE_REQUEST;
+ device->Flags.unset(SampleTypeRequest);
}
- if(device->Frequency != oldFreq && (device->Flags&DEVICE_FREQUENCY_REQUEST))
+ if(device->Frequency != oldFreq && device->Flags.get(FrequencyRequest))
{
ERR("Failed to set %uhz, got %uhz instead\n", oldFreq, device->Frequency);
- device->Flags &= ~DEVICE_FREQUENCY_REQUEST;
+ device->Flags.unset(FrequencyRequest);
}
if((device->UpdateSize&3) != 0)
@@ -2181,11 +2181,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(update_failed)
return ALC_INVALID_DEVICE;
- if(!(device->Flags&DEVICE_PAUSED))
+ if(!device->Flags.get(DevicePaused))
{
if(device->Backend->start() == ALC_FALSE)
return ALC_INVALID_DEVICE;
- device->Flags |= DEVICE_RUNNING;
+ device->Flags.set(DeviceRunning);
}
return ALC_NO_ERROR;
@@ -3525,10 +3525,10 @@ START_API_FUNC
if(ALCdevice *Device{ctx->Device})
{
std::lock_guard<std::mutex> _{Device->StateLock};
- if(!ReleaseContext(ctx.get(), Device) && (Device->Flags&DEVICE_RUNNING))
+ if(!ReleaseContext(ctx.get(), Device) && Device->Flags.get(DeviceRunning))
{
Device->Backend->stop();
- Device->Flags &= ~DEVICE_RUNNING;
+ Device->Flags.unset(DeviceRunning);
}
}
listlock.unlock();
@@ -3731,7 +3731,7 @@ START_API_FUNC
{
device->FmtChans = iter->chans;
device->mAmbiOrder = iter->order;
- device->Flags |= DEVICE_CHANNELS_REQUEST;
+ device->Flags.set(ChannelsRequest);
}
}
if(ConfigValueStr(deviceName, nullptr, "sample-type", &fmt))
@@ -3758,7 +3758,7 @@ START_API_FUNC
else
{
device->FmtType = iter->type;
- device->Flags |= DEVICE_SAMPLE_TYPE_REQUEST;
+ device->Flags.set(SampleTypeRequest);
}
}
@@ -3773,7 +3773,7 @@ START_API_FUNC
device->UpdateSize = (device->UpdateSize*freq + device->Frequency/2) / device->Frequency;
device->BufferSize = (device->BufferSize*freq + device->Frequency/2) / device->Frequency;
device->Frequency = freq;
- device->Flags |= DEVICE_FREQUENCY_REQUEST;
+ device->Flags.set(FrequencyRequest);
}
ConfigValueUInt(deviceName, nullptr, "period_size", &device->UpdateSize);
@@ -3887,9 +3887,9 @@ START_API_FUNC
ReleaseContext(ctx, device);
ctx = next;
}
- if((device->Flags&DEVICE_RUNNING))
+ if(device->Flags.get(DeviceRunning))
device->Backend->stop();
- device->Flags &= ~DEVICE_RUNNING;
+ device->Flags.unset(DeviceRunning);
statelock.unlock();
ALCdevice_DecRef(device);
@@ -3925,14 +3925,12 @@ START_API_FUNC
DeviceRef device{new ALCdevice{Capture}};
device->Frequency = frequency;
- device->Flags |= DEVICE_FREQUENCY_REQUEST;
-
if(DecomposeDevFormat(format, &device->FmtChans, &device->FmtType) == AL_FALSE)
{
alcSetError(nullptr, ALC_INVALID_ENUM);
return nullptr;
}
- device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_SAMPLE_TYPE_REQUEST;
+ device->Flags.set(FrequencyRequest, ChannelsRequest, SampleTypeRequest);
device->UpdateSize = samples;
device->BufferSize = samples;
@@ -3989,9 +3987,9 @@ START_API_FUNC
listlock.unlock();
{ std::lock_guard<std::mutex> _{device->StateLock};
- if((device->Flags&DEVICE_RUNNING))
+ if(device->Flags.get(DeviceRunning))
device->Backend->stop();
- device->Flags &= ~DEVICE_RUNNING;
+ device->Flags.unset(DeviceRunning);
}
ALCdevice_DecRef(device);
@@ -4013,10 +4011,10 @@ 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&DEVICE_RUNNING))
+ else if(!dev->Flags.get(DeviceRunning))
{
if(dev->Backend->start())
- dev->Flags |= DEVICE_RUNNING;
+ dev->Flags.set(DeviceRunning);
else
{
aluHandleDisconnect(dev.get(), "Device start failure");
@@ -4035,9 +4033,9 @@ START_API_FUNC
else
{
std::lock_guard<std::mutex> _{dev->StateLock};
- if((dev->Flags&DEVICE_RUNNING))
+ if(dev->Flags.get(DeviceRunning))
dev->Backend->stop();
- dev->Flags &= ~DEVICE_RUNNING;
+ dev->Flags.unset(DeviceRunning);
}
}
END_API_FUNC
@@ -4199,10 +4197,10 @@ START_API_FUNC
else
{
std::lock_guard<std::mutex> _{dev->StateLock};
- if((dev->Flags&DEVICE_RUNNING))
+ if(dev->Flags.get(DeviceRunning))
dev->Backend->stop();
- dev->Flags &= ~DEVICE_RUNNING;
- dev->Flags |= DEVICE_PAUSED;
+ dev->Flags.unset(DeviceRunning);
+ dev->Flags.set(DevicePaused);
}
}
END_API_FUNC
@@ -4222,9 +4220,9 @@ START_API_FUNC
}
std::lock_guard<std::mutex> _{dev->StateLock};
- if(!(dev->Flags&DEVICE_PAUSED))
+ if(!dev->Flags.get(DevicePaused))
return;
- dev->Flags &= ~DEVICE_PAUSED;
+ dev->Flags.unset(DevicePaused);
if(dev->ContextList.load() == nullptr)
return;
@@ -4234,7 +4232,7 @@ START_API_FUNC
alcSetError(dev.get(), ALC_INVALID_DEVICE);
return;
}
- dev->Flags |= DEVICE_RUNNING;
+ dev->Flags.set(DeviceRunning);
}
END_API_FUNC
@@ -4291,9 +4289,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&DEVICE_RUNNING))
+ if(dev->Flags.get(DeviceRunning))
dev->Backend->stop();
- dev->Flags &= ~DEVICE_RUNNING;
+ dev->Flags.unset(DeviceRunning);
device->Connected.store(true);
ALCenum err{UpdateDeviceParams(dev.get(), attribs)};