From: Ryan C. Gordon Date: Wed, 10 Aug 2005 19:35:52 +0000 (+0000) Subject: Try to use ALSA first, then OSS, plus command lines to change behaviour. X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=8fb50ec5e055324deda9c83f74eadfbe88338344;p=lugaru.git Try to use ALSA first, then OSS, plus command lines to change behaviour. --- diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index f1091c0..6cc47e6 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -1191,7 +1191,40 @@ void Game::InitGame() LOG("Initializing sound system..."); + int output = -1; + + #if PLATFORM_LINUX + extern bool cmdline(const char *cmd); + unsigned char rc = 0; + output = FSOUND_OUTPUT_ALSA; // Try alsa first... + if (cmdline("forceoss")) // ...but let user override that. + output = FSOUND_OUTPUT_OSS; + else if (cmdline("nosound")) + output = FSOUND_OUTPUT_NOSOUND; + + FSOUND_SetOutput(output); + if ((rc = FSOUND_Init(44100, 32, 0)) == FALSE) + { + // if we tried ALSA and failed, fall back to OSS. + if ( (output == FSOUND_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) + { + FSOUND_Close(); + output = FSOUND_OUTPUT_OSS; + FSOUND_SetOutput(output); + rc = FSOUND_Init(44100, 32, 0); + } + } + + if (rc == FALSE) + { + FSOUND_Close(); + output = FSOUND_OUTPUT_NOSOUND; // we tried! just do silence. + FSOUND_SetOutput(output); + rc = FSOUND_Init(44100, 32, 0); + } + #else FSOUND_Init(44100, 32, 0); + #endif FSOUND_SetSFXMasterVolume((int)(volume*255)); diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index 1fa7ec4..18bb2b9 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -227,7 +227,7 @@ Game * pgame = 0; static int _argc = 0; static char **_argv = NULL; -static bool cmdline(const char *cmd) +bool cmdline(const char *cmd) { for (int i = 1; i < _argc; i++) {