mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
added dynamic sound lib
This commit is contained in:
parent
dfc6b42a17
commit
f08c38a4ae
@ -20,18 +20,59 @@
|
|||||||
#include "config_audio.h"
|
#include "config_audio.h"
|
||||||
#include "audioManager.h"
|
#include "audioManager.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOUNDCARD_H
|
#include "nullAudioManager.h"
|
||||||
#include "linuxAudioManager.h"
|
|
||||||
#elif defined(HAVE_RAD_MSS)
|
|
||||||
#include "milesAudioManager.h"
|
|
||||||
#else
|
|
||||||
#include "nullAudioManager.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#include "load_dso.h"
|
||||||
|
|
||||||
// Factory method for getting a platform specific AudioManager:
|
namespace {
|
||||||
AudioManager* AudioManager::create_AudioManager() {
|
AudioManager* create_NullAudioManger() {
|
||||||
return new NAME_MACRO_FOR_AUDIO_MANAGER();
|
audio_debug("create_NullAudioManger()");
|
||||||
|
return new NullAudioManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Create_AudioManager_proc* AudioManager::_create_AudioManager=create_NullAudioManger;
|
||||||
|
|
||||||
|
void AudioManager::
|
||||||
|
register_AudioManager_creator(Create_AudioManager_proc* proc) {
|
||||||
|
nassertv(_create_AudioManager==create_NullAudioManger);
|
||||||
|
_create_AudioManager=proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Factory method for getting a platform specific AudioManager:
|
||||||
|
AudioManager* AudioManager::
|
||||||
|
create_AudioManager() {
|
||||||
|
audio_debug("create_AudioManager()\n audio_library_name=\""
|
||||||
|
<<*audio_library_name<<"\"");
|
||||||
|
static lib_load;
|
||||||
|
if (!lib_load) {
|
||||||
|
lib_load=1;
|
||||||
|
if (!audio_library_name->empty() && *audio_library_name != "null") {
|
||||||
|
Filename dl_name = Filename::dso_filename("lib"+*audio_library_name+".so");
|
||||||
|
dl_name.to_os_specific();
|
||||||
|
audio_debug(" dl_name=\""<<dl_name<<"\"");
|
||||||
|
void* lib = load_dso(dl_name);
|
||||||
|
if (!lib) {
|
||||||
|
audio_error(" LoadLibrary() failed, will use NullAudioManager");
|
||||||
|
audio_error(" "<<load_dso_error());
|
||||||
|
nassertr(_create_AudioManager==create_NullAudioManger, 0);
|
||||||
|
} else {
|
||||||
|
// ...the library will register itself with the AudioManager.
|
||||||
|
#if defined(WIN32) && !defined(NDEBUG) //[
|
||||||
|
const int bufLen=256;
|
||||||
|
char path[bufLen];
|
||||||
|
DWORD count = GetModuleFileName((HMODULE)lib, path, bufLen);
|
||||||
|
if (count) {
|
||||||
|
audio_debug(" GetModuleFileName() \""<<path<<"\"");
|
||||||
|
} else {
|
||||||
|
audio_debug(" GetModuleFileName() failed.");
|
||||||
|
}
|
||||||
|
#endif //]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (*_create_AudioManager)();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
#include "config_audio.h"
|
#include "config_audio.h"
|
||||||
#include "audioSound.h"
|
#include "audioSound.h"
|
||||||
|
|
||||||
|
typedef AudioManager* Create_AudioManager_proc();
|
||||||
|
|
||||||
|
|
||||||
class EXPCL_PANDA AudioManager {
|
class EXPCL_PANDA AudioManager {
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
// Create an AudioManager for each category of sounds you have.
|
// Create an AudioManager for each category of sounds you have.
|
||||||
@ -62,7 +65,12 @@ PUBLISHED:
|
|||||||
virtual void set_active(bool flag) = 0;
|
virtual void set_active(bool flag) = 0;
|
||||||
virtual bool get_active() = 0;
|
virtual bool get_active() = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void register_AudioManager_creator(Create_AudioManager_proc* proc);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static Create_AudioManager_proc* _create_AudioManager;
|
||||||
|
|
||||||
AudioManager() {
|
AudioManager() {
|
||||||
// intentionally blank.
|
// intentionally blank.
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user