From bd19b1b29a8f6d31845863b0e74844e74617338f Mon Sep 17 00:00:00 2001 From: Kyzentun Keeslala Date: Sat, 5 Mar 2016 18:11:59 -0700 Subject: [PATCH] Added global lua function for fetching the list of available sound drivers. Moved WaveOut to the front of the list to make it the first driver to try on Windows. --- Docs/Luadoc/Lua.xml | 1 + Docs/Luadoc/LuaDocumentation.xml | 3 +++ src/GameSoundManager.cpp | 19 ++++++++++++++++++- src/arch/Sound/RageSoundDriver.cpp | 5 +++++ src/arch/Sound/RageSoundDriver.h | 1 + src/arch/arch_default.h | 2 +- 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 660c376c16..9ccc9a77e4 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -222,6 +222,7 @@ + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 0522f84c28..dfa4404ba3 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -215,6 +215,9 @@ save yourself some time, copy this for undocumented things: Returns the length of the music file found at path.
If you are loading the sound into an ActorSound, ActorSound:get to get its RageSound then use RageSound's get_length function instead to avoid loading the file twice.
+ + Returns a table of the names of the sound drivers available. If the SoundDriver preference is set to something that is not in this list, StepMania WILL NOT START UP. Changes to the SoundDriver preference do not take effect until the next time StepMania starts up. + Returns a string representing the name of the operating system being used. (e.g. "Windows", "Linux", "Mac, "Unknown") diff --git a/src/GameSoundManager.cpp b/src/GameSoundManager.cpp index 41d545671e..34c810b922 100644 --- a/src/GameSoundManager.cpp +++ b/src/GameSoundManager.cpp @@ -18,6 +18,8 @@ #include "SongUtil.h" #include "LuaManager.h" +#include "arch/Sound/RageSoundDriver.h" + GameSoundManager *SOUND = NULL; /* @@ -869,7 +871,22 @@ public: } }; -LUA_REGISTER_CLASS( GameSoundManager ) +LUA_REGISTER_CLASS(GameSoundManager); + +int LuaFunc_get_sound_driver_list(lua_State* L); +int LuaFunc_get_sound_driver_list(lua_State* L) +{ + vector driver_names; + split(RageSoundDriver::GetDefaultSoundDriverList(), ",", driver_names, true); + lua_createtable(L, driver_names.size(), 0); + for(size_t n= 0; n < driver_names.size(); ++n) + { + lua_pushstring(L, driver_names[n].c_str()); + lua_rawseti(L, -2, n+1); + } + return 1; +} +LUAFUNC_REGISTER_COMMON(get_sound_driver_list); /* diff --git a/src/arch/Sound/RageSoundDriver.cpp b/src/arch/Sound/RageSoundDriver.cpp index a491a5096f..52f273422a 100644 --- a/src/arch/Sound/RageSoundDriver.cpp +++ b/src/arch/Sound/RageSoundDriver.cpp @@ -36,6 +36,11 @@ RageSoundDriver *RageSoundDriver::Create( const RString& sDrivers ) return NULL; } +RString RageSoundDriver::GetDefaultSoundDriverList() +{ + return DEFAULT_SOUND_DRIVER_LIST; +} + /* * (c) 2002-2006 Glenn Maynard, Steve Checkoway * All rights reserved. diff --git a/src/arch/Sound/RageSoundDriver.h b/src/arch/Sound/RageSoundDriver.h index c2b230926b..f173488f50 100644 --- a/src/arch/Sound/RageSoundDriver.h +++ b/src/arch/Sound/RageSoundDriver.h @@ -18,6 +18,7 @@ public: /* Pass an empty string to get the default sound driver list. */ static RageSoundDriver *Create( const RString &sDrivers ); static DriverList m_pDriverList; + static RString GetDefaultSoundDriverList(); friend class RageSoundManager; diff --git a/src/arch/arch_default.h b/src/arch/arch_default.h index fad7fed71d..48fe11a4d9 100644 --- a/src/arch/arch_default.h +++ b/src/arch/arch_default.h @@ -9,7 +9,7 @@ #include "MemoryCard/MemoryCardDriverThreaded_Windows.h" #define DEFAULT_INPUT_DRIVER_LIST "DirectInput,Pump,Para" #define DEFAULT_MOVIE_DRIVER_LIST "FFMpeg,DShow,Null" -#define DEFAULT_SOUND_DRIVER_LIST "DirectSound-sw,WDMKS,WaveOut,Null" +#define DEFAULT_SOUND_DRIVER_LIST "WaveOut,DirectSound-sw,WDMKS,Null" #elif defined(MACOSX)