diff options
36 files changed, 143 insertions, 167 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 764b4590..07377ddb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -599,7 +599,6 @@ set(COMMON_OBJS common/almalloc.h common/alnumbers.h common/alnumeric.h - common/aloptional.h common/alspan.h common/alstring.cpp common/alstring.h diff --git a/al/buffer.cpp b/al/buffer.cpp index b89ad5af..4f0bcf8c 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -35,6 +35,7 @@ #include <mutex> #include <new> #include <numeric> +#include <optional> #include <stdexcept> #include <utility> @@ -49,7 +50,6 @@ #include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" -#include "aloptional.h" #include "atomic.h" #include "core/except.h" #include "core/logging.h" @@ -64,14 +64,14 @@ namespace { -al::optional<AmbiLayout> AmbiLayoutFromEnum(ALenum layout) +std::optional<AmbiLayout> AmbiLayoutFromEnum(ALenum layout) { switch(layout) { case AL_FUMA_SOFT: return AmbiLayout::FuMa; case AL_ACN_SOFT: return AmbiLayout::ACN; } - return al::nullopt; + return std::nullopt; } ALenum EnumFromAmbiLayout(AmbiLayout layout) { @@ -83,7 +83,7 @@ ALenum EnumFromAmbiLayout(AmbiLayout layout) throw std::runtime_error{"Invalid AmbiLayout: "+std::to_string(int(layout))}; } -al::optional<AmbiScaling> AmbiScalingFromEnum(ALenum scale) +std::optional<AmbiScaling> AmbiScalingFromEnum(ALenum scale) { switch(scale) { @@ -91,7 +91,7 @@ al::optional<AmbiScaling> AmbiScalingFromEnum(ALenum scale) case AL_SN3D_SOFT: return AmbiScaling::SN3D; case AL_N3D_SOFT: return AmbiScaling::N3D; } - return al::nullopt; + return std::nullopt; } ALenum EnumFromAmbiScaling(AmbiScaling scale) { @@ -106,7 +106,7 @@ ALenum EnumFromAmbiScaling(AmbiScaling scale) } #ifdef ALSOFT_EAX -al::optional<EaxStorage> EaxStorageFromEnum(ALenum scale) +std::optional<EaxStorage> EaxStorageFromEnum(ALenum scale) { switch(scale) { @@ -114,7 +114,7 @@ al::optional<EaxStorage> EaxStorageFromEnum(ALenum scale) case AL_STORAGE_ACCESSIBLE: return EaxStorage::Accessible; case AL_STORAGE_HARDWARE: return EaxStorage::Hardware; } - return al::nullopt; + return std::nullopt; } ALenum EnumFromEaxStorage(EaxStorage storage) { @@ -536,7 +536,7 @@ void PrepareUserPtr(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, struct DecompResult { FmtChannels channels; FmtType type; }; -al::optional<DecompResult> DecomposeUserFormat(ALenum format) +std::optional<DecompResult> DecomposeUserFormat(ALenum format) { struct FormatMap { ALenum format; @@ -624,9 +624,9 @@ al::optional<DecompResult> DecomposeUserFormat(ALenum format) for(const auto &fmt : UserFmtList) { if(fmt.format == format) - return al::make_optional<DecompResult>({fmt.channels, fmt.type}); + return DecompResult{fmt.channels, fmt.type}; } - return al::nullopt; + return std::nullopt; } } // namespace diff --git a/al/debug.cpp b/al/debug.cpp index 786fcd1f..3df85d62 100644 --- a/al/debug.cpp +++ b/al/debug.cpp @@ -6,6 +6,7 @@ #include <array> #include <cstring> #include <mutex> +#include <optional> #include <stddef.h> #include <stdexcept> #include <string> @@ -15,7 +16,6 @@ #include "alc/context.h" #include "alc/inprogext.h" -#include "aloptional.h" #include "alspan.h" #include "core/logging.h" #include "opthelpers.h" @@ -35,7 +35,7 @@ constexpr auto make_array() { return make_array(std::make_integer_sequence<T,N>{}); } -constexpr al::optional<DebugSource> GetDebugSource(ALenum source) noexcept +constexpr std::optional<DebugSource> GetDebugSource(ALenum source) noexcept { switch(source) { @@ -45,10 +45,10 @@ constexpr al::optional<DebugSource> GetDebugSource(ALenum source) noexcept case AL_DEBUG_SOURCE_APPLICATION_EXT: return DebugSource::Application; case AL_DEBUG_SOURCE_OTHER_EXT: return DebugSource::Other; } - return al::nullopt; + return std::nullopt; } -constexpr al::optional<DebugType> GetDebugType(ALenum type) noexcept +constexpr std::optional<DebugType> GetDebugType(ALenum type) noexcept { switch(type) { @@ -62,10 +62,10 @@ constexpr al::optional<DebugType> GetDebugType(ALenum type) noexcept case AL_DEBUG_TYPE_POP_GROUP_EXT: return DebugType::PopGroup; case AL_DEBUG_TYPE_OTHER_EXT: return DebugType::Other; } - return al::nullopt; + return std::nullopt; } -constexpr al::optional<DebugSeverity> GetDebugSeverity(ALenum severity) noexcept +constexpr std::optional<DebugSeverity> GetDebugSeverity(ALenum severity) noexcept { switch(severity) { @@ -74,7 +74,7 @@ constexpr al::optional<DebugSeverity> GetDebugSeverity(ALenum severity) noexcept case AL_DEBUG_SEVERITY_LOW_EXT: return DebugSeverity::Low; case AL_DEBUG_SEVERITY_NOTIFICATION_EXT: return DebugSeverity::Notification; } - return al::nullopt; + return std::nullopt; } diff --git a/al/eax/fx_slot_index.h b/al/eax/fx_slot_index.h index 63dba037..9f350d9b 100644 --- a/al/eax/fx_slot_index.h +++ b/al/eax/fx_slot_index.h @@ -3,17 +3,16 @@ #include <cstddef> +#include <optional> -#include "aloptional.h" #include "api.h" using EaxFxSlotIndexValue = std::size_t; -class EaxFxSlotIndex : public al::optional<EaxFxSlotIndexValue> -{ +class EaxFxSlotIndex : public std::optional<EaxFxSlotIndexValue> { public: - using al::optional<EaxFxSlotIndexValue>::optional; + using std::optional<EaxFxSlotIndexValue>::optional; EaxFxSlotIndex& operator=(const EaxFxSlotIndexValue &value) { set(value); return *this; } EaxFxSlotIndex& operator=(const GUID &guid) { set(guid); return *this; } diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp index 305259a4..2e0c23dd 100644 --- a/al/effects/chorus.cpp +++ b/al/effects/chorus.cpp @@ -1,13 +1,13 @@ #include "config.h" +#include <optional> #include <stdexcept> #include "AL/al.h" #include "AL/efx.h" #include "alc/effects/base.h" -#include "aloptional.h" #include "core/logging.h" #include "effects.h" @@ -27,14 +27,14 @@ static_assert(FlangerMaxDelay >= AL_FLANGER_MAX_DELAY, "Flanger max delay too sm static_assert(AL_CHORUS_WAVEFORM_SINUSOID == AL_FLANGER_WAVEFORM_SINUSOID, "Chorus/Flanger waveform value mismatch"); static_assert(AL_CHORUS_WAVEFORM_TRIANGLE == AL_FLANGER_WAVEFORM_TRIANGLE, "Chorus/Flanger waveform value mismatch"); -inline al::optional<ChorusWaveform> WaveformFromEnum(ALenum type) +inline std::optional<ChorusWaveform> WaveformFromEnum(ALenum type) { switch(type) { case AL_CHORUS_WAVEFORM_SINUSOID: return ChorusWaveform::Sinusoid; case AL_CHORUS_WAVEFORM_TRIANGLE: return ChorusWaveform::Triangle; } - return al::nullopt; + return std::nullopt; } inline ALenum EnumFromWaveform(ChorusWaveform type) { diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp index 949db203..54e71408 100644 --- a/al/effects/fshifter.cpp +++ b/al/effects/fshifter.cpp @@ -1,13 +1,13 @@ #include "config.h" +#include <optional> #include <stdexcept> #include "AL/al.h" #include "AL/efx.h" #include "alc/effects/base.h" -#include "aloptional.h" #include "effects.h" #ifdef ALSOFT_EAX @@ -20,7 +20,7 @@ namespace { -al::optional<FShifterDirection> DirectionFromEmum(ALenum value) +std::optional<FShifterDirection> DirectionFromEmum(ALenum value) { switch(value) { @@ -28,7 +28,7 @@ al::optional<FShifterDirection> DirectionFromEmum(ALenum value) case AL_FREQUENCY_SHIFTER_DIRECTION_UP: return FShifterDirection::Up; case AL_FREQUENCY_SHIFTER_DIRECTION_OFF: return FShifterDirection::Off; } - return al::nullopt; + return std::nullopt; } ALenum EnumFromDirection(FShifterDirection dir) { diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp index 5f37d08f..228fe084 100644 --- a/al/effects/modulator.cpp +++ b/al/effects/modulator.cpp @@ -1,13 +1,13 @@ #include "config.h" +#include <optional> #include <stdexcept> #include "AL/al.h" #include "AL/efx.h" #include "alc/effects/base.h" -#include "aloptional.h" #include "effects.h" #ifdef ALSOFT_EAX @@ -20,7 +20,7 @@ namespace { -al::optional<ModulatorWaveform> WaveformFromEmum(ALenum value) +std::optional<ModulatorWaveform> WaveformFromEmum(ALenum value) { switch(value) { @@ -28,7 +28,7 @@ al::optional<ModulatorWaveform> WaveformFromEmum(ALenum value) case AL_RING_MODULATOR_SAWTOOTH: return ModulatorWaveform::Sawtooth; case AL_RING_MODULATOR_SQUARE: return ModulatorWaveform::Square; } - return al::nullopt; + return std::nullopt; } ALenum EnumFromWaveform(ModulatorWaveform type) { diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp index 21ea3680..6268ea7f 100644 --- a/al/effects/vmorpher.cpp +++ b/al/effects/vmorpher.cpp @@ -1,13 +1,13 @@ #include "config.h" +#include <optional> #include <stdexcept> #include "AL/al.h" #include "AL/efx.h" #include "alc/effects/base.h" -#include "aloptional.h" #include "effects.h" #ifdef ALSOFT_EAX @@ -20,7 +20,7 @@ namespace { -al::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val) +std::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val) { #define HANDLE_PHENOME(x) case AL_VOCAL_MORPHER_PHONEME_ ## x: \ return VMorpherPhenome::x @@ -57,7 +57,7 @@ al::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val) HANDLE_PHENOME(V); HANDLE_PHENOME(Z); } - return al::nullopt; + return std::nullopt; #undef HANDLE_PHENOME } ALenum EnumFromPhenome(VMorpherPhenome phenome) @@ -100,7 +100,7 @@ ALenum EnumFromPhenome(VMorpherPhenome phenome) #undef HANDLE_PHENOME } -al::optional<VMorpherWaveform> WaveformFromEmum(ALenum value) +std::optional<VMorpherWaveform> WaveformFromEmum(ALenum value) { switch(value) { @@ -108,7 +108,7 @@ al::optional<VMorpherWaveform> WaveformFromEmum(ALenum value) case AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE: return VMorpherWaveform::Triangle; case AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH: return VMorpherWaveform::Sawtooth; } - return al::nullopt; + return std::nullopt; } ALenum EnumFromWaveform(VMorpherWaveform type) { diff --git a/al/source.cpp b/al/source.cpp index f51c3bca..2b0540b4 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -38,6 +38,7 @@ #include <mutex> #include <new> #include <numeric> +#include <optional> #include <stdexcept> #include <thread> #include <utility> @@ -55,7 +56,6 @@ #include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "atomic.h" #include "auxeffectslot.h" @@ -395,8 +395,8 @@ struct VoicePos { * using the givem offset type and offset. If the offset is out of range, * returns an empty optional. */ -al::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList, ALenum OffsetType, - double Offset) +std::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList, + ALenum OffsetType, double Offset) { /* Find the first valid Buffer in the Queue */ const ALbuffer *BufferFmt{nullptr}; @@ -406,7 +406,7 @@ al::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList, if(BufferFmt) break; } if(!BufferFmt) UNLIKELY - return al::nullopt; + return std::nullopt; /* Get sample frame offset */ int64_t offset{}; @@ -452,12 +452,12 @@ al::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList, if(offset < 0) { if(offset < std::numeric_limits<int>::min()) - return al::nullopt; + return std::nullopt; return VoicePos{static_cast<int>(offset), frac, &BufferList.front()}; } if(BufferFmt->mCallback) - return al::nullopt; + return std::nullopt; int64_t totalBufferLen{0}; for(auto &item : BufferList) @@ -473,7 +473,7 @@ al::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList, } /* Offset is out of range of the queue */ - return al::nullopt; + return std::nullopt; } @@ -798,7 +798,7 @@ inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) noexcept } -al::optional<SourceStereo> StereoModeFromEnum(ALenum mode) +std::optional<SourceStereo> StereoModeFromEnum(ALenum mode) { switch(mode) { @@ -806,7 +806,7 @@ al::optional<SourceStereo> StereoModeFromEnum(ALenum mode) case AL_SUPER_STEREO_SOFT: return SourceStereo::Enhanced; } WARN("Unsupported stereo mode: 0x%04x\n", mode); - return al::nullopt; + return std::nullopt; } ALenum EnumFromStereoMode(SourceStereo mode) { @@ -818,7 +818,7 @@ ALenum EnumFromStereoMode(SourceStereo mode) throw std::runtime_error{"Invalid SourceStereo: "+std::to_string(int(mode))}; } -al::optional<SpatializeMode> SpatializeModeFromEnum(ALenum mode) +std::optional<SpatializeMode> SpatializeModeFromEnum(ALenum mode) { switch(mode) { @@ -827,7 +827,7 @@ al::optional<SpatializeMode> SpatializeModeFromEnum(ALenum mode) case AL_AUTO_SOFT: return SpatializeMode::Auto; } WARN("Unsupported spatialize mode: 0x%04x\n", mode); - return al::nullopt; + return std::nullopt; } ALenum EnumFromSpatializeMode(SpatializeMode mode) { @@ -840,7 +840,7 @@ ALenum EnumFromSpatializeMode(SpatializeMode mode) throw std::runtime_error{"Invalid SpatializeMode: "+std::to_string(int(mode))}; } -al::optional<DirectMode> DirectModeFromEnum(ALenum mode) +std::optional<DirectMode> DirectModeFromEnum(ALenum mode) { switch(mode) { @@ -849,7 +849,7 @@ al::optional<DirectMode> DirectModeFromEnum(ALenum mode) case AL_REMIX_UNMATCHED_SOFT: return DirectMode::RemixMismatch; } WARN("Unsupported direct mode: 0x%04x\n", mode); - return al::nullopt; + return std::nullopt; } ALenum EnumFromDirectMode(DirectMode mode) { @@ -862,7 +862,7 @@ ALenum EnumFromDirectMode(DirectMode mode) throw std::runtime_error{"Invalid DirectMode: "+std::to_string(int(mode))}; } -al::optional<DistanceModel> DistanceModelFromALenum(ALenum model) +std::optional<DistanceModel> DistanceModelFromALenum(ALenum model) { switch(model) { @@ -874,7 +874,7 @@ al::optional<DistanceModel> DistanceModelFromALenum(ALenum model) case AL_EXPONENT_DISTANCE: return DistanceModel::Exponent; case AL_EXPONENT_DISTANCE_CLAMPED: return DistanceModel::ExponentClamped; } - return al::nullopt; + return std::nullopt; } ALenum ALenumFromDistanceModel(DistanceModel model) { diff --git a/al/state.cpp b/al/state.cpp index efc6398d..77b104a4 100644 --- a/al/state.cpp +++ b/al/state.cpp @@ -26,6 +26,7 @@ #include <cmath> #include <cstring> #include <mutex> +#include <optional> #include <stdexcept> #include <string> @@ -38,7 +39,6 @@ #include "alc/context.h" #include "alc/inprogext.h" #include "alnumeric.h" -#include "aloptional.h" #include "atomic.h" #include "core/context.h" #include "core/except.h" @@ -107,7 +107,7 @@ const ALchar *GetResamplerName(const Resampler rtype) throw std::runtime_error{"Unexpected resampler index"}; } -al::optional<DistanceModel> DistanceModelFromALenum(ALenum model) +std::optional<DistanceModel> DistanceModelFromALenum(ALenum model) { switch(model) { @@ -119,7 +119,7 @@ al::optional<DistanceModel> DistanceModelFromALenum(ALenum model) case AL_EXPONENT_DISTANCE: return DistanceModel::Exponent; case AL_EXPONENT_DISTANCE_CLAMPED: return DistanceModel::ExponentClamped; } - return al::nullopt; + return std::nullopt; } ALenum ALenumFromDistanceModel(DistanceModel model) { diff --git a/alc/alc.cpp b/alc/alc.cpp index 8932a084..2da5c5db 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -48,6 +48,7 @@ #include <memory> #include <mutex> #include <new> +#include <optional> #include <stddef.h> #include <stdexcept> #include <string> @@ -71,7 +72,6 @@ #include "alconfig.h" #include "almalloc.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "alstring.h" #include "alu.h" @@ -1443,7 +1443,7 @@ void ProbeCaptureDeviceList() struct DevFmtPair { DevFmtChannels chans; DevFmtType type; }; -al::optional<DevFmtPair> DecomposeDevFormat(ALenum format) +std::optional<DevFmtPair> DecomposeDevFormat(ALenum format) { static const struct { ALenum format; @@ -1478,13 +1478,13 @@ al::optional<DevFmtPair> DecomposeDevFormat(ALenum format) for(const auto &item : list) { if(item.format == format) - return al::make_optional<DevFmtPair>({item.channels, item.type}); + return DevFmtPair{item.channels, item.type}; } - return al::nullopt; + return std::nullopt; } -al::optional<DevFmtType> DevFmtTypeFromEnum(ALCenum type) +std::optional<DevFmtType> DevFmtTypeFromEnum(ALCenum type) { switch(type) { @@ -1497,7 +1497,7 @@ al::optional<DevFmtType> DevFmtTypeFromEnum(ALCenum type) case ALC_FLOAT_SOFT: return DevFmtFloat; } WARN("Unsupported format type: 0x%04x\n", type); - return al::nullopt; + return std::nullopt; } ALCenum EnumFromDevFmt(DevFmtType type) { @@ -1514,7 +1514,7 @@ ALCenum EnumFromDevFmt(DevFmtType type) throw std::runtime_error{"Invalid DevFmtType: "+std::to_string(int(type))}; } -al::optional<DevFmtChannels> DevFmtChannelsFromEnum(ALCenum channels) +std::optional<DevFmtChannels> DevFmtChannelsFromEnum(ALCenum channels) { switch(channels) { @@ -1527,7 +1527,7 @@ al::optional<DevFmtChannels> DevFmtChannelsFromEnum(ALCenum channels) case ALC_BFORMAT3D_SOFT: return DevFmtAmbi3D; } WARN("Unsupported format channels: 0x%04x\n", channels); - return al::nullopt; + return std::nullopt; } ALCenum EnumFromDevFmt(DevFmtChannels channels) { @@ -1547,7 +1547,7 @@ ALCenum EnumFromDevFmt(DevFmtChannels channels) throw std::runtime_error{"Invalid DevFmtChannels: "+std::to_string(int(channels))}; } -al::optional<DevAmbiLayout> DevAmbiLayoutFromEnum(ALCenum layout) +std::optional<DevAmbiLayout> DevAmbiLayoutFromEnum(ALCenum layout) { switch(layout) { @@ -1555,7 +1555,7 @@ al::optional<DevAmbiLayout> DevAmbiLayoutFromEnum(ALCenum layout) case ALC_ACN_SOFT: return DevAmbiLayout::ACN; } WARN("Unsupported ambisonic layout: 0x%04x\n", layout); - return al::nullopt; + return std::nullopt; } ALCenum EnumFromDevAmbi(DevAmbiLayout layout) { @@ -1567,7 +1567,7 @@ ALCenum EnumFromDevAmbi(DevAmbiLayout layout) throw std::runtime_error{"Invalid DevAmbiLayout: "+std::to_string(int(layout))}; } -al::optional<DevAmbiScaling> DevAmbiScalingFromEnum(ALCenum scaling) +std::optional<DevAmbiScaling> DevAmbiScalingFromEnum(ALCenum scaling) { switch(scaling) { @@ -1576,7 +1576,7 @@ al::optional<DevAmbiScaling> DevAmbiScalingFromEnum(ALCenum scaling) case ALC_N3D_SOFT: return DevAmbiScaling::N3D; } WARN("Unsupported ambisonic scaling: 0x%04x\n", scaling); - return al::nullopt; + return std::nullopt; } ALCenum EnumFromDevAmbi(DevAmbiScaling scaling) { @@ -1731,13 +1731,13 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) uint numMono{device->NumMonoSources}; uint numStereo{device->NumStereoSources}; uint numSends{device->NumAuxSends}; - al::optional<StereoEncoding> stereomode; - al::optional<bool> optlimit; - al::optional<uint> optsrate; - al::optional<DevFmtChannels> optchans; - al::optional<DevFmtType> opttype; - al::optional<DevAmbiLayout> optlayout; - al::optional<DevAmbiScaling> optscale; + std::optional<StereoEncoding> stereomode; + std::optional<bool> optlimit; + std::optional<uint> optsrate; + std::optional<DevFmtChannels> optchans; + std::optional<DevFmtType> opttype; + std::optional<DevAmbiLayout> optlayout; + std::optional<DevAmbiScaling> optscale; uint period_size{DEFAULT_UPDATE_SIZE}; uint buffer_size{DEFAULT_UPDATE_SIZE * DEFAULT_NUM_UPDATES}; int hrtf_id{-1}; @@ -1880,7 +1880,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) if(attrList && attrList[0]) { ALenum outmode{ALC_ANY_SOFT}; - al::optional<bool> opthrtf; + std::optional<bool> opthrtf; int freqAttr{}; #define ATTRIBUTE(a) a: TRACE("%s = %d\n", #a, attrList[attrIdx + 1]); @@ -1940,7 +1940,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) else if(attrList[attrIdx + 1] == ALC_TRUE) opthrtf = true; else if(attrList[attrIdx + 1] == ALC_DONT_CARE_SOFT) - opthrtf = al::nullopt; + opthrtf = std::nullopt; break; case ATTRIBUTE(ALC_HRTF_ID_SOFT) @@ -1953,7 +1953,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) else if(attrList[attrIdx + 1] == ALC_TRUE) optlimit = true; else if(attrList[attrIdx + 1] == ALC_DONT_CARE_SOFT) - optlimit = al::nullopt; + optlimit = std::nullopt; break; case ATTRIBUTE(ALC_OUTPUT_MODE_SOFT) diff --git a/alc/alconfig.cpp b/alc/alconfig.cpp index b0544b89..56cad9e0 100644 --- a/alc/alconfig.cpp +++ b/alc/alconfig.cpp @@ -52,7 +52,7 @@ struct ConfigEntry { std::string key; std::string value; }; -al::vector<ConfigEntry> ConfOpts; +std::vector<ConfigEntry> ConfOpts; std::string &lstrip(std::string &line) @@ -483,40 +483,40 @@ void ReadALConfig() } #endif -al::optional<std::string> ConfigValueStr(const char *devName, const char *blockName, const char *keyName) +std::optional<std::string> ConfigValueStr(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) return val; - return al::nullopt; + return std::nullopt; } -al::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName) +std::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) return static_cast<int>(std::strtol(val, nullptr, 0)); - return al::nullopt; + return std::nullopt; } -al::optional<unsigned int> ConfigValueUInt(const char *devName, const char *blockName, const char *keyName) +std::optional<unsigned int> ConfigValueUInt(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) return static_cast<unsigned int>(std::strtoul(val, nullptr, 0)); - return al::nullopt; + return std::nullopt; } -al::optional<float> ConfigValueFloat(const char *devName, const char *blockName, const char *keyName) +std::optional<float> ConfigValueFloat(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) return std::strtof(val, nullptr); - return al::nullopt; + return std::nullopt; } -al::optional<bool> ConfigValueBool(const char *devName, const char *blockName, const char *keyName) +std::optional<bool> ConfigValueBool(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) return al::strcasecmp(val, "on") == 0 || al::strcasecmp(val, "yes") == 0 || al::strcasecmp(val, "true")==0 || atoi(val) != 0; - return al::nullopt; + return std::nullopt; } bool GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, bool def) diff --git a/alc/alconfig.h b/alc/alconfig.h index df2830cc..1eb44405 100644 --- a/alc/alconfig.h +++ b/alc/alconfig.h @@ -1,18 +1,18 @@ #ifndef ALCONFIG_H #define ALCONFIG_H +#include <optional> #include <string> -#include "aloptional.h" void ReadALConfig(); bool GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, bool def); -al::optional<std::string> ConfigValueStr(const char *devName, const char *blockName, const char *keyName); -al::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName); -al::optional<unsigned int> ConfigValueUInt(const char *devName, const char *blockName, const char *keyName); -al::optional<float> ConfigValueFloat(const char *devName, const char *blockName, const char *keyName); -al::optional<bool> ConfigValueBool(const char *devName, const char *blockName, const char *keyName); +std::optional<std::string> ConfigValueStr(const char *devName, const char *blockName, const char *keyName); +std::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName); +std::optional<unsigned int> ConfigValueUInt(const char *devName, const char *blockName, const char *keyName); +std::optional<float> ConfigValueFloat(const char *devName, const char *blockName, const char *keyName); +std::optional<bool> ConfigValueBool(const char *devName, const char *blockName, const char *keyName); #endif /* ALCONFIG_H */ diff --git a/alc/alu.cpp b/alc/alu.cpp index e9ad68b1..fc22febb 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -36,6 +36,7 @@ #include <limits> #include <memory> #include <new> +#include <optional> #include <stdint.h> #include <utility> @@ -2,8 +2,7 @@ #define ALU_H #include <bitset> - -#include "aloptional.h" +#include <optional> struct ALCcontext; struct ALCdevice; @@ -31,7 +30,7 @@ void aluInit(CompatFlagBitset flags, const float nfcscale); * Set up the appropriate panning method and mixing method given the device * properties. */ -void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<StereoEncoding> stereomode); +void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional<StereoEncoding> stereomode); void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context); diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index d620a83c..01021868 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -39,7 +39,6 @@ #include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" -#include "aloptional.h" #include "core/device.h" #include "core/helpers.h" #include "core/logging.h" diff --git a/alc/backends/base.cpp b/alc/backends/base.cpp index e5ad8494..45254c47 100644 --- a/alc/backends/base.cpp +++ b/alc/backends/base.cpp @@ -14,7 +14,6 @@ #include "albit.h" #include "core/logging.h" -#include "aloptional.h" #endif #include "atomic.h" diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp index 6d4fa261..f76024f4 100644 --- a/alc/backends/oss.cpp +++ b/alc/backends/oss.cpp @@ -45,7 +45,6 @@ #include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" -#include "aloptional.h" #include "core/device.h" #include "core/helpers.h" #include "core/logging.h" diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index c6569a74..d3c8e77e 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -31,6 +31,7 @@ #include <list> #include <memory> #include <mutex> +#include <optional> #include <stdint.h> #include <thread> #include <type_traits> @@ -40,7 +41,6 @@ #include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "alstring.h" #include "core/devformat.h" @@ -304,12 +304,12 @@ al::span<const Pod_t<T>> get_array_span(const spa_pod *pod) } template<uint32_t T> -al::optional<Pod_t<T>> get_value(const spa_pod *value) +std::optional<Pod_t<T>> get_value(const spa_pod *value) { Pod_t<T> val{}; if(PodInfo<T>::get_value(value, &val) == 0) return val; - return al::nullopt; + return std::nullopt; } /* Internally, PipeWire types "inherit" from each other, but this is hidden @@ -997,7 +997,7 @@ int MetadataProxy::propertyCallback(uint32_t id, const char *key, const char *ty auto get_json_string = [](spa_json *iter) { - al::optional<std::string> str; + std::optional<std::string> str; const char *val{}; int len{spa_json_next(iter, &val)}; diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index 4b0e316f..6f706c7f 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -31,6 +31,7 @@ #include <cstring> #include <limits> #include <mutex> +#include <optional> #include <stdint.h> #include <stdlib.h> #include <string> @@ -41,7 +42,6 @@ #include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "core/devformat.h" #include "core/device.h" @@ -615,7 +615,7 @@ struct PulsePlayback final : public BackendBase { PulseMainloop mMainloop; - al::optional<std::string> mDeviceName{al::nullopt}; + std::optional<std::string> mDeviceName{std::nullopt}; bool mIs51Rear{false}; pa_buffer_attr mAttr; @@ -1042,7 +1042,7 @@ struct PulseCapture final : public BackendBase { PulseMainloop mMainloop; - al::optional<std::string> mDeviceName{al::nullopt}; + std::optional<std::string> mDeviceName{std::nullopt}; al::span<const al::byte> mCapBuffer; size_t mHoleLength{0}; diff --git a/alc/device.h b/alc/device.h index ef50f53e..d5e82ce3 100644 --- a/alc/device.h +++ b/alc/device.h @@ -4,6 +4,7 @@ #include <atomic> #include <memory> #include <mutex> +#include <optional> #include <stdint.h> #include <string> #include <utility> @@ -141,25 +142,25 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice>, DeviceBase { { return GetConfigValueBool(DeviceName.c_str(), block, key, def); } template<typename T> - inline al::optional<T> configValue(const char *block, const char *key) = delete; + inline std::optional<T> configValue(const char *block, const char *key) = delete; DEF_NEWDEL(ALCdevice) }; template<> -inline al::optional<std::string> ALCdevice::configValue(const char *block, const char *key) +inline std::optional<std::string> ALCdevice::configValue(const char *block, const char *key) { return ConfigValueStr(DeviceName.c_str(), block, key); } template<> -inline al::optional<int> ALCdevice::configValue(const char *block, const char *key) +inline std::optional<int> ALCdevice::configValue(const char *block, const char *key) { return ConfigValueInt(DeviceName.c_str(), block, key); } template<> -inline al::optional<uint> ALCdevice::configValue(const char *block, const char *key) +inline std::optional<uint> ALCdevice::configValue(const char *block, const char *key) { return ConfigValueUInt(DeviceName.c_str(), block, key); } template<> -inline al::optional<float> ALCdevice::configValue(const char *block, const char *key) +inline std::optional<float> ALCdevice::configValue(const char *block, const char *key) { return ConfigValueFloat(DeviceName.c_str(), block, key); } template<> -inline al::optional<bool> ALCdevice::configValue(const char *block, const char *key) +inline std::optional<bool> ALCdevice::configValue(const char *block, const char *key) { return ConfigValueBool(DeviceName.c_str(), block, key); } #endif diff --git a/alc/panning.cpp b/alc/panning.cpp index d118f99c..a3d639fc 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -32,6 +32,7 @@ #include <memory> #include <new> #include <numeric> +#include <optional> #include <string> #include "AL/al.h" @@ -45,7 +46,6 @@ #include "almalloc.h" #include "alnumbers.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "alstring.h" #include "alu.h" @@ -933,7 +933,7 @@ void InitUhjPanning(ALCdevice *device) } // namespace -void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<StereoEncoding> stereomode) +void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional<StereoEncoding> stereomode) { /* Hold the HRTF the device last used, in case it's used again. */ HrtfStorePtr old_hrtf{std::move(device->mHrtf)}; diff --git a/common/aloptional.h b/common/aloptional.h deleted file mode 100644 index 45b0cf8a..00000000 --- a/common/aloptional.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef AL_OPTIONAL_H -#define AL_OPTIONAL_H - -#include <optional> - -namespace al { - -constexpr auto nullopt = std::nullopt; - -template<typename T> -using optional = std::optional<T>; - -using std::make_optional; - -} // namespace al - -#endif /* AL_OPTIONAL_H */ diff --git a/common/strutils.cpp b/common/strutils.cpp index d0418eff..b221b6ec 100644 --- a/common/strutils.cpp +++ b/common/strutils.cpp @@ -43,21 +43,21 @@ std::wstring utf8_to_wstr(const char *str) namespace al { -al::optional<std::string> getenv(const char *envname) +std::optional<std::string> getenv(const char *envname) { const char *str{std::getenv(envname)}; if(str && str[0] != '\0') return str; - return al::nullopt; + return std::nullopt; } #ifdef _WIN32 -al::optional<std::wstring> getenv(const WCHAR *envname) +std::optional<std::wstring> getenv(const WCHAR *envname) { const WCHAR *str{_wgetenv(envname)}; if(str && str[0] != L'\0') return str; - return al::nullopt; + return std::nullopt; } #endif diff --git a/common/strutils.h b/common/strutils.h index 0c7a0e22..67f057a7 100644 --- a/common/strutils.h +++ b/common/strutils.h @@ -1,10 +1,9 @@ #ifndef AL_STRUTILS_H #define AL_STRUTILS_H +#include <optional> #include <string> -#include "aloptional.h" - #ifdef _WIN32 #include <wchar.h> @@ -14,9 +13,9 @@ std::wstring utf8_to_wstr(const char *str); namespace al { -al::optional<std::string> getenv(const char *envname); +std::optional<std::string> getenv(const char *envname); #ifdef _WIN32 -al::optional<std::wstring> getenv(const wchar_t *envname); +std::optional<std::wstring> getenv(const wchar_t *envname); #endif } // namespace al diff --git a/core/ambdec.cpp b/core/ambdec.cpp index 8ca182c4..a056e63f 100644 --- a/core/ambdec.cpp +++ b/core/ambdec.cpp @@ -47,9 +47,9 @@ enum class ReaderScope { #else [[gnu::format(printf,2,3)]] #endif -al::optional<std::string> make_error(size_t linenum, const char *fmt, ...) +std::optional<std::string> make_error(size_t linenum, const char *fmt, ...) { - al::optional<std::string> ret; + std::optional<std::string> ret; auto &str = ret.emplace(); str.resize(256); @@ -77,7 +77,7 @@ al::optional<std::string> make_error(size_t linenum, const char *fmt, ...) AmbDecConf::~AmbDecConf() = default; -al::optional<std::string> AmbDecConf::load(const char *fname) noexcept +std::optional<std::string> AmbDecConf::load(const char *fname) noexcept { al::ifstream f{fname}; if(!f.is_open()) @@ -291,7 +291,7 @@ al::optional<std::string> AmbDecConf::load(const char *fname) noexcept if(CoeffScale == AmbDecScale::Unset) return make_error(linenum, "No coefficient scaling defined"); - return al::nullopt; + return std::nullopt; } else return make_error(linenum, "Unexpected command: %s", command.c_str()); diff --git a/core/ambdec.h b/core/ambdec.h index 7f739781..19f68697 100644 --- a/core/ambdec.h +++ b/core/ambdec.h @@ -3,9 +3,9 @@ #include <array> #include <memory> +#include <optional> #include <string> -#include "aloptional.h" #include "core/ambidefs.h" /* Helpers to read .ambdec configuration files. */ @@ -49,7 +49,7 @@ struct AmbDecConf { ~AmbDecConf(); - al::optional<std::string> load(const char *fname) noexcept; + std::optional<std::string> load(const char *fname) noexcept; }; #endif /* CORE_AMBDEC_H */ diff --git a/core/cpu_caps.cpp b/core/cpu_caps.cpp index 165edb24..1a064cf4 100644 --- a/core/cpu_caps.cpp +++ b/core/cpu_caps.cpp @@ -51,14 +51,14 @@ inline std::array<reg_type,4> get_cpuid(unsigned int f) } // namespace -al::optional<CPUInfo> GetCPUInfo() +std::optional<CPUInfo> GetCPUInfo() { CPUInfo ret; #ifdef CAN_GET_CPUID auto cpuregs = get_cpuid(0); if(cpuregs[0] == 0) - return al::nullopt; + return std::nullopt; const reg_type maxfunc{cpuregs[0]}; diff --git a/core/cpu_caps.h b/core/cpu_caps.h index ffd671d0..0826a49b 100644 --- a/core/cpu_caps.h +++ b/core/cpu_caps.h @@ -1,10 +1,9 @@ #ifndef CORE_CPU_CAPS_H #define CORE_CPU_CAPS_H +#include <optional> #include <string> -#include "aloptional.h" - extern int CPUCapFlags; enum { @@ -21,6 +20,6 @@ struct CPUInfo { int mCaps{0}; }; -al::optional<CPUInfo> GetCPUInfo(); +std::optional<CPUInfo> GetCPUInfo(); #endif /* CORE_CPU_CAPS_H */ diff --git a/core/helpers.cpp b/core/helpers.cpp index 71ddbc23..58cc74e5 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -9,15 +9,15 @@ #include <cstdlib> #include <cstdio> #include <cstring> -#include <mutex> #include <limits> +#include <mutex> +#include <optional> #include <string> #include <tuple> #include "almalloc.h" #include "alfstream.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "alstring.h" #include "logging.h" @@ -38,7 +38,7 @@ bool AllowRTTimeLimit{true}; const PathNamePair &GetProcBinary() { - static al::optional<PathNamePair> procbin; + static std::optional<PathNamePair> procbin; if(procbin) return *procbin; auto fullpath = std::vector<WCHAR>(256); @@ -209,7 +209,7 @@ void SetRTPriority(void) const PathNamePair &GetProcBinary() { - static al::optional<PathNamePair> procbin; + static std::optional<PathNamePair> procbin; if(procbin) return *procbin; std::vector<char> pathname; diff --git a/core/hrtf.cpp b/core/hrtf.cpp index cdafe93c..c54d96d1 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -16,6 +16,7 @@ #include <memory> #include <mutex> #include <numeric> +#include <optional> #include <type_traits> #include <utility> @@ -25,7 +26,6 @@ #include "almalloc.h" #include "alnumbers.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "ambidefs.h" #include "filters/splitter.h" @@ -1221,7 +1221,7 @@ al::span<const char> GetResource(int name) } // namespace -al::vector<std::string> EnumerateHrtf(al::optional<std::string> pathopt) +al::vector<std::string> EnumerateHrtf(std::optional<std::string> pathopt) { std::lock_guard<std::mutex> _{EnumeratedHrtfLock}; EnumeratedHrtfs.clear(); diff --git a/core/hrtf.h b/core/hrtf.h index eb18682a..7215711b 100644 --- a/core/hrtf.h +++ b/core/hrtf.h @@ -4,10 +4,10 @@ #include <array> #include <cstddef> #include <memory> +#include <optional> #include <string> #include "almalloc.h" -#include "aloptional.h" #include "alspan.h" #include "atomic.h" #include "ambidefs.h" @@ -83,7 +83,7 @@ struct DirectHrtfState { }; -al::vector<std::string> EnumerateHrtf(al::optional<std::string> pathopt); +al::vector<std::string> EnumerateHrtf(std::optional<std::string> pathopt); HrtfStorePtr GetLoadedHrtf(const std::string &name, const uint devrate); #endif /* CORE_HRTF_H */ diff --git a/core/voice.cpp b/core/voice.cpp index 6a747f85..090b10a3 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -12,13 +12,13 @@ #include <iterator> #include <memory> #include <new> +#include <optional> #include <stdlib.h> #include <utility> #include <vector> #include "albyte.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "alstring.h" #include "ambidefs.h" @@ -129,7 +129,7 @@ inline HrtfMixerBlendFunc SelectHrtfBlendMixer() } // namespace -void Voice::InitMixer(al::optional<std::string> resampler) +void Voice::InitMixer(std::optional<std::string> resampler) { if(resampler) { diff --git a/core/voice.h b/core/voice.h index 57ee7b01..9d74ff6b 100644 --- a/core/voice.h +++ b/core/voice.h @@ -6,12 +6,12 @@ #include <bitset> #include <chrono> #include <memory> +#include <optional> #include <stddef.h> #include <string> #include "albyte.h" #include "almalloc.h" -#include "aloptional.h" #include "alspan.h" #include "bufferline.h" #include "buffer_storage.h" @@ -270,7 +270,7 @@ struct Voice { void prepare(DeviceBase *device); - static void InitMixer(al::optional<std::string> resampler); + static void InitMixer(std::optional<std::string> resampler); DEF_NEWDEL(Voice) }; diff --git a/utils/makemhr/loaddef.cpp b/utils/makemhr/loaddef.cpp index e8092363..84fbb48b 100644 --- a/utils/makemhr/loaddef.cpp +++ b/utils/makemhr/loaddef.cpp @@ -33,11 +33,10 @@ #include <iterator> #include <limits> #include <memory> -#include <cstdarg> +#include <optional> #include <vector> #include "alfstream.h" -#include "aloptional.h" #include "alspan.h" #include "alstring.h" #include "makemhr.h" @@ -1755,7 +1754,7 @@ static int ProcessSources(TokenReaderT *tr, HrirDataT *hData, const uint outRate PPhaseResampler onsetResampler; onsetResampler.init(hData->mIrRate, OnsetRateMultiple*hData->mIrRate); - al::optional<PPhaseResampler> resampler; + std::optional<PPhaseResampler> resampler; if(outRate && outRate != hData->mIrRate) resampler.emplace().init(hData->mIrRate, outRate); const double rateScale{outRate ? static_cast<double>(outRate) / hData->mIrRate : 1.0}; diff --git a/utils/makemhr/loadsofa.cpp b/utils/makemhr/loadsofa.cpp index dcb0a35e..9e661839 100644 --- a/utils/makemhr/loadsofa.cpp +++ b/utils/makemhr/loadsofa.cpp @@ -33,11 +33,11 @@ #include <iterator> #include <memory> #include <numeric> +#include <optional> #include <string> #include <thread> #include <vector> -#include "aloptional.h" #include "alspan.h" #include "makemhr.h" #include "polyphase_resampler.h" @@ -265,7 +265,7 @@ static bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayTy double *hrirs = hData->mHrirsBase.data(); std::unique_ptr<double[]> restmp; - al::optional<PPhaseResampler> resampler; + std::optional<PPhaseResampler> resampler; if(outRate && outRate != hData->mIrRate) { resampler.emplace().init(hData->mIrRate, outRate); |