diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index 5b7d855105..60ab6ba293 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -21,9 +21,15 @@ #include "audioManager.h" #include "atomicAdjust.h" #include "nullAudioManager.h" - +#include "windowsRegistry.h" +#include "virtualFileSystem.h" +#include "config_util.h" #include "load_dso.h" +#ifdef WIN32 +#include // For GetSystemDirectory() +#endif + TypeHandle AudioManager::_type_handle; @@ -287,3 +293,47 @@ float AudioManager::audio_3d_get_drop_off_factor() const { // intentionally blank. return 0.0f; } + +//////////////////////////////////////////////////////////////////// +// Function: AudioManager::get_dls_pathname +// Access: Public +// Description: Returns the full pathname to the DLS file, as +// specified by the Config.prc file, or the default for +// the current OS if appropriate. Returns empty string +// if the DLS file is unavailable. +//////////////////////////////////////////////////////////////////// +Filename AudioManager:: +get_dls_pathname() { + Filename dls_filename = audio_dls_file; + if (!dls_filename.empty()) { + VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); + vfs->resolve_filename(dls_filename, get_sound_path()) || + vfs->resolve_filename(dls_filename, get_model_path()); + + return dls_filename; + } + +#ifdef WIN32 + Filename pathname; + + // Get the registry key from DirectMusic + string os_filename = WindowsRegistry::get_string_value("SOFTWARE\\Microsoft\\DirectMusic", "GMFilePath", ""); + + if (!os_filename.empty()) { + pathname = Filename::from_os_specific(os_filename); + } else { + char sysdir[MAX_PATH+1]; + GetSystemDirectory(sysdir,MAX_PATH+1); + pathname = Filename(Filename::from_os_specific(sysdir), Filename("drivers/gm.dls")); + } + pathname.make_true_case(); + return pathname; + +#elif defined(IS_OSX) + // This appears to be the standard place for this file on OSX 10.4. + return Filename("/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls"); + +#else + return Filename(); +#endif +} diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index f51628870e..f2ffc6eb30 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -216,6 +216,8 @@ PUBLISHED: virtual void audio_3d_set_drop_off_factor(float factor); virtual float audio_3d_get_drop_off_factor() const; + Filename get_dls_pathname(); + public: static void register_AudioManager_creator(Create_AudioManager_proc* proc); diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 4b675ae973..e76d2128eb 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -156,13 +156,9 @@ FmodAudioManager() { memset(&_midi_info, 0, sizeof(_midi_info)); _midi_info.cbsize = sizeof(_midi_info); - Filename dls_filename = audio_dls_file; - if (!dls_filename.empty()) { - VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - vfs->resolve_filename(dls_filename, get_sound_path()) || - vfs->resolve_filename(dls_filename, get_model_path()); - - _dlsname = dls_filename.to_os_specific(); + Filename dls_pathname = get_dls_pathname(); + if (!dls_pathname.empty()) { + _dlsname = dls_pathname.to_os_specific(); _midi_info.dlsname = _dlsname.c_str(); } } diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index 17e4f148e2..a6b83df86c 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -109,13 +109,12 @@ MilesAudioManager() { if (dls == NULL) { audio_error(" Unable to open DLS. " << AIL_last_error()); } else { - string dls_file; - get_gm_file_path(dls_file); - audio_debug(" dls_file=\""<