Use an optional for ConfigValueStr
This commit is contained in:
parent
db026454f2
commit
3658dafdcb
41
Alc/alc.cpp
41
Alc/alc.cpp
@ -1024,8 +1024,9 @@ void alc_initconfig(void)
|
|||||||
#ifdef HAVE_NEON
|
#ifdef HAVE_NEON
|
||||||
capfilter |= CPU_CAP_NEON;
|
capfilter |= CPU_CAP_NEON;
|
||||||
#endif
|
#endif
|
||||||
if(ConfigValueStr(nullptr, nullptr, "disable-cpu-exts", &str))
|
if(auto cpuopt = ConfigValueStr(nullptr, nullptr, "disable-cpu-exts"))
|
||||||
{
|
{
|
||||||
|
str = cpuopt->c_str();
|
||||||
if(strcasecmp(str, "all") == 0)
|
if(strcasecmp(str, "all") == 0)
|
||||||
capfilter = 0;
|
capfilter = 0;
|
||||||
else
|
else
|
||||||
@ -1094,15 +1095,20 @@ void alc_initconfig(void)
|
|||||||
if(ConfigValueFloat(nullptr, "reverb", "boost", &valf))
|
if(ConfigValueFloat(nullptr, "reverb", "boost", &valf))
|
||||||
ReverbBoost *= std::pow(10.0f, valf / 20.0f);
|
ReverbBoost *= std::pow(10.0f, valf / 20.0f);
|
||||||
|
|
||||||
const char *devs{getenv("ALSOFT_DRIVERS")};
|
auto devopt = ConfigValueStr(nullptr, nullptr, "drivers");
|
||||||
if((devs && devs[0]) || ConfigValueStr(nullptr, nullptr, "drivers", &devs))
|
if(const char *devs{getenv("ALSOFT_DRIVERS")})
|
||||||
|
{
|
||||||
|
if(devs[0])
|
||||||
|
devopt = al::optional<std::string>{al::in_place, devs};
|
||||||
|
}
|
||||||
|
if(devopt)
|
||||||
{
|
{
|
||||||
auto backendlist_cur = std::begin(BackendList);
|
auto backendlist_cur = std::begin(BackendList);
|
||||||
|
|
||||||
bool endlist{true};
|
bool endlist{true};
|
||||||
const char *next = devs;
|
const char *next{devopt->c_str()};
|
||||||
do {
|
do {
|
||||||
devs = next;
|
const char *devs{next};
|
||||||
while(isspace(devs[0]))
|
while(isspace(devs[0]))
|
||||||
devs++;
|
devs++;
|
||||||
next = strchr(devs, ',');
|
next = strchr(devs, ',');
|
||||||
@ -1182,9 +1188,9 @@ void alc_initconfig(void)
|
|||||||
if(!CaptureFactory)
|
if(!CaptureFactory)
|
||||||
WARN("No capture backend available!\n");
|
WARN("No capture backend available!\n");
|
||||||
|
|
||||||
if(ConfigValueStr(nullptr, nullptr, "excludefx", &str))
|
if(auto exclopt = ConfigValueStr(nullptr, nullptr, "excludefx"))
|
||||||
{
|
{
|
||||||
const char *next = str;
|
const char *next{exclopt->c_str()};
|
||||||
do {
|
do {
|
||||||
str = next;
|
str = next;
|
||||||
next = strchr(str, ',');
|
next = strchr(str, ',');
|
||||||
@ -1203,9 +1209,10 @@ void alc_initconfig(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
InitEffect(&DefaultEffect);
|
InitEffect(&DefaultEffect);
|
||||||
str = getenv("ALSOFT_DEFAULT_REVERB");
|
auto defrevopt = ConfigValueStr(nullptr, nullptr, "default-reverb");
|
||||||
if((str && str[0]) || ConfigValueStr(nullptr, nullptr, "default-reverb", &str))
|
if((str=getenv("ALSOFT_DEFAULT_REVERB")) && str[0])
|
||||||
LoadReverbPreset(str, &DefaultEffect);
|
defrevopt = al::optional<std::string>{al::in_place, str};
|
||||||
|
if(defrevopt) LoadReverbPreset(defrevopt->c_str(), &DefaultEffect);
|
||||||
}
|
}
|
||||||
#define DO_INITCONFIG() std::call_once(alc_config_once, [](){alc_initconfig();})
|
#define DO_INITCONFIG() std::call_once(alc_config_once, [](){alc_initconfig();})
|
||||||
|
|
||||||
@ -1919,9 +1926,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
|||||||
device->HrtfStatus = ALC_HRTF_DISABLED_SOFT;
|
device->HrtfStatus = ALC_HRTF_DISABLED_SOFT;
|
||||||
if(device->Type != Loopback)
|
if(device->Type != Loopback)
|
||||||
{
|
{
|
||||||
const char *hrtf;
|
if(auto hrtfopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf"))
|
||||||
if(ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf", &hrtf))
|
|
||||||
{
|
{
|
||||||
|
const char *hrtf{hrtfopt->c_str()};
|
||||||
if(strcasecmp(hrtf, "true") == 0)
|
if(strcasecmp(hrtf, "true") == 0)
|
||||||
hrtf_userreq = Hrtf_Enable;
|
hrtf_userreq = Hrtf_Enable;
|
||||||
else if(strcasecmp(hrtf, "false") == 0)
|
else if(strcasecmp(hrtf, "false") == 0)
|
||||||
@ -3743,8 +3750,7 @@ START_API_FUNC
|
|||||||
}
|
}
|
||||||
|
|
||||||
deviceName = device->DeviceName.c_str();
|
deviceName = device->DeviceName.c_str();
|
||||||
const ALCchar *fmt{};
|
if(auto chanopt = ConfigValueStr(deviceName, nullptr, "channels"))
|
||||||
if(ConfigValueStr(deviceName, nullptr, "channels", &fmt))
|
|
||||||
{
|
{
|
||||||
static constexpr struct ChannelMap {
|
static constexpr struct ChannelMap {
|
||||||
const char name[16];
|
const char name[16];
|
||||||
@ -3763,6 +3769,7 @@ START_API_FUNC
|
|||||||
{ "ambi3", DevFmtAmbi3D, 3 },
|
{ "ambi3", DevFmtAmbi3D, 3 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ALCchar *fmt{chanopt->c_str()};
|
||||||
auto iter = std::find_if(std::begin(chanlist), std::end(chanlist),
|
auto iter = std::find_if(std::begin(chanlist), std::end(chanlist),
|
||||||
[fmt](const ChannelMap &entry) -> bool
|
[fmt](const ChannelMap &entry) -> bool
|
||||||
{ return strcasecmp(entry.name, fmt) == 0; }
|
{ return strcasecmp(entry.name, fmt) == 0; }
|
||||||
@ -3776,7 +3783,7 @@ START_API_FUNC
|
|||||||
device->Flags.set<ChannelsRequest>();
|
device->Flags.set<ChannelsRequest>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ConfigValueStr(deviceName, nullptr, "sample-type", &fmt))
|
if(auto typeopt = ConfigValueStr(deviceName, nullptr, "sample-type"))
|
||||||
{
|
{
|
||||||
static constexpr struct TypeMap {
|
static constexpr struct TypeMap {
|
||||||
const char name[16];
|
const char name[16];
|
||||||
@ -3791,6 +3798,7 @@ START_API_FUNC
|
|||||||
{ "float32", DevFmtFloat },
|
{ "float32", DevFmtFloat },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ALCchar *fmt{typeopt->c_str()};
|
||||||
auto iter = std::find_if(std::begin(typelist), std::end(typelist),
|
auto iter = std::find_if(std::begin(typelist), std::end(typelist),
|
||||||
[fmt](const TypeMap &entry) -> bool
|
[fmt](const TypeMap &entry) -> bool
|
||||||
{ return strcasecmp(entry.name, fmt) == 0; }
|
{ return strcasecmp(entry.name, fmt) == 0; }
|
||||||
@ -3842,8 +3850,9 @@ START_API_FUNC
|
|||||||
device->NumStereoSources = 1;
|
device->NumStereoSources = 1;
|
||||||
device->NumMonoSources = device->SourcesMax - device->NumStereoSources;
|
device->NumMonoSources = device->SourcesMax - device->NumStereoSources;
|
||||||
|
|
||||||
if(ConfigValueStr(deviceName, nullptr, "ambi-format", &fmt))
|
if(auto ambiopt = ConfigValueStr(deviceName, nullptr, "ambi-format"))
|
||||||
{
|
{
|
||||||
|
const ALCchar *fmt{ambiopt->c_str()};
|
||||||
if(strcasecmp(fmt, "fuma") == 0)
|
if(strcasecmp(fmt, "fuma") == 0)
|
||||||
{
|
{
|
||||||
if(device->mAmbiOrder > 3)
|
if(device->mAmbiOrder > 3)
|
||||||
|
@ -492,13 +492,12 @@ int ConfigValueExists(const char *devName, const char *blockName, const char *ke
|
|||||||
return val[0] != 0;
|
return val[0] != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigValueStr(const char *devName, const char *blockName, const char *keyName, const char **ret)
|
al::optional<std::string> ConfigValueStr(const char *devName, const char *blockName, const char *keyName)
|
||||||
{
|
{
|
||||||
const char *val = GetConfigValue(devName, blockName, keyName, "");
|
const char *val = GetConfigValue(devName, blockName, keyName, "");
|
||||||
if(!val[0]) return 0;
|
if(!val[0]) return al::nullopt;
|
||||||
|
|
||||||
*ret = val;
|
return al::optional<std::string>{al::in_place, val};
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
al::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName)
|
al::optional<int> ConfigValueInt(const char *devName, const char *blockName, const char *keyName)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef ALCONFIG_H
|
#ifndef ALCONFIG_H
|
||||||
#define ALCONFIG_H
|
#define ALCONFIG_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "aloptional.h"
|
#include "aloptional.h"
|
||||||
|
|
||||||
void ReadALConfig();
|
void ReadALConfig();
|
||||||
@ -9,7 +11,7 @@ int ConfigValueExists(const char *devName, const char *blockName, const char *ke
|
|||||||
const char *GetConfigValue(const char *devName, const char *blockName, const char *keyName, const char *def);
|
const char *GetConfigValue(const char *devName, const char *blockName, const char *keyName, const char *def);
|
||||||
int GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, int def);
|
int GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, int def);
|
||||||
|
|
||||||
int ConfigValueStr(const char *devName, const char *blockName, const char *keyName, const char **ret);
|
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<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<unsigned int> ConfigValueUInt(const char *devName, const char *blockName, const char *keyName);
|
||||||
int ConfigValueFloat(const char *devName, const char *blockName, const char *keyName, float *ret);
|
int ConfigValueFloat(const char *devName, const char *blockName, const char *keyName, float *ret);
|
||||||
|
@ -207,11 +207,6 @@ ALSA_FUNCS(MAKE_FUNC);
|
|||||||
struct DevMap {
|
struct DevMap {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string device_name;
|
std::string device_name;
|
||||||
|
|
||||||
template<typename StrT0, typename StrT1>
|
|
||||||
DevMap(StrT0&& name_, StrT1&& devname_)
|
|
||||||
: name{std::forward<StrT0>(name_)}, device_name{std::forward<StrT1>(devname_)}
|
|
||||||
{ }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
al::vector<DevMap> PlaybackDevices;
|
al::vector<DevMap> PlaybackDevices;
|
||||||
@ -233,10 +228,9 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
|
|||||||
snd_pcm_info_t *pcminfo;
|
snd_pcm_info_t *pcminfo;
|
||||||
snd_pcm_info_malloc(&pcminfo);
|
snd_pcm_info_malloc(&pcminfo);
|
||||||
|
|
||||||
devlist.emplace_back(alsaDevice,
|
devlist.emplace_back(DevMap{alsaDevice,
|
||||||
GetConfigValue(nullptr, "alsa", (stream==SND_PCM_STREAM_PLAYBACK) ? "device" : "capture",
|
GetConfigValue(nullptr, "alsa", (stream==SND_PCM_STREAM_PLAYBACK) ? "device" : "capture",
|
||||||
"default")
|
"default")});
|
||||||
);
|
|
||||||
|
|
||||||
if(stream == SND_PCM_STREAM_PLAYBACK)
|
if(stream == SND_PCM_STREAM_PLAYBACK)
|
||||||
{
|
{
|
||||||
@ -254,15 +248,15 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *oldsep{sep++};
|
const char *oldsep{sep++};
|
||||||
devlist.emplace_back(std::string(customdevs, oldsep),
|
devlist.emplace_back(DevMap{std::string(customdevs, oldsep),
|
||||||
next ? std::string(sep, next++) : std::string(sep));
|
next ? std::string(sep, next++) : std::string(sep)});
|
||||||
const auto &entry = devlist.back();
|
const auto &entry = devlist.back();
|
||||||
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
|
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *main_prefix{"plughw:"};
|
const std::string main_prefix{
|
||||||
ConfigValueStr(nullptr, "alsa", prefix_name(stream), &main_prefix);
|
ConfigValueStr(nullptr, "alsa", prefix_name(stream)).value_or("plughw:")};
|
||||||
|
|
||||||
int card{-1};
|
int card{-1};
|
||||||
int err{snd_card_next(&card)};
|
int err{snd_card_next(&card)};
|
||||||
@ -288,9 +282,8 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
|
|||||||
name = prefix_name(stream);
|
name = prefix_name(stream);
|
||||||
name += '-';
|
name += '-';
|
||||||
name += cardid;
|
name += cardid;
|
||||||
|
const std::string card_prefix{
|
||||||
const char *card_prefix{main_prefix};
|
ConfigValueStr(nullptr, "alsa", name.c_str()).value_or(main_prefix)};
|
||||||
ConfigValueStr(nullptr, "alsa", name.c_str(), &card_prefix);
|
|
||||||
|
|
||||||
int dev{-1};
|
int dev{-1};
|
||||||
while(1)
|
while(1)
|
||||||
@ -315,8 +308,8 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
|
|||||||
name += cardid;
|
name += cardid;
|
||||||
name += '-';
|
name += '-';
|
||||||
name += std::to_string(dev);
|
name += std::to_string(dev);
|
||||||
const char *device_prefix{card_prefix};
|
const std::string device_prefix{
|
||||||
ConfigValueStr(nullptr, "alsa", name.c_str(), &device_prefix);
|
ConfigValueStr(nullptr, "alsa", name.c_str()).value_or(card_prefix)};
|
||||||
|
|
||||||
/* "CardName, PcmName (CARD=cardid,DEV=dev)" */
|
/* "CardName, PcmName (CARD=cardid,DEV=dev)" */
|
||||||
name = cardname;
|
name = cardname;
|
||||||
@ -335,7 +328,7 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
|
|||||||
device += ",DEV=";
|
device += ",DEV=";
|
||||||
device += std::to_string(dev);
|
device += std::to_string(dev);
|
||||||
|
|
||||||
devlist.emplace_back(std::move(name), std::move(device));
|
devlist.emplace_back(DevMap{std::move(name), std::move(device)});
|
||||||
const auto &entry = devlist.back();
|
const auto &entry = devlist.back();
|
||||||
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
|
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
|
||||||
}
|
}
|
||||||
|
@ -80,17 +80,12 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr char DefaultName[] = "OSS Default";
|
constexpr char DefaultName[] = "OSS Default";
|
||||||
const char *DefaultPlayback{"/dev/dsp"};
|
std::string DefaultPlayback{"/dev/dsp"};
|
||||||
const char *DefaultCapture{"/dev/dsp"};
|
std::string DefaultCapture{"/dev/dsp"};
|
||||||
|
|
||||||
struct DevMap {
|
struct DevMap {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string device_name;
|
std::string device_name;
|
||||||
|
|
||||||
template<typename StrT0, typename StrT1>
|
|
||||||
DevMap(StrT0&& name_, StrT1&& devname_)
|
|
||||||
: name{std::forward<StrT0>(name_)}, device_name{std::forward<StrT1>(devname_)}
|
|
||||||
{ }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool checkName(const al::vector<DevMap> &list, const std::string &name)
|
bool checkName(const al::vector<DevMap> &list, const std::string &name)
|
||||||
@ -111,7 +106,7 @@ al::vector<DevMap> CaptureDevices;
|
|||||||
#define DSP_CAP_INPUT 0x00010000
|
#define DSP_CAP_INPUT 0x00010000
|
||||||
void ALCossListPopulate(al::vector<DevMap> *devlist, int type)
|
void ALCossListPopulate(al::vector<DevMap> *devlist, int type)
|
||||||
{
|
{
|
||||||
devlist->emplace_back(DefaultName, (type==DSP_CAP_INPUT) ? DefaultCapture : DefaultPlayback);
|
devlist->emplace_back(DevMap{DefaultName, (type==DSP_CAP_INPUT) ? DefaultCapture : DefaultPlayback});
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -156,7 +151,7 @@ void ALCossListAppend(al::vector<DevMap> *list, const char *handle, size_t hlen,
|
|||||||
newname += std::to_string(++count);
|
newname += std::to_string(++count);
|
||||||
}
|
}
|
||||||
|
|
||||||
list->emplace_back(std::move(newname), std::move(devname));
|
list->emplace_back(DevMap{std::move(newname), std::move(devname)});
|
||||||
const DevMap &entry = list->back();
|
const DevMap &entry = list->back();
|
||||||
|
|
||||||
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
|
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
|
||||||
@ -212,7 +207,7 @@ done:
|
|||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
|
||||||
const char *defdev{(type_flag==DSP_CAP_INPUT) ? DefaultCapture : DefaultPlayback};
|
const char *defdev{((type_flag==DSP_CAP_INPUT) ? DefaultCapture : DefaultPlayback).c_str()};
|
||||||
auto iter = std::find_if(devlist->cbegin(), devlist->cend(),
|
auto iter = std::find_if(devlist->cbegin(), devlist->cend(),
|
||||||
[defdev](const DevMap &entry) -> bool
|
[defdev](const DevMap &entry) -> bool
|
||||||
{ return entry.device_name == defdev; }
|
{ return entry.device_name == defdev; }
|
||||||
@ -331,7 +326,7 @@ int OSSPlayback::mixerProc()
|
|||||||
|
|
||||||
ALCenum OSSPlayback::open(const ALCchar *name)
|
ALCenum OSSPlayback::open(const ALCchar *name)
|
||||||
{
|
{
|
||||||
const char *devname{DefaultPlayback};
|
const char *devname{DefaultPlayback.c_str()};
|
||||||
if(!name)
|
if(!name)
|
||||||
name = DefaultName;
|
name = DefaultName;
|
||||||
else
|
else
|
||||||
@ -548,7 +543,7 @@ int OSScapture::recordProc()
|
|||||||
|
|
||||||
ALCenum OSScapture::open(const ALCchar *name)
|
ALCenum OSScapture::open(const ALCchar *name)
|
||||||
{
|
{
|
||||||
const char *devname{DefaultCapture};
|
const char *devname{DefaultCapture.c_str()};
|
||||||
if(!name)
|
if(!name)
|
||||||
name = DefaultName;
|
name = DefaultName;
|
||||||
else
|
else
|
||||||
@ -700,8 +695,10 @@ BackendFactory &OSSBackendFactory::getFactory()
|
|||||||
|
|
||||||
bool OSSBackendFactory::init()
|
bool OSSBackendFactory::init()
|
||||||
{
|
{
|
||||||
ConfigValueStr(nullptr, "oss", "device", &DefaultPlayback);
|
if(auto devopt = ConfigValueStr(nullptr, "oss", "device"))
|
||||||
ConfigValueStr(nullptr, "oss", "capture", &DefaultCapture);
|
DefaultPlayback = std::move(*devopt);
|
||||||
|
if(auto capopt = ConfigValueStr(nullptr, "oss", "capture"))
|
||||||
|
DefaultCapture = std::move(*capopt);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace {
|
|||||||
|
|
||||||
constexpr ALCchar solaris_device[] = "Solaris Default";
|
constexpr ALCchar solaris_device[] = "Solaris Default";
|
||||||
|
|
||||||
const char *solaris_driver = "/dev/audio";
|
std::string solaris_driver{"/dev/audio"};
|
||||||
|
|
||||||
|
|
||||||
struct SolarisBackend final : public BackendBase {
|
struct SolarisBackend final : public BackendBase {
|
||||||
@ -149,10 +149,10 @@ ALCenum SolarisBackend::open(const ALCchar *name)
|
|||||||
else if(strcmp(name, solaris_device) != 0)
|
else if(strcmp(name, solaris_device) != 0)
|
||||||
return ALC_INVALID_VALUE;
|
return ALC_INVALID_VALUE;
|
||||||
|
|
||||||
mFd = ::open(solaris_driver, O_WRONLY);
|
mFd = ::open(solaris_driver.c_str(), O_WRONLY);
|
||||||
if(mFd == -1)
|
if(mFd == -1)
|
||||||
{
|
{
|
||||||
ERR("Could not open %s: %s\n", solaris_driver, strerror(errno));
|
ERR("Could not open %s: %s\n", solaris_driver.c_str(), strerror(errno));
|
||||||
return ALC_INVALID_VALUE;
|
return ALC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,8 @@ BackendFactory &SolarisBackendFactory::getFactory()
|
|||||||
|
|
||||||
bool SolarisBackendFactory::init()
|
bool SolarisBackendFactory::init()
|
||||||
{
|
{
|
||||||
ConfigValueStr(nullptr, "solaris", "device", &solaris_driver);
|
if(auto devopt = ConfigValueStr(nullptr, "solaris", "device"))
|
||||||
|
solaris_driver = std::move(*devopt);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +283,7 @@ void SolarisBackendFactory::probe(DevProbe type, std::string *outnames)
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if(stat(solaris_driver, &buf) == 0)
|
if(stat(solaris_driver.c_str(), &buf) == 0)
|
||||||
#endif
|
#endif
|
||||||
outnames->append(solaris_device, sizeof(solaris_device));
|
outnames->append(solaris_device, sizeof(solaris_device));
|
||||||
}
|
}
|
||||||
|
30
Alc/hrtf.cpp
30
Alc/hrtf.cpp
@ -1214,9 +1214,9 @@ al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname)
|
|||||||
al::vector<EnumeratedHrtf> list;
|
al::vector<EnumeratedHrtf> list;
|
||||||
|
|
||||||
bool usedefaults{true};
|
bool usedefaults{true};
|
||||||
const char *pathlist{""};
|
if(auto pathopt = ConfigValueStr(devname, nullptr, "hrtf-paths"))
|
||||||
if(ConfigValueStr(devname, nullptr, "hrtf-paths", &pathlist))
|
|
||||||
{
|
{
|
||||||
|
const char *pathlist{pathopt->c_str()};
|
||||||
while(pathlist && *pathlist)
|
while(pathlist && *pathlist)
|
||||||
{
|
{
|
||||||
const char *next, *end;
|
const char *next, *end;
|
||||||
@ -1262,20 +1262,22 @@ al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname)
|
|||||||
AddBuiltInEntry(list, "Built-In 48000hz", IDR_DEFAULT_48000_MHR);
|
AddBuiltInEntry(list, "Built-In 48000hz", IDR_DEFAULT_48000_MHR);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *defaulthrtf{""};
|
if(!list.empty())
|
||||||
if(!list.empty() && ConfigValueStr(devname, nullptr, "default-hrtf", &defaulthrtf))
|
|
||||||
{
|
{
|
||||||
auto iter = std::find_if(list.begin(), list.end(),
|
if(auto defhrtfopt = ConfigValueStr(devname, nullptr, "default-hrtf"))
|
||||||
[defaulthrtf](const EnumeratedHrtf &entry) -> bool
|
|
||||||
{ return entry.name == defaulthrtf; }
|
|
||||||
);
|
|
||||||
if(iter == list.end())
|
|
||||||
WARN("Failed to find default HRTF \"%s\"\n", defaulthrtf);
|
|
||||||
else if(iter != list.begin())
|
|
||||||
{
|
{
|
||||||
EnumeratedHrtf entry{*iter};
|
auto iter = std::find_if(list.begin(), list.end(),
|
||||||
list.erase(iter);
|
[&defhrtfopt](const EnumeratedHrtf &entry) -> bool
|
||||||
list.insert(list.begin(), entry);
|
{ return entry.name == *defhrtfopt; }
|
||||||
|
);
|
||||||
|
if(iter == list.end())
|
||||||
|
WARN("Failed to find default HRTF \"%s\"\n", defhrtfopt->c_str());
|
||||||
|
else if(iter != list.begin())
|
||||||
|
{
|
||||||
|
EnumeratedHrtf entry{std::move(*iter)};
|
||||||
|
list.erase(iter);
|
||||||
|
list.insert(list.begin(), std::move(entry));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +155,9 @@ ResamplerFunc SelectResampler(Resampler resampler)
|
|||||||
|
|
||||||
void aluInitMixer()
|
void aluInitMixer()
|
||||||
{
|
{
|
||||||
const char *str;
|
if(auto resopt = ConfigValueStr(nullptr, nullptr, "resampler"))
|
||||||
|
|
||||||
if(ConfigValueStr(nullptr, nullptr, "resampler", &str))
|
|
||||||
{
|
{
|
||||||
|
const char *str{resopt->c_str()};
|
||||||
if(strcasecmp(str, "point") == 0 || strcasecmp(str, "none") == 0)
|
if(strcasecmp(str, "point") == 0 || strcasecmp(str, "none") == 0)
|
||||||
ResamplerDefault = PointResampler;
|
ResamplerDefault = PointResampler;
|
||||||
else if(strcasecmp(str, "linear") == 0)
|
else if(strcasecmp(str, "linear") == 0)
|
||||||
|
@ -553,9 +553,9 @@ void InitHrtfPanning(ALCdevice *device)
|
|||||||
*/
|
*/
|
||||||
device->mRenderMode = HrtfRender;
|
device->mRenderMode = HrtfRender;
|
||||||
ALsizei ambi_order{1};
|
ALsizei ambi_order{1};
|
||||||
const char *mode;
|
if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf-mode"))
|
||||||
if(ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf-mode", &mode))
|
|
||||||
{
|
{
|
||||||
|
const char *mode{modeopt->c_str()};
|
||||||
if(strcasecmp(mode, "basic") == 0)
|
if(strcasecmp(mode, "basic") == 0)
|
||||||
{
|
{
|
||||||
ERR("HRTF mode \"%s\" deprecated, substituting \"%s\"\n", mode, "ambi2");
|
ERR("HRTF mode \"%s\" deprecated, substituting \"%s\"\n", mode, "ambi2");
|
||||||
@ -783,11 +783,10 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
|
|||||||
AmbDecConf conf{};
|
AmbDecConf conf{};
|
||||||
if(layout)
|
if(layout)
|
||||||
{
|
{
|
||||||
const char *fname;
|
if(auto decopt = ConfigValueStr(devname, "decoder", layout))
|
||||||
if(ConfigValueStr(devname, "decoder", layout, &fname))
|
|
||||||
{
|
{
|
||||||
if(!conf.load(fname))
|
if(!conf.load(decopt->c_str()))
|
||||||
ERR("Failed to load layout file %s\n", fname);
|
ERR("Failed to load layout file %s\n", decopt->c_str());
|
||||||
else if(conf.Speakers.size() > MAX_OUTPUT_CHANNELS)
|
else if(conf.Speakers.size() > MAX_OUTPUT_CHANNELS)
|
||||||
ERR("Unsupported speaker count %zu (max %d)\n", conf.Speakers.size(),
|
ERR("Unsupported speaker count %zu (max %d)\n", conf.Speakers.size(),
|
||||||
MAX_OUTPUT_CHANNELS);
|
MAX_OUTPUT_CHANNELS);
|
||||||
@ -814,9 +813,9 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
|
|||||||
bool headphones{device->IsHeadphones != AL_FALSE};
|
bool headphones{device->IsHeadphones != AL_FALSE};
|
||||||
if(device->Type != Loopback)
|
if(device->Type != Loopback)
|
||||||
{
|
{
|
||||||
const char *mode;
|
if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "stereo-mode"))
|
||||||
if(ConfigValueStr(device->DeviceName.c_str(), nullptr, "stereo-mode", &mode))
|
|
||||||
{
|
{
|
||||||
|
const char *mode{modeopt->c_str()};
|
||||||
if(strcasecmp(mode, "headphones") == 0)
|
if(strcasecmp(mode, "headphones") == 0)
|
||||||
headphones = true;
|
headphones = true;
|
||||||
else if(strcasecmp(mode, "speakers") == 0)
|
else if(strcasecmp(mode, "speakers") == 0)
|
||||||
@ -916,9 +915,9 @@ no_hrtf:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *mode;
|
if(auto encopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "stereo-encoding"))
|
||||||
if(ConfigValueStr(device->DeviceName.c_str(), nullptr, "stereo-encoding", &mode))
|
|
||||||
{
|
{
|
||||||
|
const char *mode{encopt->c_str()};
|
||||||
if(strcasecmp(mode, "uhj") == 0)
|
if(strcasecmp(mode, "uhj") == 0)
|
||||||
device->mRenderMode = NormalRender;
|
device->mRenderMode = NormalRender;
|
||||||
else if(strcasecmp(mode, "panpot") != 0)
|
else if(strcasecmp(mode, "panpot") != 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user