36 audio_debug(
"create_NullAudioManager()");
41 Create_AudioManager_proc *AudioManager::_create_AudioManager =
nullptr;
44 register_AudioManager_creator(Create_AudioManager_proc* proc) {
45 nassertv(_create_AudioManager ==
nullptr || _create_AudioManager == proc);
46 _create_AudioManager = proc;
51 audio_debug(
"create_AudioManager()\n audio_library_name=\""<<audio_library_name<<
"\"");
53 if (_create_AudioManager !=
nullptr) {
57 if (!am->is_exact_type(NullAudioManager::get_class_type()) && !am->is_valid()) {
58 audio_error(
" " << am->get_type() <<
" is not valid, will use NullAudioManager");
59 am = create_NullAudioManager();
64 static bool lib_load =
false;
67 if (!audio_library_name.empty() && audio_library_name !=
"null") {
68 Filename dl_name = Filename::dso_filename(
69 "lib" +
string(audio_library_name) +
".so");
71 audio_debug(
" dl_name=\""<<dl_name<<
"\"");
72 void *handle = load_dso(get_plugin_path().get_value(), dl_name);
73 if (handle ==
nullptr) {
74 audio_error(
" load_dso(" << dl_name <<
") failed, will use NullAudioManager");
75 audio_error(
" "<<load_dso_error());
76 nassertr(_create_AudioManager ==
nullptr,
nullptr);
80 string lib_name = audio_library_name;
81 if (lib_name.substr(0, 2) ==
"p3") {
82 lib_name = lib_name.substr(2);
84 string symbol_name =
"get_audio_manager_func_" + lib_name;
85 void *dso_symbol = get_dso_symbol(handle, symbol_name);
86 if (audio_cat.is_debug()) {
88 <<
"symbol of " << symbol_name <<
" = " << dso_symbol <<
"\n";
91 if (dso_symbol ==
nullptr) {
95 audio_error(
" Audio library did not provide get_audio_manager_func, will use NullAudioManager");
97 typedef Create_AudioManager_proc *FuncType();
98 Create_AudioManager_proc *factory_func = (*(FuncType *)dso_symbol)();
101 if (_create_AudioManager ==
nullptr) {
102 AudioManager::register_AudioManager_creator(factory_func);
109 if (_create_AudioManager ==
nullptr) {
110 _create_AudioManager = create_NullAudioManager;
114 if (!am->is_exact_type(NullAudioManager::get_class_type()) && !am->is_valid()) {
115 audio_error(
" " << am->get_type() <<
" is not valid, will use NullAudioManager");
116 am = create_NullAudioManager();
126 if (_null_sound !=
nullptr) {
136 _null_sound =
nullptr;
156 if (_null_sound ==
nullptr) {
160 if (result !=
nullptr) {
162 nassertr(_null_sound != new_sound,
nullptr);
165 nassertr(_null_sound !=
nullptr,
nullptr);
175 get_speaker_setup() {
184 set_speaker_setup(SpeakerModeCategory cat) {
217 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) {
224 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) {
231 void AudioManager::audio_3d_set_distance_factor(PN_stdfloat factor) {
238 PN_stdfloat AudioManager::audio_3d_get_distance_factor()
const {
246 void AudioManager::audio_3d_set_doppler_factor(PN_stdfloat factor) {
253 PN_stdfloat AudioManager::audio_3d_get_doppler_factor()
const {
261 void AudioManager::audio_3d_set_drop_off_factor(PN_stdfloat factor) {
268 PN_stdfloat AudioManager::audio_3d_get_drop_off_factor()
const {
280 Filename dls_filename = audio_dls_file;
281 if (!dls_filename.empty()) {
292 string os_filename = WindowsRegistry::get_string_value(
"SOFTWARE\\Microsoft\\DirectMusic",
"GMFilePath",
"");
294 if (!os_filename.empty()) {
297 char sysdir[MAX_PATH+1];
298 GetSystemDirectory(sysdir,MAX_PATH+1);
304 #elif defined(IS_OSX)
306 return Filename(
"/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls");
317 output(std::ostream &out)
const {
325 write(std::ostream &out)
const {
326 out << (*this) <<
"\n";
333 set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2, LVecBase3 *speaker3, LVecBase3 *speaker4, LVecBase3 *speaker5, LVecBase3 *speaker6, LVecBase3 *speaker7, LVecBase3 *speaker8, LVecBase3 *speaker9) {