spu2-x: Fix crash with an invalid output module. (#3125)

* spu2-x: Fix crash with an invalid output module.

This will default to SDLOut.

Fixes https://github.com/PCSX2/pcsx2/issues/3124

* spu2-x: Create non-empty defaults for OutputApi and SdlOutputApi.
This commit is contained in:
orbea 2019-10-07 01:05:19 +00:00 committed by arcum42
parent fa096cfce0
commit afde59bb19
1 changed files with 11 additions and 9 deletions

View File

@ -132,24 +132,20 @@ void ReadSettings()
// find current API
#ifdef __linux__
CfgReadStr(L"PORTAUDIO", L"HostApi", temp, L"ALSA");
OutputAPI = -1;
if (temp == L"ALSA")
OutputAPI = 0;
if (temp == L"OSS")
OutputAPI = 1;
if (temp == L"JACK")
else if (temp == L"JACK")
OutputAPI = 2;
else // L"ALSA"
OutputAPI = 0;
#else
CfgReadStr(L"PORTAUDIO", L"HostApi", temp, L"OSS");
OutputAPI = -1;
if (temp == L"OSS")
OutputAPI = 0;
OutputAPI = 0; // L"OSS"
#endif
#ifdef __unix__
CfgReadStr(L"SDL", L"HostApi", temp, L"pulseaudio");
SdlOutputAPI = -1;
SdlOutputAPI = 0;
#if SDL_MAJOR_VERSION >= 2
// YES It sucks ...
for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
@ -174,6 +170,12 @@ void ReadSettings()
Clampify(SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX);
if (mods[OutputModule] == NULL) {
fwprintf(stderr, L"* SPU2-X: Unknown output module '%s' specified in configuration file.\n", temp.wc_str());
fprintf(stderr, "* SPU2-X: Defaulting to SDL (%S).\n", SDLOut->GetIdent());
OutputModule = FindOutputModuleById(SDLOut->GetIdent());
}
WriteSettings();
spuConfig->Flush();
}