aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-06-08 23:49:15 -0700
committerChris Robinson <[email protected]>2019-06-08 23:49:15 -0700
commit2e154069c6aa3bfc9d00d420e2f508a4127dd649 (patch)
treeaa31339329f8fd04178d94b8a35a3d6314be5fd9 /Alc
parentc9ba7ba19353c9cf55dec668b2b059c267d1b0ea (diff)
Use a bitfield for the device flags
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alc.cpp84
-rw-r--r--Alc/backends/alsa.cpp2
-rw-r--r--Alc/backends/dsound.cpp4
-rw-r--r--Alc/backends/opensl.cpp2
-rw-r--r--Alc/backends/pulseaudio.cpp4
-rw-r--r--Alc/backends/wasapi.cpp4
6 files changed, 49 insertions, 51 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)};
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index eee89b28..1c0d7489 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -725,7 +725,7 @@ ALCboolean AlsaPlayback::reset()
CHECK(snd_pcm_hw_params_set_channels(mPcmHandle, hp, mDevice->channelsFromFmt()));
/* set rate (implicitly constrains period/buffer parameters) */
if(!GetConfigValueBool(mDevice->DeviceName.c_str(), "alsa", "allow-resampler", 0) ||
- !(mDevice->Flags&DEVICE_FREQUENCY_REQUEST))
+ !mDevice->Flags.get(FrequencyRequest))
{
if(snd_pcm_hw_params_set_rate_resample(mPcmHandle, hp, 0) < 0)
ERR("Failed to disable ALSA resampler\n");
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp
index 039f78ac..480d9a18 100644
--- a/Alc/backends/dsound.cpp
+++ b/Alc/backends/dsound.cpp
@@ -359,7 +359,7 @@ ALCboolean DSoundPlayback::reset()
mDevice->FmtType = DevFmtUByte;
break;
case DevFmtFloat:
- if((mDevice->Flags&DEVICE_SAMPLE_TYPE_REQUEST))
+ if(mDevice->Flags.get(SampleTypeRequest))
break;
/* fall-through */
case DevFmtUShort:
@@ -380,7 +380,7 @@ ALCboolean DSoundPlayback::reset()
if(SUCCEEDED(hr))
{
speakers = DSSPEAKER_CONFIG(speakers);
- if(!(mDevice->Flags&DEVICE_CHANNELS_REQUEST))
+ if(!mDevice->Flags.get(ChannelsRequest))
{
if(speakers == DSSPEAKER_MONO)
mDevice->FmtChans = DevFmtMono;
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index 4cf7ca36..37495abe 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -361,7 +361,7 @@ ALCboolean OpenSLPlayback::reset()
mRing = nullptr;
#if 0
- if(!(mDevice->Flags&DEVICE_FREQUENCY_REQUEST))
+ if(!mDevice->Flags.get(FrequencyRequest))
{
/* FIXME: Disabled until I figure out how to get the Context needed for
* the getSystemService call.
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index 30c0053d..0b7257d1 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -779,7 +779,7 @@ void PulsePlayback::sinkInfoCallback(pa_context* UNUSED(context), const pa_sink_
);
if(chanmap != chanmaps.cend())
{
- if(!(mDevice->Flags&DEVICE_CHANNELS_REQUEST))
+ if(!mDevice->Flags.get(ChannelsRequest))
mDevice->FmtChans = chanmap->chans;
}
else
@@ -910,7 +910,7 @@ ALCboolean PulsePlayback::reset()
flags |= PA_STREAM_ADJUST_LATENCY;
}
if(GetConfigValueBool(mDevice->DeviceName.c_str(), "pulse", "fix-rate", 0) ||
- !(mDevice->Flags&DEVICE_FREQUENCY_REQUEST))
+ !mDevice->Flags.get(FrequencyRequest))
flags |= PA_STREAM_FIX_RATE;
pa_channel_map chanmap{};
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index c80e5943..6c3dc6e6 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -787,9 +787,9 @@ HRESULT WasapiPlayback::resetProxy()
const REFERENCE_TIME per_time{mDevice->UpdateSize * REFTIME_PER_SEC / mDevice->Frequency};
const REFERENCE_TIME buf_time{mDevice->BufferSize * REFTIME_PER_SEC / mDevice->Frequency};
- if(!(mDevice->Flags&DEVICE_FREQUENCY_REQUEST))
+ if(!mDevice->Flags.get(FrequencyRequest))
mDevice->Frequency = OutputType.Format.nSamplesPerSec;
- if(!(mDevice->Flags&DEVICE_CHANNELS_REQUEST))
+ if(!mDevice->Flags.get(ChannelsRequest))
{
if(OutputType.Format.nChannels == 1 && OutputType.dwChannelMask == MONO)
mDevice->FmtChans = DevFmtMono;