diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4d0ca918a..324f1a2438 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -475,7 +475,7 @@ jobs: - name: Setup emsdk uses: mymindstorm/setup-emsdk@v14 with: - version: 3.1.51 + version: 3.1.65 actions-cache-folder: 'emsdk-cache' - name: Build for Emscripten diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index aed7e55079..2e4ce0b0cd 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2508,7 +2508,8 @@ def WriteConfigSettings(): dtool_config["PYTHON_FRAMEWORK"] = 'Python' dtool_config["PHAVE_MALLOC_H"] = 'UNDEF' dtool_config["PHAVE_SYS_MALLOC_H"] = '1' - dtool_config["HAVE_OPENAL_FRAMEWORK"] = '1' + if not os.path.isdir(GetThirdpartyDir() + "openal"): + dtool_config["HAVE_OPENAL_FRAMEWORK"] = '1' dtool_config["HAVE_X11"] = 'UNDEF' # We might have X11, but we don't need it. dtool_config["IS_LINUX"] = 'UNDEF' dtool_config["HAVE_VIDEO4LINUX"] = 'UNDEF' diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index d483b40d75..de128896e6 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -75,6 +75,13 @@ ConfigVariableInt audio_preload_threshold "practical to stream multiple sound-files from disk at the same " "time - the hard drive seek time makes it stutter.")); +ConfigVariableBool audio_want_hrtf +("audio-want-hrtf", true, + PRC_DESC("This determines whether OpenAL-Soft should activate HRTF in " + "certain hardware configurations. Set it to true to cause " + "OpenAL to automatically apply HRTF processing to all output " + "audio when headphones are used for playback.")); + // Unknown ConfigVariableInt audio_min_hw_channels diff --git a/panda/src/audio/config_audio.h b/panda/src/audio/config_audio.h index deac9704be..4e5c428e92 100644 --- a/panda/src/audio/config_audio.h +++ b/panda/src/audio/config_audio.h @@ -67,6 +67,7 @@ extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_distance_factor; extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_drop_off_factor; extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_buffering_seconds; extern EXPCL_PANDA_AUDIO ConfigVariableInt audio_preload_threshold; +extern EXPCL_PANDA_AUDIO ConfigVariableBool audio_want_hrtf; #ifdef NOTIFY_DEBUG //[ // Non-release build: diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 0e6e06d16a..5df2d0d880 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -155,7 +155,22 @@ OpenALAudioManager() { if (_device != nullptr) { // We managed to get a device open. alcGetError(_device); // clear errors - _context = alcCreateContext(_device, nullptr); + + ALCboolean is_hrtf_present = alcIsExtensionPresent(_device, "ALC_SOFT_HRTF"); + + ALCint attrs[3] = {0}; + +#ifndef HAVE_OPENAL_FRAMEWORK + if (is_hrtf_present) { + attrs[0] = ALC_HRTF_SOFT; + attrs[1] = audio_want_hrtf.get_value() ? ALC_TRUE : ALC_FALSE; + attrs[2] = 0; // end of list + } else { + attrs[0] = 0; // end of list + } +#endif // HAVE_OPENAL_FRAMEWORK + + _context = alcCreateContext(_device, attrs); alc_audio_errcheck("alcCreateContext(_device, NULL)", _device); if (_context != nullptr) { _openal_active = true; diff --git a/panda/src/audiotraits/openalAudioManager.h b/panda/src/audiotraits/openalAudioManager.h index 3970c50627..56b01afc6c 100644 --- a/panda/src/audiotraits/openalAudioManager.h +++ b/panda/src/audiotraits/openalAudioManager.h @@ -29,6 +29,7 @@ #else #include #include + #include #endif class OpenALAudioSound; diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index cc643ac20c..6dc30a936c 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -27,6 +27,7 @@ #else #include #include + #include #endif class EXPCL_OPENAL_AUDIO OpenALAudioSound final : public AudioSound {