From aee99c2bd060141f49807499d4c2b39b2bb887ea Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 11 Mar 2009 04:56:43 +0000 Subject: [PATCH] - Added an SDL output plugin, so FMOD can produce sound using SDL's audio support instead of its own OSS/ALSA/ESD support. This is selectable by setting snd_output to "sdl". SVN r1473 (trunk) --- CMakeLists.txt | 4 ++++ docs/rh-log.txt | 6 ++++++ src/m_options.cpp | 1 + src/sound/fmodsound.cpp | 29 +++++++++++++++++++++++++++-- src/sound/fmodsound.h | 1 + 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a69195d49..4a5518c4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,3 +90,7 @@ add_subdirectory( dumb ) add_subdirectory( gdtoa ) add_subdirectory( wadsrc ) add_subdirectory( src ) + +if( NOT WIN32 ) + add_subdirectory( output_sdl ) +endif( NOT WIN32 ) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index bb64a33b8..8a57ef303 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,10 @@ March 10, 2009 +- Added an SDL output plugin, so FMOD can produce sound using SDL's audio + support instead of its own OSS/ALSA/ESD support. This is selectable by + setting snd_output to "sdl". +- 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. - Added sdl_nokeyrepeat to disable key repeating in the menus and console on Linux. - Added support for zip/pk3 files with LZMA and bzip2 compression to ZDoom. diff --git a/src/m_options.cpp b/src/m_options.cpp index 72fb5a8b1..1372b7331 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -1218,6 +1218,7 @@ static valueenum_t Outputs[] = #elif defined(unix) { "OSS", "OSS" }, { "ALSA", "ALSA" }, + { "SDL", "SDL" }, { "ESD", "ESD" }, #elif defined(__APPLE__) { "Sound Manager", "Sound Manager" }, diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 298dc3ead..c03bfe0aa 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -54,6 +54,7 @@ extern HWND Window; #include "v_text.h" #include "v_video.h" #include "v_palette.h" +#include "cmdlib.h" // MACROS ------------------------------------------------------------------ @@ -159,6 +160,7 @@ static const FEnumList OutputNames[] = { "OSS", FMOD_OUTPUTTYPE_OSS }, { "ALSA", FMOD_OUTPUTTYPE_ALSA }, { "ESD", FMOD_OUTPUTTYPE_ESD }, + { "SDL", 666 }, // Mac { "Sound Manager", FMOD_OUTPUTTYPE_SOUNDMANAGER }, @@ -612,6 +614,7 @@ bool FMODSoundRenderer::Init() ChannelGroupTargetUnit = NULL; SfxReverbHooked = false; SfxReverbPlaceholder = NULL; + OutputPlugin = 0; Printf("I_InitSound: Initializing FMOD\n"); @@ -692,11 +695,28 @@ bool FMODSoundRenderer::Init() } #endif +#ifndef _WIN32 + // Try to load SDL output plugin + result = Sys->setPluginPath(progdir); // Should we really look for it in the program directory? + result = Sys->loadPlugin("liboutput_sdl.so", &OutputPlugin); + if (result != FMOD_OK) + { + OutputPlugin = 0; + } +#endif + // Set the user specified output mode. eval = Enum_NumForName(OutputNames, snd_output); if (eval >= 0) { - result = Sys->setOutput(FMOD_OUTPUTTYPE(eval)); + if (eval == 666 && OutputPlugin != 0) + { + result = Sys->setOutputByPlugin(OutputPlugin); + } + else + { + result = Sys->setOutput(FMOD_OUTPUTTYPE(eval)); + } if (result != FMOD_OK) { Printf(TEXTCOLOR_BLUE"Setting output type '%s' failed. Using default instead. (Error %d)\n", *snd_output, result); @@ -704,7 +724,7 @@ bool FMODSoundRenderer::Init() Sys->setOutput(FMOD_OUTPUTTYPE_AUTODETECT); } } - + result = Sys->getNumDrivers(&driver); #ifdef unix if (result == FMOD_OK) @@ -1083,6 +1103,11 @@ void FMODSoundRenderer::Shutdown() } Sys->close(); + if (OutputPlugin != 0) + { + Sys->unloadPlugin(OutputPlugin); + OutputPlugin = 0; + } Sys->release(); Sys = NULL; } diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index c6f949299..e26ec44b5 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -98,6 +98,7 @@ private: FMOD::DSP *SfxReverbPlaceholder; bool SfxReverbHooked; float LastWaterLP; + unsigned int OutputPlugin; // Just for snd_status display int Driver_MinFrequency;