aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-04 08:03:40 -0700
committerChris Robinson <[email protected]>2023-05-04 08:03:40 -0700
commit7cda37a67c8f147536c53f0073df9a9e61d40587 (patch)
tree68a0997c94ec905dd3438f26418234bf63aa76f4 /alc
parent40483b512218bab50fccaaeb11b51e5ca528fbe1 (diff)
Replace al::optional with std::optional
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp44
-rw-r--r--alc/alconfig.cpp22
-rw-r--r--alc/alconfig.h12
-rw-r--r--alc/alu.cpp1
-rw-r--r--alc/alu.h5
-rw-r--r--alc/backends/alsa.cpp1
-rw-r--r--alc/backends/base.cpp1
-rw-r--r--alc/backends/oss.cpp1
-rw-r--r--alc/backends/pipewire.cpp8
-rw-r--r--alc/backends/pulseaudio.cpp6
-rw-r--r--alc/device.h13
-rw-r--r--alc/panning.cpp4
12 files changed, 58 insertions, 60 deletions
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>
diff --git a/alc/alu.h b/alc/alu.h
index 67fd09e5..253940cf 100644
--- a/alc/alu.h
+++ b/alc/alu.h
@@ -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)};