Choosing the driver via a new submenu instead
This commit is contained in:
parent
981569e23d
commit
2c0dab7c32
@ -473,8 +473,11 @@ namespace spades {
|
|||||||
StartupScreenConfigView @configViewOpenAL;
|
StartupScreenConfigView @configViewOpenAL;
|
||||||
StartupScreenConfigView @configViewYSR;
|
StartupScreenConfigView @configViewYSR;
|
||||||
|
|
||||||
|
StartupScreenAudioOpenALEditor @editOpenAL;
|
||||||
|
|
||||||
private ConfigItem s_audioDriver("s_audioDriver");
|
private ConfigItem s_audioDriver("s_audioDriver");
|
||||||
private ConfigItem s_eax("s_eax");
|
private ConfigItem s_eax("s_eax");
|
||||||
|
private ConfigItem s_openalDevice("s_openalDevice");
|
||||||
|
|
||||||
StartupScreenAudioTab(StartupScreenUI @ui, Vector2 size) {
|
StartupScreenAudioTab(StartupScreenUI @ui, Vector2 size) {
|
||||||
super(ui.manager);
|
super(ui.manager);
|
||||||
@ -536,6 +539,7 @@ namespace spades {
|
|||||||
{
|
{
|
||||||
StartupScreenConfigView cfg(Manager);
|
StartupScreenConfigView cfg(Manager);
|
||||||
|
|
||||||
|
|
||||||
cfg.AddRow(StartupScreenConfigSliderItemEditor(
|
cfg.AddRow(StartupScreenConfigSliderItemEditor(
|
||||||
ui, StartupScreenConfig(ui, "s_maxPolyphonics"), 16.0, 256.0, 8.0,
|
ui, StartupScreenConfig(ui, "s_maxPolyphonics"), 16.0, 256.0, 8.0,
|
||||||
_Tr("StartupScreen", "Polyphonics"),
|
_Tr("StartupScreen", "Polyphonics"),
|
||||||
@ -547,6 +551,13 @@ namespace spades {
|
|||||||
ui, StartupScreenConfig(ui, "s_eax"), "0", "1", _Tr("StartupScreen", "EAX"),
|
ui, StartupScreenConfig(ui, "s_eax"), "0", "1", _Tr("StartupScreen", "EAX"),
|
||||||
_Tr("StartupScreen",
|
_Tr("StartupScreen",
|
||||||
"Enables extended features provided by the OpenAL driver to create " "more ambience.")));
|
"Enables extended features provided by the OpenAL driver to create " "more ambience.")));
|
||||||
|
AddLabel(0.f, 90.f, 20.f, _Tr("StartupScreen", "Devices"));
|
||||||
|
{
|
||||||
|
StartupScreenAudioOpenALEditor e(ui);
|
||||||
|
AddChild(e);
|
||||||
|
@editOpenAL = e;
|
||||||
|
cfg.AddRow(editOpenAL);
|
||||||
|
}
|
||||||
|
|
||||||
cfg.Finalize();
|
cfg.Finalize();
|
||||||
cfg.SetHelpTextHandler(HelpTextHandler(this.HandleHelpText));
|
cfg.SetHelpTextHandler(HelpTextHandler(this.HandleHelpText));
|
||||||
@ -609,6 +620,71 @@ namespace spades {
|
|||||||
ui.helper.CheckConfigCapability("s_audioDriver", "null").length == 0;
|
ui.helper.CheckConfigCapability("s_audioDriver", "null").length == 0;
|
||||||
configViewOpenAL.LoadConfig();
|
configViewOpenAL.LoadConfig();
|
||||||
configViewYSR.LoadConfig();
|
configViewYSR.LoadConfig();
|
||||||
|
editOpenAL.LoadConfig();
|
||||||
|
|
||||||
|
s_openalDevice.StringValue = editOpenAL.openal.StringValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StartupScreenAudioOpenALEditor : spades::ui::UIElement, LabelAddable {
|
||||||
|
StartupScreenUI @ui;
|
||||||
|
StartupScreenHelper @helper;
|
||||||
|
ConfigItem openal("openal");
|
||||||
|
|
||||||
|
spades::ui::Button @dropdownButton;
|
||||||
|
|
||||||
|
StartupScreenAudioOpenALEditor(StartupScreenUI @ui) {
|
||||||
|
super(ui.manager);
|
||||||
|
@this.ui = ui;
|
||||||
|
@helper = ui.helper;
|
||||||
|
{
|
||||||
|
StartupScreenDropdownListDropdownButton e(Manager);
|
||||||
|
AddChild(e);
|
||||||
|
e.Bounds = AABB2(80.f, 0.f, 400.f, 20.f);
|
||||||
|
@e.Activated = spades::ui::EventHandler(this.ShowDropdown);
|
||||||
|
@dropdownButton = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadConfig() {
|
||||||
|
string drivername = openal.StringValue;
|
||||||
|
string name = _Tr("StartupScreen", "Default device", drivername);
|
||||||
|
if (drivername == "") {
|
||||||
|
name = _Tr("StartupScreen", "Default device");
|
||||||
|
}
|
||||||
|
|
||||||
|
int cnt = helper.GetNumAudioOpenALDevices();
|
||||||
|
for (int i = 0; i < cnt; i++) {
|
||||||
|
if (drivername == helper.GetAudioOpenALDevice(i)) {
|
||||||
|
name = helper.GetAudioOpenALDevice(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dropdownButton.Caption = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowDropdown(spades::ui::UIElement @) {
|
||||||
|
string[] items = {_Tr("StartupScreen", "Default device")};
|
||||||
|
int cnt = helper.GetNumAudioOpenALDevices();
|
||||||
|
for (int i = 0; i < cnt; i++) {
|
||||||
|
string s = helper.GetAudioOpenALDevice(i);
|
||||||
|
items.insertLast(s);
|
||||||
|
}
|
||||||
|
spades::ui::ShowDropDownList(this, items,
|
||||||
|
spades::ui::DropDownListHandler(this.DropdownHandler));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DropdownHandler(int index) {
|
||||||
|
if (index >= 0) {
|
||||||
|
if (index == 0) {
|
||||||
|
openal = "default";
|
||||||
|
} else {
|
||||||
|
openal = helper.GetAudioOpenALDevice(index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload the startup screen so the language config takes effect
|
||||||
|
ui.Reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ DEFINE_SPADES_SETTING(s_maxPolyphonics, "96");
|
|||||||
DEFINE_SPADES_SETTING(s_eax, "1");
|
DEFINE_SPADES_SETTING(s_eax, "1");
|
||||||
DEFINE_SPADES_SETTING(s_alPreciseErrorCheck, "1");
|
DEFINE_SPADES_SETTING(s_alPreciseErrorCheck, "1");
|
||||||
DEFINE_SPADES_SETTING(s_gain, "1");
|
DEFINE_SPADES_SETTING(s_gain, "1");
|
||||||
|
DEFINE_SPADES_SETTING(s_openalDevice, "");
|
||||||
|
|
||||||
// lm: seems to be missing for me..
|
// lm: seems to be missing for me..
|
||||||
#ifndef ALC_ALL_DEVICES_SPECIFIER
|
#ifndef ALC_ALL_DEVICES_SPECIFIER
|
||||||
@ -421,7 +422,7 @@ namespace spades {
|
|||||||
|
|
||||||
Internal() {
|
Internal() {
|
||||||
SPADES_MARK_FUNCTION();
|
SPADES_MARK_FUNCTION();
|
||||||
std::vector<std::string> devs;
|
const char *ext, *dev;
|
||||||
|
|
||||||
if (al::qalGetString(AL_EXTENSIONS)) {
|
if (al::qalGetString(AL_EXTENSIONS)) {
|
||||||
std::vector<std::string> strs = Split(al::qalGetString(AL_EXTENSIONS), " ");
|
std::vector<std::string> strs = Split(al::qalGetString(AL_EXTENSIONS), " ");
|
||||||
@ -431,38 +432,11 @@ namespace spades {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPLog("--- All devices ---");
|
dev = s_openalDevice.CString();
|
||||||
const ALCchar *ext = al::qalcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
|
SPLog("OpenAL opening device: %s", dev);
|
||||||
while (ext && *ext) {
|
if (!strcmp(dev, "default"))
|
||||||
SPLog("%s", ext);
|
dev = NULL;
|
||||||
devs.push_back(ext);
|
alDevice = al::qalcOpenDevice(dev);
|
||||||
ext += (std::strlen(ext) + 1);
|
|
||||||
}
|
|
||||||
SPLog("-------------------");
|
|
||||||
|
|
||||||
SPLog("--- Devices ---");
|
|
||||||
ext = al::qalcGetString(NULL, ALC_DEVICE_SPECIFIER);
|
|
||||||
while (ext && *ext) {
|
|
||||||
SPLog("%s", ext);
|
|
||||||
devs.push_back(ext);
|
|
||||||
ext += (std::strlen(ext) + 1);
|
|
||||||
}
|
|
||||||
SPLog("---------------");
|
|
||||||
const ALCchar *dev = al::qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
|
|
||||||
if (dev && *dev) {
|
|
||||||
SPLog("Default device: %s", dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(alDevice = al::qalcOpenDevice(NULL))) {
|
|
||||||
SPLog("Failed to open default OpenAL device");
|
|
||||||
for (const auto &d: devs) {
|
|
||||||
if (dev && *dev && !strcmp(dev, d.c_str()))
|
|
||||||
continue;
|
|
||||||
SPLog("Opening handle attempt on device: %s", d.c_str());
|
|
||||||
if ((alDevice = al::qalcOpenDevice(d.c_str())))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!alDevice) {
|
if (!alDevice) {
|
||||||
if ((ext = al::qalcGetString(NULL, ALC_EXTENSIONS))) {
|
if ((ext = al::qalcGetString(NULL, ALC_EXTENSIONS))) {
|
||||||
@ -571,7 +545,7 @@ namespace spades {
|
|||||||
ALSrc *AllocChunk() {
|
ALSrc *AllocChunk() {
|
||||||
SPADES_MARK_FUNCTION();
|
SPADES_MARK_FUNCTION();
|
||||||
|
|
||||||
size_t start = SampleRandomInt<std::size_t>(0, srcs.size() - 1);
|
size_t start = SampleRandomInt<std::size_t>(0, srcs.size() - 1);
|
||||||
for (size_t i = 0; i < srcs.size(); i++) {
|
for (size_t i = 0; i < srcs.size(); i++) {
|
||||||
ALSrc *src = srcs[(i + start) % srcs.size()];
|
ALSrc *src = srcs[(i + start) % srcs.size()];
|
||||||
if (src->IsPlaying())
|
if (src->IsPlaying())
|
||||||
@ -579,7 +553,7 @@ namespace spades {
|
|||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALSrc *src = SampleRandomElement(srcs);
|
ALSrc *src = SampleRandomElement(srcs);
|
||||||
src->Terminate();
|
src->Terminate();
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
@ -768,6 +742,19 @@ namespace spades {
|
|||||||
d = new Internal();
|
d = new Internal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> ALDevice::DeviceList() {
|
||||||
|
std::vector<std::string> devs;
|
||||||
|
const ALCchar *ext = al::qalcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
|
||||||
|
if (!ext || *ext == '\0')
|
||||||
|
ext = al::qalcGetString(NULL, ALC_DEVICE_SPECIFIER);
|
||||||
|
while (ext && *ext) {
|
||||||
|
devs.push_back(ext);
|
||||||
|
ext += std::strlen(ext) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return devs;
|
||||||
|
}
|
||||||
|
|
||||||
bool ALDevice::TryLoad() {
|
bool ALDevice::TryLoad() {
|
||||||
try {
|
try {
|
||||||
al::Link();
|
al::Link();
|
||||||
|
@ -45,6 +45,8 @@ namespace spades {
|
|||||||
|
|
||||||
client::IAudioChunk *RegisterSound(const char *name) override;
|
client::IAudioChunk *RegisterSound(const char *name) override;
|
||||||
|
|
||||||
|
static std::vector<std::string> DeviceList();
|
||||||
|
|
||||||
void ClearCache() override;
|
void ClearCache() override;
|
||||||
|
|
||||||
void SetGameMap(client::GameMap *) override;
|
void SetGameMap(client::GameMap *) override;
|
||||||
|
@ -166,6 +166,13 @@ namespace spades {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check openAL drivers
|
||||||
|
SPLog("Checking OpenAL available drivers");
|
||||||
|
openalDevices = audio::ALDevice::DeviceList();
|
||||||
|
for (const auto &d: openalDevices) {
|
||||||
|
SPLog("%s", d.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// check GL capabilities
|
// check GL capabilities
|
||||||
|
|
||||||
SPLog("Performing ecapability query");
|
SPLog("Performing ecapability query");
|
||||||
@ -754,6 +761,13 @@ namespace spades {
|
|||||||
report += '\n';
|
report += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StartupScreenHelper::GetNumAudioOpenALDevices() { return static_cast<int>(openalDevices.size()); }
|
||||||
|
std::string StartupScreenHelper::GetAudioOpenALDevice(int index) {
|
||||||
|
if (index < 0 || index >= GetNumAudioOpenALDevices())
|
||||||
|
SPInvalidArgument("index");
|
||||||
|
return openalDevices[index];
|
||||||
|
}
|
||||||
|
|
||||||
int StartupScreenHelper::GetNumLocales() { return static_cast<int>(locales.size()); }
|
int StartupScreenHelper::GetNumLocales() { return static_cast<int>(locales.size()); }
|
||||||
std::string StartupScreenHelper::GetLocale(int index) {
|
std::string StartupScreenHelper::GetLocale(int index) {
|
||||||
if (index < 0 || index >= GetNumLocales())
|
if (index < 0 || index >= GetNumLocales())
|
||||||
|
@ -50,6 +50,7 @@ namespace spades {
|
|||||||
void AddReport(const std::string &text = std::string(),
|
void AddReport(const std::string &text = std::string(),
|
||||||
Vector4 color = Vector4::Make(1.f, 1.f, 1.f, 1.f));
|
Vector4 color = Vector4::Make(1.f, 1.f, 1.f, 1.f));
|
||||||
|
|
||||||
|
std::vector<std::string> openalDevices;
|
||||||
struct LocaleInfo {
|
struct LocaleInfo {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string descriptionNative;
|
std::string descriptionNative;
|
||||||
@ -78,6 +79,9 @@ namespace spades {
|
|||||||
int GetVideoModeWidth(int index);
|
int GetVideoModeWidth(int index);
|
||||||
int GetVideoModeHeight(int index);
|
int GetVideoModeHeight(int index);
|
||||||
|
|
||||||
|
int GetNumAudioOpenALDevices();
|
||||||
|
std::string GetAudioOpenALDevice(int index);
|
||||||
|
|
||||||
int GetNumReportLines();
|
int GetNumReportLines();
|
||||||
std::string GetReport() { return report; }
|
std::string GetReport() { return report; }
|
||||||
std::string GetReportLineText(int line);
|
std::string GetReportLineText(int line);
|
||||||
|
@ -72,6 +72,16 @@ namespace spades {
|
|||||||
asMETHOD(gui::StartupScreenHelper, GetVideoModeHeight),
|
asMETHOD(gui::StartupScreenHelper, GetVideoModeHeight),
|
||||||
asCALL_THISCALL);
|
asCALL_THISCALL);
|
||||||
manager->CheckError(r);
|
manager->CheckError(r);
|
||||||
|
r = eng->RegisterObjectMethod("StartupScreenHelper",
|
||||||
|
"int GetNumAudioOpenALDevices()",
|
||||||
|
asMETHOD(gui::StartupScreenHelper, GetNumAudioOpenALDevices),
|
||||||
|
asCALL_THISCALL);
|
||||||
|
manager->CheckError(r);
|
||||||
|
r = eng->RegisterObjectMethod("StartupScreenHelper",
|
||||||
|
"string GetAudioOpenALDevice(int)",
|
||||||
|
asMETHOD(gui::StartupScreenHelper, GetAudioOpenALDevice),
|
||||||
|
asCALL_THISCALL);
|
||||||
|
manager->CheckError(r);
|
||||||
r = eng->RegisterObjectMethod("StartupScreenHelper",
|
r = eng->RegisterObjectMethod("StartupScreenHelper",
|
||||||
"int GetNumReportLines()",
|
"int GetNumReportLines()",
|
||||||
asMETHOD(gui::StartupScreenHelper, GetNumReportLines),
|
asMETHOD(gui::StartupScreenHelper, GetNumReportLines),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user