Enable OpenAL-Soft extensions for non-framework builds and add config for disabling HRTF (#1620)

This commit is contained in:
gabe 2024-10-17 15:34:32 -04:00 committed by GitHub
parent 905a7dd482
commit ad97e88a54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 29 additions and 3 deletions

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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:

View File

@ -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;

View File

@ -29,6 +29,7 @@
#else
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>
#endif
class OpenALAudioSound;

View File

@ -27,6 +27,7 @@
#else
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>
#endif
class EXPCL_OPENAL_AUDIO OpenALAudioSound final : public AudioSound {