diff options
-rw-r--r-- | al/buffer.cpp | 46 | ||||
-rw-r--r-- | al/effects/chorus.cpp | 4 | ||||
-rw-r--r-- | al/effects/fshifter.cpp | 6 | ||||
-rw-r--r-- | al/effects/modulator.cpp | 6 | ||||
-rw-r--r-- | al/effects/vmorpher.cpp | 8 | ||||
-rw-r--r-- | al/source.cpp | 30 | ||||
-rw-r--r-- | al/state.cpp | 14 | ||||
-rw-r--r-- | alc/alc.cpp | 40 | ||||
-rw-r--r-- | alc/alconfig.cpp | 12 | ||||
-rw-r--r-- | alc/backends/pulseaudio.cpp | 6 | ||||
-rw-r--r-- | common/strutils.cpp | 4 | ||||
-rw-r--r-- | core/ambdec.cpp | 2 | ||||
-rw-r--r-- | core/cpu_caps.cpp | 2 | ||||
-rw-r--r-- | core/helpers.cpp | 2 |
14 files changed, 92 insertions, 90 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp index 93daf4f5..6bf3ecbc 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -288,8 +288,8 @@ al::optional<AmbiLayout> AmbiLayoutFromEnum(ALenum layout) { switch(layout) { - case AL_FUMA_SOFT: return al::make_optional(AmbiLayout::FuMa); - case AL_ACN_SOFT: return al::make_optional(AmbiLayout::ACN); + case AL_FUMA_SOFT: return AmbiLayout::FuMa; + case AL_ACN_SOFT: return AmbiLayout::ACN; } return al::nullopt; } @@ -307,9 +307,9 @@ al::optional<AmbiScaling> AmbiScalingFromEnum(ALenum scale) { switch(scale) { - case AL_FUMA_SOFT: return al::make_optional(AmbiScaling::FuMa); - case AL_SN3D_SOFT: return al::make_optional(AmbiScaling::SN3D); - case AL_N3D_SOFT: return al::make_optional(AmbiScaling::N3D); + case AL_FUMA_SOFT: return AmbiScaling::FuMa; + case AL_SN3D_SOFT: return AmbiScaling::SN3D; + case AL_N3D_SOFT: return AmbiScaling::N3D; } return al::nullopt; } @@ -329,18 +329,18 @@ al::optional<FmtChannels> FmtFromUserFmt(UserFmtChannels chans) { switch(chans) { - case UserFmtMono: return al::make_optional(FmtMono); - case UserFmtStereo: return al::make_optional(FmtStereo); - case UserFmtRear: return al::make_optional(FmtRear); - case UserFmtQuad: return al::make_optional(FmtQuad); - case UserFmtX51: return al::make_optional(FmtX51); - case UserFmtX61: return al::make_optional(FmtX61); - case UserFmtX71: return al::make_optional(FmtX71); - case UserFmtBFormat2D: return al::make_optional(FmtBFormat2D); - case UserFmtBFormat3D: return al::make_optional(FmtBFormat3D); - case UserFmtUHJ2: return al::make_optional(FmtUHJ2); - case UserFmtUHJ3: return al::make_optional(FmtUHJ3); - case UserFmtUHJ4: return al::make_optional(FmtUHJ4); + case UserFmtMono: return FmtMono; + case UserFmtStereo: return FmtStereo; + case UserFmtRear: return FmtRear; + case UserFmtQuad: return FmtQuad; + case UserFmtX51: return FmtX51; + case UserFmtX61: return FmtX61; + case UserFmtX71: return FmtX71; + case UserFmtBFormat2D: return FmtBFormat2D; + case UserFmtBFormat3D: return FmtBFormat3D; + case UserFmtUHJ2: return FmtUHJ2; + case UserFmtUHJ3: return FmtUHJ3; + case UserFmtUHJ4: return FmtUHJ4; } return al::nullopt; } @@ -348,12 +348,12 @@ al::optional<FmtType> FmtFromUserFmt(UserFmtType type) { switch(type) { - case UserFmtUByte: return al::make_optional(FmtUByte); - case UserFmtShort: return al::make_optional(FmtShort); - case UserFmtFloat: return al::make_optional(FmtFloat); - case UserFmtDouble: return al::make_optional(FmtDouble); - case UserFmtMulaw: return al::make_optional(FmtMulaw); - case UserFmtAlaw: return al::make_optional(FmtAlaw); + case UserFmtUByte: return FmtUByte; + case UserFmtShort: return FmtShort; + case UserFmtFloat: return FmtFloat; + case UserFmtDouble: return FmtDouble; + case UserFmtMulaw: return FmtMulaw; + case UserFmtAlaw: return FmtAlaw; /* ADPCM not handled here. */ case UserFmtIMA4: break; case UserFmtMSADPCM: break; diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp index 1651ebb9..a05ec10b 100644 --- a/al/effects/chorus.cpp +++ b/al/effects/chorus.cpp @@ -31,8 +31,8 @@ inline al::optional<ChorusWaveform> WaveformFromEnum(ALenum type) { switch(type) { - case AL_CHORUS_WAVEFORM_SINUSOID: return al::make_optional(ChorusWaveform::Sinusoid); - case AL_CHORUS_WAVEFORM_TRIANGLE: return al::make_optional(ChorusWaveform::Triangle); + case AL_CHORUS_WAVEFORM_SINUSOID: return ChorusWaveform::Sinusoid; + case AL_CHORUS_WAVEFORM_TRIANGLE: return ChorusWaveform::Triangle; } return al::nullopt; } diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp index 400c0bf4..9ca28775 100644 --- a/al/effects/fshifter.cpp +++ b/al/effects/fshifter.cpp @@ -24,9 +24,9 @@ al::optional<FShifterDirection> DirectionFromEmum(ALenum value) { switch(value) { - case AL_FREQUENCY_SHIFTER_DIRECTION_DOWN: return al::make_optional(FShifterDirection::Down); - case AL_FREQUENCY_SHIFTER_DIRECTION_UP: return al::make_optional(FShifterDirection::Up); - case AL_FREQUENCY_SHIFTER_DIRECTION_OFF: return al::make_optional(FShifterDirection::Off); + case AL_FREQUENCY_SHIFTER_DIRECTION_DOWN: return FShifterDirection::Down; + case AL_FREQUENCY_SHIFTER_DIRECTION_UP: return FShifterDirection::Up; + case AL_FREQUENCY_SHIFTER_DIRECTION_OFF: return FShifterDirection::Off; } return al::nullopt; } diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp index e917e3a0..070b0998 100644 --- a/al/effects/modulator.cpp +++ b/al/effects/modulator.cpp @@ -24,9 +24,9 @@ al::optional<ModulatorWaveform> WaveformFromEmum(ALenum value) { switch(value) { - case AL_RING_MODULATOR_SINUSOID: return al::make_optional(ModulatorWaveform::Sinusoid); - case AL_RING_MODULATOR_SAWTOOTH: return al::make_optional(ModulatorWaveform::Sawtooth); - case AL_RING_MODULATOR_SQUARE: return al::make_optional(ModulatorWaveform::Square); + case AL_RING_MODULATOR_SINUSOID: return ModulatorWaveform::Sinusoid; + case AL_RING_MODULATOR_SAWTOOTH: return ModulatorWaveform::Sawtooth; + case AL_RING_MODULATOR_SQUARE: return ModulatorWaveform::Square; } return al::nullopt; } diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp index e1b7a698..e26c6fe3 100644 --- a/al/effects/vmorpher.cpp +++ b/al/effects/vmorpher.cpp @@ -23,7 +23,7 @@ namespace { al::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val) { #define HANDLE_PHENOME(x) case AL_VOCAL_MORPHER_PHONEME_ ## x: \ - return al::make_optional(VMorpherPhenome::x) + return VMorpherPhenome::x switch(val) { HANDLE_PHENOME(A); @@ -104,9 +104,9 @@ al::optional<VMorpherWaveform> WaveformFromEmum(ALenum value) { switch(value) { - case AL_VOCAL_MORPHER_WAVEFORM_SINUSOID: return al::make_optional(VMorpherWaveform::Sinusoid); - case AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE: return al::make_optional(VMorpherWaveform::Triangle); - case AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH: return al::make_optional(VMorpherWaveform::Sawtooth); + case AL_VOCAL_MORPHER_WAVEFORM_SINUSOID: return VMorpherWaveform::Sinusoid; + case AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE: return VMorpherWaveform::Triangle; + case AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH: return VMorpherWaveform::Sawtooth; } return al::nullopt; } diff --git a/al/source.cpp b/al/source.cpp index 5d95ba8a..1e4a5a50 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -839,8 +839,8 @@ al::optional<SourceStereo> StereoModeFromEnum(ALenum mode) { switch(mode) { - case AL_NORMAL_SOFT: return al::make_optional(SourceStereo::Normal); - case AL_SUPER_STEREO_SOFT: return al::make_optional(SourceStereo::Enhanced); + case AL_NORMAL_SOFT: return SourceStereo::Normal; + case AL_SUPER_STEREO_SOFT: return SourceStereo::Enhanced; } WARN("Unsupported stereo mode: 0x%04x\n", mode); return al::nullopt; @@ -859,9 +859,9 @@ al::optional<SpatializeMode> SpatializeModeFromEnum(ALenum mode) { switch(mode) { - case AL_FALSE: return al::make_optional(SpatializeMode::Off); - case AL_TRUE: return al::make_optional(SpatializeMode::On); - case AL_AUTO_SOFT: return al::make_optional(SpatializeMode::Auto); + case AL_FALSE: return SpatializeMode::Off; + case AL_TRUE: return SpatializeMode::On; + case AL_AUTO_SOFT: return SpatializeMode::Auto; } WARN("Unsupported spatialize mode: 0x%04x\n", mode); return al::nullopt; @@ -881,9 +881,9 @@ al::optional<DirectMode> DirectModeFromEnum(ALenum mode) { switch(mode) { - case AL_FALSE: return al::make_optional(DirectMode::Off); - case AL_DROP_UNMATCHED_SOFT: return al::make_optional(DirectMode::DropMismatch); - case AL_REMIX_UNMATCHED_SOFT: return al::make_optional(DirectMode::RemixMismatch); + case AL_FALSE: return DirectMode::Off; + case AL_DROP_UNMATCHED_SOFT: return DirectMode::DropMismatch; + case AL_REMIX_UNMATCHED_SOFT: return DirectMode::RemixMismatch; } WARN("Unsupported direct mode: 0x%04x\n", mode); return al::nullopt; @@ -903,13 +903,13 @@ al::optional<DistanceModel> DistanceModelFromALenum(ALenum model) { switch(model) { - case AL_NONE: return al::make_optional(DistanceModel::Disable); - case AL_INVERSE_DISTANCE: return al::make_optional(DistanceModel::Inverse); - case AL_INVERSE_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::InverseClamped); - case AL_LINEAR_DISTANCE: return al::make_optional(DistanceModel::Linear); - case AL_LINEAR_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::LinearClamped); - case AL_EXPONENT_DISTANCE: return al::make_optional(DistanceModel::Exponent); - case AL_EXPONENT_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::ExponentClamped); + case AL_NONE: return DistanceModel::Disable; + case AL_INVERSE_DISTANCE: return DistanceModel::Inverse; + case AL_INVERSE_DISTANCE_CLAMPED: return DistanceModel::InverseClamped; + case AL_LINEAR_DISTANCE: return DistanceModel::Linear; + case AL_LINEAR_DISTANCE_CLAMPED: return DistanceModel::LinearClamped; + case AL_EXPONENT_DISTANCE: return DistanceModel::Exponent; + case AL_EXPONENT_DISTANCE_CLAMPED: return DistanceModel::ExponentClamped; } return al::nullopt; } diff --git a/al/state.cpp b/al/state.cpp index d1c5605d..11202374 100644 --- a/al/state.cpp +++ b/al/state.cpp @@ -107,13 +107,13 @@ al::optional<DistanceModel> DistanceModelFromALenum(ALenum model) { switch(model) { - case AL_NONE: return al::make_optional(DistanceModel::Disable); - case AL_INVERSE_DISTANCE: return al::make_optional(DistanceModel::Inverse); - case AL_INVERSE_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::InverseClamped); - case AL_LINEAR_DISTANCE: return al::make_optional(DistanceModel::Linear); - case AL_LINEAR_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::LinearClamped); - case AL_EXPONENT_DISTANCE: return al::make_optional(DistanceModel::Exponent); - case AL_EXPONENT_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::ExponentClamped); + case AL_NONE: return DistanceModel::Disable; + case AL_INVERSE_DISTANCE: return DistanceModel::Inverse; + case AL_INVERSE_DISTANCE_CLAMPED: return DistanceModel::InverseClamped; + case AL_LINEAR_DISTANCE: return DistanceModel::Linear; + case AL_LINEAR_DISTANCE_CLAMPED: return DistanceModel::LinearClamped; + case AL_EXPONENT_DISTANCE: return DistanceModel::Exponent; + case AL_EXPONENT_DISTANCE_CLAMPED: return DistanceModel::ExponentClamped; } return al::nullopt; } diff --git a/alc/alc.cpp b/alc/alc.cpp index 37b85255..654f3fb2 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1428,7 +1428,7 @@ 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 al::make_optional<DevFmtPair>({item.channels, item.type}); } return al::nullopt; @@ -1438,13 +1438,13 @@ al::optional<DevFmtType> DevFmtTypeFromEnum(ALCenum type) { switch(type) { - case ALC_BYTE_SOFT: return al::make_optional(DevFmtByte); - case ALC_UNSIGNED_BYTE_SOFT: return al::make_optional(DevFmtUByte); - case ALC_SHORT_SOFT: return al::make_optional(DevFmtShort); - case ALC_UNSIGNED_SHORT_SOFT: return al::make_optional(DevFmtUShort); - case ALC_INT_SOFT: return al::make_optional(DevFmtInt); - case ALC_UNSIGNED_INT_SOFT: return al::make_optional(DevFmtUInt); - case ALC_FLOAT_SOFT: return al::make_optional(DevFmtFloat); + case ALC_BYTE_SOFT: return DevFmtByte; + case ALC_UNSIGNED_BYTE_SOFT: return DevFmtUByte; + case ALC_SHORT_SOFT: return DevFmtShort; + case ALC_UNSIGNED_SHORT_SOFT: return DevFmtUShort; + case ALC_INT_SOFT: return DevFmtInt; + case ALC_UNSIGNED_INT_SOFT: return DevFmtUInt; + case ALC_FLOAT_SOFT: return DevFmtFloat; } WARN("Unsupported format type: 0x%04x\n", type); return al::nullopt; @@ -1468,13 +1468,13 @@ al::optional<DevFmtChannels> DevFmtChannelsFromEnum(ALCenum channels) { switch(channels) { - case ALC_MONO_SOFT: return al::make_optional(DevFmtMono); - case ALC_STEREO_SOFT: return al::make_optional(DevFmtStereo); - case ALC_QUAD_SOFT: return al::make_optional(DevFmtQuad); - case ALC_5POINT1_SOFT: return al::make_optional(DevFmtX51); - case ALC_6POINT1_SOFT: return al::make_optional(DevFmtX61); - case ALC_7POINT1_SOFT: return al::make_optional(DevFmtX71); - case ALC_BFORMAT3D_SOFT: return al::make_optional(DevFmtAmbi3D); + case ALC_MONO_SOFT: return DevFmtMono; + case ALC_STEREO_SOFT: return DevFmtStereo; + case ALC_QUAD_SOFT: return DevFmtQuad; + case ALC_5POINT1_SOFT: return DevFmtX51; + case ALC_6POINT1_SOFT: return DevFmtX61; + case ALC_7POINT1_SOFT: return DevFmtX71; + case ALC_BFORMAT3D_SOFT: return DevFmtAmbi3D; } WARN("Unsupported format channels: 0x%04x\n", channels); return al::nullopt; @@ -1501,8 +1501,8 @@ al::optional<DevAmbiLayout> DevAmbiLayoutFromEnum(ALCenum layout) { switch(layout) { - case ALC_FUMA_SOFT: return al::make_optional(DevAmbiLayout::FuMa); - case ALC_ACN_SOFT: return al::make_optional(DevAmbiLayout::ACN); + case ALC_FUMA_SOFT: return DevAmbiLayout::FuMa; + case ALC_ACN_SOFT: return DevAmbiLayout::ACN; } WARN("Unsupported ambisonic layout: 0x%04x\n", layout); return al::nullopt; @@ -1521,9 +1521,9 @@ al::optional<DevAmbiScaling> DevAmbiScalingFromEnum(ALCenum scaling) { switch(scaling) { - case ALC_FUMA_SOFT: return al::make_optional(DevAmbiScaling::FuMa); - case ALC_SN3D_SOFT: return al::make_optional(DevAmbiScaling::SN3D); - case ALC_N3D_SOFT: return al::make_optional(DevAmbiScaling::N3D); + case ALC_FUMA_SOFT: return DevAmbiScaling::FuMa; + case ALC_SN3D_SOFT: return DevAmbiScaling::SN3D; + case ALC_N3D_SOFT: return DevAmbiScaling::N3D; } WARN("Unsupported ambisonic scaling: 0x%04x\n", scaling); return al::nullopt; diff --git a/alc/alconfig.cpp b/alc/alconfig.cpp index 7c1eec6d..14b2580d 100644 --- a/alc/alconfig.cpp +++ b/alc/alconfig.cpp @@ -486,36 +486,36 @@ void ReadALConfig() al::optional<std::string> ConfigValueStr(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional<std::string>(val); + return val; return al::nullopt; } al::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(static_cast<int>(std::strtol(val, nullptr, 0))); + return static_cast<int>(std::strtol(val, nullptr, 0)); return al::nullopt; } al::optional<unsigned int> ConfigValueUInt(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(static_cast<unsigned int>(std::strtoul(val, nullptr, 0))); + return static_cast<unsigned int>(std::strtoul(val, nullptr, 0)); return al::nullopt; } al::optional<float> ConfigValueFloat(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(std::strtof(val, nullptr)); + return std::strtof(val, nullptr); return al::nullopt; } al::optional<bool> ConfigValueBool(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(al::strcasecmp(val, "on") == 0 || al::strcasecmp(val, "yes") == 0 - || al::strcasecmp(val, "true")==0 || atoi(val) != 0); + return al::strcasecmp(val, "on") == 0 || al::strcasecmp(val, "yes") == 0 + || al::strcasecmp(val, "true")==0 || atoi(val) != 0; return al::nullopt; } diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index 5eef8f87..f79e49b0 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -836,7 +836,8 @@ void PulsePlayback::open(const char *name) pa_stream_set_moved_callback(mStream, &PulsePlayback::streamMovedCallbackC, this); mFrameSize = static_cast<uint>(pa_frame_size(pa_stream_get_sample_spec(mStream))); - mDeviceName = pulse_name ? al::make_optional<std::string>(pulse_name) : al::nullopt; + if(pulse_name) mDeviceName.emplace(pulse_name); + else mDeviceName.reset(); if(!dev_name) { pa_operation *op{pa_context_get_sink_info_by_name(mContext, @@ -1251,7 +1252,8 @@ void PulseCapture::open(const char *name) pa_stream_set_moved_callback(mStream, &PulseCapture::streamMovedCallbackC, this); pa_stream_set_state_callback(mStream, &PulseCapture::streamStateCallbackC, this); - mDeviceName = pulse_name ? al::make_optional<std::string>(pulse_name) : al::nullopt; + if(pulse_name) mDeviceName.emplace(pulse_name); + else mDeviceName.reset(); if(mDevice->DeviceName.empty()) { pa_operation *op{pa_context_get_source_info_by_name(mContext, diff --git a/common/strutils.cpp b/common/strutils.cpp index 18c4947a..d0418eff 100644 --- a/common/strutils.cpp +++ b/common/strutils.cpp @@ -47,7 +47,7 @@ al::optional<std::string> getenv(const char *envname) { const char *str{std::getenv(envname)}; if(str && str[0] != '\0') - return al::make_optional<std::string>(str); + return str; return al::nullopt; } @@ -56,7 +56,7 @@ al::optional<std::wstring> getenv(const WCHAR *envname) { const WCHAR *str{_wgetenv(envname)}; if(str && str[0] != L'\0') - return al::make_optional<std::wstring>(str); + return str; return al::nullopt; } #endif diff --git a/core/ambdec.cpp b/core/ambdec.cpp index 83c521c0..52a1df05 100644 --- a/core/ambdec.cpp +++ b/core/ambdec.cpp @@ -81,7 +81,7 @@ al::optional<std::string> AmbDecConf::load(const char *fname) noexcept { al::ifstream f{fname}; if(!f.is_open()) - return al::make_optional(std::string("Failed to open file \"")+fname+"\""); + return std::string("Failed to open file \"")+fname+"\""; ReaderScope scope{ReaderScope::Global}; size_t speaker_pos{0}; diff --git a/core/cpu_caps.cpp b/core/cpu_caps.cpp index 0325cd49..103d2437 100644 --- a/core/cpu_caps.cpp +++ b/core/cpu_caps.cpp @@ -137,5 +137,5 @@ al::optional<CPUInfo> GetCPUInfo() #endif #endif - return al::make_optional(ret); + return ret; } diff --git a/core/helpers.cpp b/core/helpers.cpp index 1670561a..99cf009c 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -51,7 +51,7 @@ const PathNamePair &GetProcBinary() if(len == 0) { ERR("Failed to get process name: error %lu\n", GetLastError()); - procbin = al::make_optional<PathNamePair>(); + procbin.emplace(); return *procbin; } |