diff options
author | Chris Robinson <[email protected]> | 2023-05-04 08:03:40 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-05-04 08:03:40 -0700 |
commit | 7cda37a67c8f147536c53f0073df9a9e61d40587 (patch) | |
tree | 68a0997c94ec905dd3438f26418234bf63aa76f4 /al | |
parent | 40483b512218bab50fccaaeb11b51e5ca528fbe1 (diff) |
Replace al::optional with std::optional
Diffstat (limited to 'al')
-rw-r--r-- | al/buffer.cpp | 20 | ||||
-rw-r--r-- | al/debug.cpp | 14 | ||||
-rw-r--r-- | al/eax/fx_slot_index.h | 7 | ||||
-rw-r--r-- | al/effects/chorus.cpp | 6 | ||||
-rw-r--r-- | al/effects/fshifter.cpp | 6 | ||||
-rw-r--r-- | al/effects/modulator.cpp | 6 | ||||
-rw-r--r-- | al/effects/vmorpher.cpp | 10 | ||||
-rw-r--r-- | al/source.cpp | 30 | ||||
-rw-r--r-- | al/state.cpp | 6 |
9 files changed, 52 insertions, 53 deletions
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) { |