From 47abeec7d9af5e5fd7d54a514143eac5349f2019 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 11 Mar 2009 01:12:51 +0000 Subject: [PATCH] - Fixed: On Linux systems with ALSA but no OSS support, trying to start the sound system with snd_output default would fail instead of trying to use ALSA. SVN r1472 (trunk) --- src/sound/fmodsound.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 1a50ac250..298dc3ead 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -700,13 +700,40 @@ bool FMODSoundRenderer::Init() if (result != FMOD_OK) { Printf(TEXTCOLOR_BLUE"Setting output type '%s' failed. Using default instead. (Error %d)\n", *snd_output, result); + eval = FMOD_OUTPUTTYPE_AUTODETECT; Sys->setOutput(FMOD_OUTPUTTYPE_AUTODETECT); } } result = Sys->getNumDrivers(&driver); +#ifdef unix if (result == FMOD_OK) { + // On Linux, FMOD defaults to OSS. If OSS is not present, it doesn't + // try ALSA, it just fails. We'll try for it, but only if OSS wasn't + // explicitly specified for snd_output. + if (driver == 0 && eval == FMOD_OUTPUTTYPE_AUTODETECT) + { + FMOD_OUTPUTTYPE output; + if (FMOD_OK == Sys->getOutput(&output)) + { + if (output == FMOD_OUTPUTTYPE_OSS) + { + Printf(TEXTCOLOR_BLUE"OSS could not be initialized. Trying ALSA.\n"); + Sys->setOutput(FMOD_OUTPUTTYPE_ALSA); + result = Sys->getNumDrivers(&driver); + } + } + } + } +#endif + if (result == FMOD_OK) + { + if (driver == 0) + { + Printf(TEXTCOLOR_ORANGE"No working sound devices found. Try a different snd_output?\n"); + return false; + } if (snd_driver >= driver) { Printf(TEXTCOLOR_BLUE"Driver %d does not exist. Using 0.\n", *snd_driver);