Use a standard bitset for bitfield flags
This commit is contained in:
+41
-39
@@ -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
|
/* If a context is already running on the device, stop playback so the
|
||||||
* device attributes can be updated.
|
* device attributes can be updated.
|
||||||
*/
|
*/
|
||||||
if(device->Flags.get<DeviceRunning>())
|
if(device->Flags.test(DeviceRunning))
|
||||||
device->Backend->stop();
|
device->Backend->stop();
|
||||||
device->Flags.unset<DeviceRunning>();
|
device->Flags.reset(DeviceRunning);
|
||||||
|
|
||||||
UpdateClockBase(device);
|
UpdateClockBase(device);
|
||||||
|
|
||||||
@@ -1833,7 +1833,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
|
|||||||
|
|
||||||
freq = ConfigValueUInt(devname, nullptr, "frequency").value_or(freq);
|
freq = ConfigValueUInt(devname, nullptr, "frequency").value_or(freq);
|
||||||
if(freq < 1)
|
if(freq < 1)
|
||||||
device->Flags.unset<FrequencyRequest>();
|
device->Flags.reset(FrequencyRequest);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
freq = clampu(freq, MIN_OUTPUT_RATE, MAX_OUTPUT_RATE);
|
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->BufferSize = static_cast<uint>(device->BufferSize*scale + 0.5);
|
||||||
|
|
||||||
device->Frequency = freq;
|
device->Frequency = freq;
|
||||||
device->Flags.set<FrequencyRequest>();
|
device->Flags.set(FrequencyRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(auto persizeopt = ConfigValueUInt(devname, nullptr, "period_size"))
|
if(auto persizeopt = ConfigValueUInt(devname, nullptr, "period_size"))
|
||||||
@@ -1878,7 +1878,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
|
|||||||
new_sends = numSends;
|
new_sends = numSends;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(device->Flags.get<DeviceRunning>())
|
if(device->Flags.test(DeviceRunning))
|
||||||
return ALC_NO_ERROR;
|
return ALC_NO_ERROR;
|
||||||
|
|
||||||
device->AvgSpeakerDist = 0.0f;
|
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))
|
if(hrtf_userreq == Hrtf_Enable || (hrtf_userreq != Hrtf_Disable && hrtf_appreq == Hrtf_Enable))
|
||||||
{
|
{
|
||||||
device->FmtChans = DevFmtStereo;
|
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;
|
oldType = device->FmtType;
|
||||||
|
|
||||||
TRACE("Pre-reset: %s%s, %s%s, %s%uhz, %u / %u buffer\n",
|
TRACE("Pre-reset: %s%s, %s%s, %s%uhz, %u / %u buffer\n",
|
||||||
device->Flags.get<ChannelsRequest>()?"*":"", DevFmtChannelsString(device->FmtChans),
|
device->Flags.test(ChannelsRequest)?"*":"", DevFmtChannelsString(device->FmtChans),
|
||||||
device->Flags.get<SampleTypeRequest>()?"*":"", DevFmtTypeString(device->FmtType),
|
device->Flags.test(SampleTypeRequest)?"*":"", DevFmtTypeString(device->FmtType),
|
||||||
device->Flags.get<FrequencyRequest>()?"*":"", device->Frequency,
|
device->Flags.test(FrequencyRequest)?"*":"", device->Frequency,
|
||||||
device->UpdateSize, device->BufferSize);
|
device->UpdateSize, device->BufferSize);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1951,22 +1951,22 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
|
|||||||
return ALC_INVALID_DEVICE;
|
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),
|
ERR("Failed to set %s, got %s instead\n", DevFmtChannelsString(oldChans),
|
||||||
DevFmtChannelsString(device->FmtChans));
|
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),
|
ERR("Failed to set %s, got %s instead\n", DevFmtTypeString(oldType),
|
||||||
DevFmtTypeString(device->FmtType));
|
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);
|
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",
|
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();
|
mixer_mode.leave();
|
||||||
|
|
||||||
if(!device->Flags.get<DevicePaused>())
|
if(!device->Flags.test(DevicePaused))
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto backend = device->Backend.get();
|
auto backend = device->Backend.get();
|
||||||
backend->start();
|
backend->start();
|
||||||
device->Flags.set<DeviceRunning>();
|
device->Flags.set(DeviceRunning);
|
||||||
}
|
}
|
||||||
catch(al::backend_exception& e) {
|
catch(al::backend_exception& e) {
|
||||||
device->handleDisconnect("%s", e.what());
|
device->handleDisconnect("%s", e.what());
|
||||||
@@ -3367,10 +3367,10 @@ START_API_FUNC
|
|||||||
ALCdevice *Device{ctx->mDevice.get()};
|
ALCdevice *Device{ctx->mDevice.get()};
|
||||||
|
|
||||||
std::lock_guard<std::mutex> _{Device->StateLock};
|
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->Backend->stop();
|
||||||
Device->Flags.unset<DeviceRunning>();
|
Device->Flags.reset(DeviceRunning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_API_FUNC
|
END_API_FUNC
|
||||||
@@ -3545,7 +3545,7 @@ START_API_FUNC
|
|||||||
{
|
{
|
||||||
device->FmtChans = iter->chans;
|
device->FmtChans = iter->chans;
|
||||||
device->mAmbiOrder = iter->order;
|
device->mAmbiOrder = iter->order;
|
||||||
device->Flags.set<ChannelsRequest>();
|
device->Flags.set(ChannelsRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(auto typeopt = ConfigValueStr(deviceName, nullptr, "sample-type"))
|
if(auto typeopt = ConfigValueStr(deviceName, nullptr, "sample-type"))
|
||||||
@@ -3573,7 +3573,7 @@ START_API_FUNC
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
device->FmtType = iter->type;
|
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->UpdateSize = static_cast<uint>(device->UpdateSize*scale + 0.5);
|
||||||
device->BufferSize = static_cast<uint>(device->BufferSize*scale + 0.5);
|
device->BufferSize = static_cast<uint>(device->BufferSize*scale + 0.5);
|
||||||
device->Frequency = freq;
|
device->Frequency = freq;
|
||||||
device->Flags.set<FrequencyRequest>();
|
device->Flags.set(FrequencyRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(auto persizeopt = ConfigValueUInt(deviceName, nullptr, "period_size"))
|
if(auto persizeopt = ConfigValueUInt(deviceName, nullptr, "period_size"))
|
||||||
@@ -3698,9 +3698,9 @@ START_API_FUNC
|
|||||||
}
|
}
|
||||||
orphanctxs.clear();
|
orphanctxs.clear();
|
||||||
|
|
||||||
if(dev->Flags.get<DeviceRunning>())
|
if(dev->Flags.test(DeviceRunning))
|
||||||
dev->Backend->stop();
|
dev->Backend->stop();
|
||||||
dev->Flags.unset<DeviceRunning>();
|
dev->Flags.reset(DeviceRunning);
|
||||||
|
|
||||||
return ALC_TRUE;
|
return ALC_TRUE;
|
||||||
}
|
}
|
||||||
@@ -3746,7 +3746,9 @@ START_API_FUNC
|
|||||||
device->Frequency = frequency;
|
device->Frequency = frequency;
|
||||||
device->FmtChans = decompfmt->chans;
|
device->FmtChans = decompfmt->chans;
|
||||||
device->FmtType = decompfmt->type;
|
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->UpdateSize = static_cast<uint>(samples);
|
||||||
device->BufferSize = static_cast<uint>(samples);
|
device->BufferSize = static_cast<uint>(samples);
|
||||||
@@ -3800,9 +3802,9 @@ START_API_FUNC
|
|||||||
listlock.unlock();
|
listlock.unlock();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> _{dev->StateLock};
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
||||||
if(dev->Flags.get<DeviceRunning>())
|
if(dev->Flags.test(DeviceRunning))
|
||||||
dev->Backend->stop();
|
dev->Backend->stop();
|
||||||
dev->Flags.unset<DeviceRunning>();
|
dev->Flags.reset(DeviceRunning);
|
||||||
|
|
||||||
return ALC_TRUE;
|
return ALC_TRUE;
|
||||||
}
|
}
|
||||||
@@ -3821,12 +3823,12 @@ START_API_FUNC
|
|||||||
std::lock_guard<std::mutex> _{dev->StateLock};
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
||||||
if(!dev->Connected.load(std::memory_order_acquire))
|
if(!dev->Connected.load(std::memory_order_acquire))
|
||||||
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
||||||
else if(!dev->Flags.get<DeviceRunning>())
|
else if(!dev->Flags.test(DeviceRunning))
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto backend = dev->Backend.get();
|
auto backend = dev->Backend.get();
|
||||||
backend->start();
|
backend->start();
|
||||||
dev->Flags.set<DeviceRunning>();
|
dev->Flags.set(DeviceRunning);
|
||||||
}
|
}
|
||||||
catch(al::backend_exception& e) {
|
catch(al::backend_exception& e) {
|
||||||
dev->handleDisconnect("%s", e.what());
|
dev->handleDisconnect("%s", e.what());
|
||||||
@@ -3845,9 +3847,9 @@ START_API_FUNC
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _{dev->StateLock};
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
||||||
if(dev->Flags.get<DeviceRunning>())
|
if(dev->Flags.test(DeviceRunning))
|
||||||
dev->Backend->stop();
|
dev->Backend->stop();
|
||||||
dev->Flags.unset<DeviceRunning>();
|
dev->Flags.reset(DeviceRunning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_API_FUNC
|
END_API_FUNC
|
||||||
@@ -4007,10 +4009,10 @@ START_API_FUNC
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _{dev->StateLock};
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
||||||
if(dev->Flags.get<DeviceRunning>())
|
if(dev->Flags.test(DeviceRunning))
|
||||||
dev->Backend->stop();
|
dev->Backend->stop();
|
||||||
dev->Flags.unset<DeviceRunning>();
|
dev->Flags.reset(DeviceRunning);
|
||||||
dev->Flags.set<DevicePaused>();
|
dev->Flags.set(DevicePaused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_API_FUNC
|
END_API_FUNC
|
||||||
@@ -4027,16 +4029,16 @@ START_API_FUNC
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> _{dev->StateLock};
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
||||||
if(!dev->Flags.get<DevicePaused>())
|
if(!dev->Flags.test(DevicePaused))
|
||||||
return;
|
return;
|
||||||
dev->Flags.unset<DevicePaused>();
|
dev->Flags.reset(DevicePaused);
|
||||||
if(dev->mContexts.load()->empty())
|
if(dev->mContexts.load()->empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto backend = dev->Backend.get();
|
auto backend = dev->Backend.get();
|
||||||
backend->start();
|
backend->start();
|
||||||
dev->Flags.set<DeviceRunning>();
|
dev->Flags.set(DeviceRunning);
|
||||||
}
|
}
|
||||||
catch(al::backend_exception& e) {
|
catch(al::backend_exception& e) {
|
||||||
dev->handleDisconnect("%s", e.what());
|
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
|
/* Force the backend to stop mixing first since we're resetting. Also reset
|
||||||
* the connected state so lost devices can attempt recover.
|
* the connected state so lost devices can attempt recover.
|
||||||
*/
|
*/
|
||||||
if(dev->Flags.get<DeviceRunning>())
|
if(dev->Flags.test(DeviceRunning))
|
||||||
dev->Backend->stop();
|
dev->Backend->stop();
|
||||||
dev->Flags.unset<DeviceRunning>();
|
dev->Flags.reset(DeviceRunning);
|
||||||
if(!dev->Connected.load(std::memory_order_relaxed))
|
if(!dev->Connected.load(std::memory_order_relaxed))
|
||||||
{
|
{
|
||||||
/* Make sure disconnection is finished before continuing on. */
|
/* Make sure disconnection is finished before continuing on. */
|
||||||
|
|||||||
+2
-2
@@ -4,6 +4,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <bitset>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@@ -17,7 +18,6 @@
|
|||||||
#include "AL/alc.h"
|
#include "AL/alc.h"
|
||||||
#include "AL/alext.h"
|
#include "AL/alext.h"
|
||||||
|
|
||||||
#include "albyte.h"
|
|
||||||
#include "almalloc.h"
|
#include "almalloc.h"
|
||||||
#include "alnumeric.h"
|
#include "alnumeric.h"
|
||||||
#include "alspan.h"
|
#include "alspan.h"
|
||||||
@@ -201,7 +201,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
|
|||||||
std::string DeviceName;
|
std::string DeviceName;
|
||||||
|
|
||||||
// Device flags
|
// Device flags
|
||||||
al::bitfield<DeviceFlagsCount> Flags{};
|
std::bitset<DeviceFlagsCount> Flags{};
|
||||||
|
|
||||||
// Maximum number of sources that can be created
|
// Maximum number of sources that can be created
|
||||||
uint SourcesMax{};
|
uint SourcesMax{};
|
||||||
|
|||||||
@@ -746,8 +746,8 @@ bool AlsaPlayback::reset()
|
|||||||
}
|
}
|
||||||
CHECK(snd_pcm_hw_params_set_channels(mPcmHandle, hp.get(), mDevice->channelsFromFmt()));
|
CHECK(snd_pcm_hw_params_set_channels(mPcmHandle, hp.get(), mDevice->channelsFromFmt()));
|
||||||
/* set rate (implicitly constrains period/buffer parameters) */
|
/* set rate (implicitly constrains period/buffer parameters) */
|
||||||
if(!GetConfigValueBool(mDevice->DeviceName.c_str(), "alsa", "allow-resampler", 0) ||
|
if(!GetConfigValueBool(mDevice->DeviceName.c_str(), "alsa", "allow-resampler", 0)
|
||||||
!mDevice->Flags.get<FrequencyRequest>())
|
|| !mDevice->Flags.test(FrequencyRequest))
|
||||||
{
|
{
|
||||||
if(snd_pcm_hw_params_set_rate_resample(mPcmHandle, hp.get(), 0) < 0)
|
if(snd_pcm_hw_params_set_rate_resample(mPcmHandle, hp.get(), 0) < 0)
|
||||||
ERR("Failed to disable ALSA resampler\n");
|
ERR("Failed to disable ALSA resampler\n");
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ bool DSoundPlayback::reset()
|
|||||||
mDevice->FmtType = DevFmtUByte;
|
mDevice->FmtType = DevFmtUByte;
|
||||||
break;
|
break;
|
||||||
case DevFmtFloat:
|
case DevFmtFloat:
|
||||||
if(mDevice->Flags.get<SampleTypeRequest>())
|
if(mDevice->Flags.test(SampleTypeRequest))
|
||||||
break;
|
break;
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case DevFmtUShort:
|
case DevFmtUShort:
|
||||||
@@ -398,7 +398,7 @@ bool DSoundPlayback::reset()
|
|||||||
if(SUCCEEDED(hr))
|
if(SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
speakers = DSSPEAKER_CONFIG(speakers);
|
speakers = DSSPEAKER_CONFIG(speakers);
|
||||||
if(!mDevice->Flags.get<ChannelsRequest>())
|
if(!mDevice->Flags.test(ChannelsRequest))
|
||||||
{
|
{
|
||||||
if(speakers == DSSPEAKER_MONO)
|
if(speakers == DSSPEAKER_MONO)
|
||||||
mDevice->FmtChans = DevFmtMono;
|
mDevice->FmtChans = DevFmtMono;
|
||||||
|
|||||||
@@ -87,9 +87,9 @@ bool OboePlayback::reset()
|
|||||||
builder.setFormatConversionAllowed(false);
|
builder.setFormatConversionAllowed(false);
|
||||||
builder.setCallback(this);
|
builder.setCallback(this);
|
||||||
|
|
||||||
if(mDevice->Flags.get<FrequencyRequest>())
|
if(mDevice->Flags.test(FrequencyRequest))
|
||||||
builder.setSampleRate(static_cast<int32_t>(mDevice->Frequency));
|
builder.setSampleRate(static_cast<int32_t>(mDevice->Frequency));
|
||||||
if(mDevice->Flags.get<ChannelsRequest>())
|
if(mDevice->Flags.test(ChannelsRequest))
|
||||||
{
|
{
|
||||||
/* Only use mono or stereo at user request. There's no telling what
|
/* Only use mono or stereo at user request. There's no telling what
|
||||||
* other counts may be inferred as.
|
* other counts may be inferred as.
|
||||||
@@ -98,7 +98,7 @@ bool OboePlayback::reset()
|
|||||||
: (mDevice->FmtChans==DevFmtStereo) ? oboe::ChannelCount::Stereo
|
: (mDevice->FmtChans==DevFmtStereo) ? oboe::ChannelCount::Stereo
|
||||||
: oboe::ChannelCount::Unspecified);
|
: oboe::ChannelCount::Unspecified);
|
||||||
}
|
}
|
||||||
if(mDevice->Flags.get<SampleTypeRequest>())
|
if(mDevice->Flags.test(SampleTypeRequest))
|
||||||
{
|
{
|
||||||
oboe::AudioFormat format{oboe::AudioFormat::Unspecified};
|
oboe::AudioFormat format{oboe::AudioFormat::Unspecified};
|
||||||
switch(mDevice->FmtType)
|
switch(mDevice->FmtType)
|
||||||
|
|||||||
@@ -793,7 +793,7 @@ void PulsePlayback::sinkInfoCallback(pa_context*, const pa_sink_info *info, int
|
|||||||
);
|
);
|
||||||
if(chaniter != chanmaps.cend())
|
if(chaniter != chanmaps.cend())
|
||||||
{
|
{
|
||||||
if(!mDevice->Flags.get<ChannelsRequest>())
|
if(!mDevice->Flags.test(ChannelsRequest))
|
||||||
mDevice->FmtChans = chaniter->fmt;
|
mDevice->FmtChans = chaniter->fmt;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -914,8 +914,8 @@ bool PulsePlayback::reset()
|
|||||||
flags &= ~PA_STREAM_EARLY_REQUESTS;
|
flags &= ~PA_STREAM_EARLY_REQUESTS;
|
||||||
flags |= PA_STREAM_ADJUST_LATENCY;
|
flags |= PA_STREAM_ADJUST_LATENCY;
|
||||||
}
|
}
|
||||||
if(GetConfigValueBool(mDevice->DeviceName.c_str(), "pulse", "fix-rate", 0) ||
|
if(GetConfigValueBool(mDevice->DeviceName.c_str(), "pulse", "fix-rate", 0)
|
||||||
!mDevice->Flags.get<FrequencyRequest>())
|
|| !mDevice->Flags.test(FrequencyRequest))
|
||||||
flags |= PA_STREAM_FIX_RATE;
|
flags |= PA_STREAM_FIX_RATE;
|
||||||
|
|
||||||
pa_channel_map chanmap{};
|
pa_channel_map chanmap{};
|
||||||
|
|||||||
@@ -924,9 +924,9 @@ HRESULT WasapiPlayback::resetProxy()
|
|||||||
const ReferenceTime per_time{ReferenceTime{seconds{mDevice->UpdateSize}} / mDevice->Frequency};
|
const ReferenceTime per_time{ReferenceTime{seconds{mDevice->UpdateSize}} / mDevice->Frequency};
|
||||||
const ReferenceTime buf_time{ReferenceTime{seconds{mDevice->BufferSize}} / mDevice->Frequency};
|
const ReferenceTime buf_time{ReferenceTime{seconds{mDevice->BufferSize}} / mDevice->Frequency};
|
||||||
|
|
||||||
if(!mDevice->Flags.get<FrequencyRequest>())
|
if(!mDevice->Flags.test(FrequencyRequest))
|
||||||
mDevice->Frequency = OutputType.Format.nSamplesPerSec;
|
mDevice->Frequency = OutputType.Format.nSamplesPerSec;
|
||||||
if(!mDevice->Flags.get<ChannelsRequest>())
|
if(!mDevice->Flags.test(ChannelsRequest))
|
||||||
{
|
{
|
||||||
const uint32_t chancount{OutputType.Format.nChannels};
|
const uint32_t chancount{OutputType.Format.nChannels};
|
||||||
const DWORD chanmask{OutputType.dwChannelMask};
|
const DWORD chanmask{OutputType.dwChannelMask};
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "albit.h"
|
#include "albit.h"
|
||||||
|
#include "albyte.h"
|
||||||
#include "alcmain.h"
|
#include "alcmain.h"
|
||||||
#include "alconfig.h"
|
#include "alconfig.h"
|
||||||
#include "alfstream.h"
|
#include "alfstream.h"
|
||||||
|
|||||||
@@ -62,53 +62,6 @@ AL_DECL_OP(^, ^=)
|
|||||||
constexpr al::byte operator~(al::byte b) noexcept
|
constexpr al::byte operator~(al::byte b) noexcept
|
||||||
{ return al::byte(~to_integer<uint>(b)); }
|
{ return al::byte(~to_integer<uint>(b)); }
|
||||||
|
|
||||||
|
|
||||||
namespace detail_ {
|
|
||||||
template<size_t> struct Elem { };
|
|
||||||
template<> struct Elem<1> { using type = uint8_t; };
|
|
||||||
template<> struct Elem<2> { using type = uint16_t; };
|
|
||||||
template<> struct Elem<3> { using type = uint32_t; };
|
|
||||||
template<> struct Elem<4> { using type = uint32_t; };
|
|
||||||
|
|
||||||
template<size_t N> using ElemT = typename Elem<N>::type;
|
|
||||||
} // namespace detail_
|
|
||||||
|
|
||||||
template<size_t N>
|
|
||||||
class bitfield {
|
|
||||||
static constexpr size_t bits_per_byte{std::numeric_limits<unsigned char>::digits};
|
|
||||||
static constexpr size_t NumElems{(N+bits_per_byte-1) / bits_per_byte};
|
|
||||||
|
|
||||||
using storage_type = detail_::ElemT<NumElems>;
|
|
||||||
storage_type vals{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
template<size_t b>
|
|
||||||
inline void set() noexcept
|
|
||||||
{
|
|
||||||
static_assert(b < N, "Bit index out of range");
|
|
||||||
vals |= 1 << b;
|
|
||||||
}
|
|
||||||
template<size_t b>
|
|
||||||
inline void unset() noexcept
|
|
||||||
{
|
|
||||||
static_assert(b < N, "Bit index out of range");
|
|
||||||
vals &= static_cast<storage_type>(~(1 << b));
|
|
||||||
}
|
|
||||||
template<size_t b>
|
|
||||||
inline bool get() const noexcept
|
|
||||||
{
|
|
||||||
static_assert(b < N, "Bit index out of range");
|
|
||||||
return (vals & (1 << b)) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<size_t b, size_t ...args>
|
|
||||||
std::enable_if_t<(sizeof...(args) > 0)> set() noexcept
|
|
||||||
{
|
|
||||||
set<b>();
|
|
||||||
set<args...>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace al
|
} // namespace al
|
||||||
|
|
||||||
#endif /* AL_BYTE_H */
|
#endif /* AL_BYTE_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user