fix valid sound driver config values + faudio fix

Fix name of FAudio option XRC control: "FAudio" and not "Faudio".

Create list of valid sound driver options by using macros for the ones
that are compiled in (with windows being a special case.)
This commit is contained in:
Rafael Kitover 2018-12-26 06:09:29 -08:00
parent 1f4487b836
commit 296e8e1693
3 changed files with 29 additions and 12 deletions

View File

@ -3442,7 +3442,7 @@ bool MainFrame::BindControls()
#if !defined(__WXMSW__) || defined(NO_XAUDIO2)
rb->Hide();
#endif
audapi_rb("Faudio", AUD_FAUDIO);
audapi_rb("FAudio", AUD_FAUDIO);
#ifdef NO_FAUDIO
rb->Hide();
#endif

View File

@ -254,18 +254,29 @@ opt_desc opts[] = {
INTOPT("preferences/vsync", "VSync", wxTRANSLATE("Wait for vertical sync"), vsync, 0, 1),
/// Sound
#define OAL_SOUND "openal|"
#ifdef NO_OAL
#ifdef __WXMSW__
ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl|directsound|faudio|xaudio2")),
#else
ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl")),
#endif
# define OAL_SOUND ""
#endif
#define XAUDIO2_SOUND "xaudio2|"
#ifdef NO_XAUDIO2
# define XAUDIO2_SOUND ""
#endif
#define FAUDIO_SOUND "faudio|"
#ifdef NO_FAUDIO
# define FAUDIO_SOUND ""
#endif
#ifdef __WXMSW__
ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl|" OAL_SOUND "directsound|" FAUDIO_SOUND "xaudio2")),
#else
#ifdef __WXMSW__
ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl|openal|directsound|faudio|xaudio2")),
#else
ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl|openal")),
#endif
ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl" OAL_SOUND FAUDIO_SOUND)),
#endif
INTOPT("Sound/Buffers", "", wxTRANSLATE("Number of sound buffers"), gopts.audio_buffers, 2, 10),
INTOPT("Sound/Enable", "", wxTRANSLATE("Bit mask of sound channels to enable"), gopts.sound_en, 0, 0x30f),

View File

@ -5,12 +5,18 @@
#include "strutils.h"
// From: https://stackoverflow.com/a/7408245/262458
//
// modified to ignore empty tokens
std::vector<wxString> str_split(const wxString& text, const wxString& sep) {
std::vector<wxString> tokens;
std::size_t start = 0, end = 0;
while ((end = text.find(sep, start)) != std::string::npos) {
tokens.push_back(text.substr(start, end - start));
wxString token = text.substr(start, end - start);
if (token.length())
tokens.push_back(token);
start = end + 1;
}