16 #include "config_audio.h" 17 #include "audioManager.h" 18 #include "atomicAdjust.h" 19 #include "nullAudioManager.h" 20 #include "windowsRegistry.h" 21 #include "virtualFileSystem.h" 22 #include "config_util.h" 35 audio_debug(
"create_NullAudioManager()");
40 Create_AudioManager_proc* AudioManager::_create_AudioManager
41 =create_NullAudioManager;
43 void AudioManager::register_AudioManager_creator(Create_AudioManager_proc* proc) {
44 nassertv(_create_AudioManager==create_NullAudioManager);
45 _create_AudioManager=proc;
52 audio_debug(
"create_AudioManager()\n audio_library_name=\""<<audio_library_name<<
"\"");
53 static bool lib_load =
false;
56 if (!audio_library_name.empty() && !(audio_library_name ==
"null")) {
57 Filename dl_name = Filename::dso_filename(
58 "lib"+
string(audio_library_name)+
".so");
60 audio_debug(
" dl_name=\""<<dl_name<<
"\"");
61 void *handle = load_dso(get_plugin_path().get_value(), dl_name);
62 if (handle == (
void *)NULL) {
63 audio_error(
" load_dso(" << dl_name <<
") failed, will use NullAudioManager");
64 audio_error(
" "<<load_dso_error());
65 nassertr(_create_AudioManager == create_NullAudioManager, NULL);
69 string lib_name = audio_library_name;
70 if (lib_name.substr(0, 2) ==
"p3") {
71 lib_name = lib_name.substr(2);
73 string symbol_name =
"get_audio_manager_func_" + lib_name;
74 void *dso_symbol = get_dso_symbol(handle, symbol_name);
75 if (audio_cat.is_debug()) {
77 <<
"symbol of " << symbol_name <<
" = " << dso_symbol <<
"\n";
80 if (dso_symbol == (
void *)NULL) {
84 audio_error(
" Audio library did not provide get_audio_manager_func, will use NullAudioManager");
86 typedef Create_AudioManager_proc *FuncType();
87 Create_AudioManager_proc *factory_func = (*(FuncType *)dso_symbol)();
88 AudioManager::register_AudioManager_creator(factory_func);
94 if (!am->is_exact_type(NullAudioManager::get_class_type()) && !am->is_valid()) {
95 audio_error(
" " << am->get_type() <<
" is not valid, will use NullAudioManager");
96 am = create_NullAudioManager();
150 if (result != NULL) {
152 nassertr(_null_sound != new_sound, NULL);
153 unref_delete(new_sound);
155 nassertr(_null_sound != NULL, NULL);
178 setSpeakerSetup(SpeakerModeCategory cat) {
220 void AudioManager::audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) {
229 void AudioManager::audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) {
238 void AudioManager::audio_3d_set_distance_factor(PN_stdfloat factor) {
247 PN_stdfloat AudioManager::audio_3d_get_distance_factor()
const {
257 void AudioManager::audio_3d_set_doppler_factor(PN_stdfloat factor) {
266 PN_stdfloat AudioManager::audio_3d_get_doppler_factor()
const {
276 void AudioManager::audio_3d_set_drop_off_factor(PN_stdfloat factor) {
285 PN_stdfloat AudioManager::audio_3d_get_drop_off_factor()
const {
300 Filename dls_filename = audio_dls_file;
301 if (!dls_filename.empty()) {
312 string os_filename = WindowsRegistry::get_string_value(
"SOFTWARE\\Microsoft\\DirectMusic",
"GMFilePath",
"");
314 if (!os_filename.empty()) {
317 char sysdir[MAX_PATH+1];
318 GetSystemDirectory(sysdir,MAX_PATH+1);
324 #elif defined(IS_OSX) 326 return Filename(
"/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls");
339 output(ostream &out)
const {
349 write(ostream &out)
const {
350 out << (*this) <<
"\n";
This is the base class for all three-component vectors and points.
bool resolve_filename(Filename &filename, const DSearchPath &searchpath, const string &default_extension=string()) const
Searches the given search path for the filename.
virtual bool configure_filters(FilterProperties *config)
Configures the global DSP filter chain.
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS's file system.
static Filename get_dls_pathname()
Returns the full pathname to the DLS file, as specified by the Config.prc file, or the default for th...
Stores a configuration for a set of audio DSP filters.
bool make_true_case()
On a case-insensitive operating system (e.g.
const ConfigVector & get_config()
Intended for use by AudioManager and AudioSound implementations: allows access to the config vector...
virtual void update()
Must be called every frame.
The name of a file, such as a texture file or an Egg file.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
void ref() const
Explicitly increments the reference count.
virtual void shutdown()
Call this at exit time to shut down the audio system.
TypeHandle is the identifier used to differentiate C++ class types.
string to_os_specific() const
Converts the filename from our generic Unix-like convention (forward slashes starting with the root a...
virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=NULL, LVecBase3 *speaker3=NULL, LVecBase3 *speaker4=NULL, LVecBase3 *speaker5=NULL, LVecBase3 *speaker6=NULL, LVecBase3 *speaker7=NULL, LVecBase3 *speaker8=NULL, LVecBase3 *speaker9=NULL)
For use only with Miles.
static Pointer compare_and_exchange_ptr(Pointer &mem, Pointer old_value, Pointer new_value)
Atomic compare and exchange.
static Filename from_os_specific(const string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes, and no drive letter) based on the supplied filename string that describes a filename in the local system conventions (for instance, on Windows, it may use backslashes or begin with a drive letter and a colon).