From 87ce3b31a92a9bd0b4c4406113586696dc573f2a Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 20 Nov 2021 01:17:01 +0200 Subject: [PATCH] ao_openal: enable AL_SOFT_direct_channels_remix extension by default Prevent audio distortions caused by OpenAL's 3D effects. --- DOCS/man/ao.rst | 4 +--- audio/out/ao_openal.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/DOCS/man/ao.rst b/DOCS/man/ao.rst index e5cc9f963d..cc4cea0036 100644 --- a/DOCS/man/ao.rst +++ b/DOCS/man/ao.rst @@ -112,9 +112,7 @@ Available audio output drivers are: ``--openal-direct-channels=`` Enable OpenAL Soft's direct channel extension when available to avoid - tinting the sound with ambisonics or HRTF. - Channels are dropped when when they are not available as downmixing - will be disabled. Default: no. + tinting the sound with ambisonics or HRTF. Default: yes. ``pulse`` PulseAudio audio output driver diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c index ca36230ea2..6b2e3bc176 100644 --- a/audio/out/ao_openal.c +++ b/audio/out/ao_openal.c @@ -199,8 +199,14 @@ static int init(struct ao *ao) alListenerfv(AL_ORIENTATION, direction); alGenSources(1, &source); - if (p->direct_channels && alGetEnumValue((ALchar*)"AL_DIRECT_CHANNELS_SOFT")) { - alSourcei(source, alGetEnumValue((ALchar*)"AL_DIRECT_CHANNELS_SOFT"), AL_TRUE); + if (p->direct_channels) { + if (alIsExtensionPresent("AL_SOFT_direct_channels_remix")) { + alSourcei(source, + alGetEnumValue((ALchar*)"AL_DIRECT_CHANNELS_SOFT"), + alcGetEnumValue(dev, "AL_REMIX_UNMATCHED_SOFT")); + } else { + MP_WARN(ao, "Direct channels aren't supported by this version of OpenAL\n"); + } } cur_buf = 0; @@ -385,7 +391,7 @@ const struct ao_driver audio_out_openal = { .priv_defaults = &(const struct priv) { .num_buffers = 4, .num_samples = 8192, - .direct_channels = 0, + .direct_channels = 1, }, .options = (const struct m_option[]) { {"num-buffers", OPT_INT(num_buffers), M_RANGE(2, MAX_BUF)},