Skip to content
Permalink
Browse files

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 #3124

* spu2-x: Create non-empty defaults for OutputApi and SdlOutputApi.
  • Loading branch information...
orbea authored and arcum42 committed Oct 7, 2019
1 parent fa096cf commit afde59bb1983fd7f9bdc6d90b36686851a37b496
Showing with 11 additions and 9 deletions.
  1. +11 −9 plugins/spu2-x/src/Linux/Config.cpp
@@ -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();
}

0 comments on commit afde59b

Please sign in to comment.
You can’t perform that action at this time.