summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLAGonauta <lagonauta@gmail.com>2018-03-28 10:33:38 -0300
committerJan Ekström <jeebjp@gmail.com>2018-04-15 00:57:01 +0300
commitdd357a7d53aba4a8146fb466251aed162f68785a (patch)
tree49f00012b87d333058fc2517be5c7950c422fee3
parentabaab930f005d84196dc33ec14dbd128a9f6ba5c (diff)
downloadmpv-dd357a7d53aba4a8146fb466251aed162f68785a.tar.bz2
mpv-dd357a7d53aba4a8146fb466251aed162f68785a.tar.xz
ao/openal: Add support for direct channels output
Uses OpenAL Soft's AL_DIRECT_CHANNELS_SOFT extension and can be controlled through a new CLI option, --openal-direct-channels. This allows one to send the audio data direrctly to the desired channel without effects applied.
-rw-r--r--DOCS/man/ao.rst6
-rw-r--r--audio/out/ao_openal.c10
2 files changed, 16 insertions, 0 deletions
diff --git a/DOCS/man/ao.rst b/DOCS/man/ao.rst
index b50cbc6b6b..5beca55384 100644
--- a/DOCS/man/ao.rst
+++ b/DOCS/man/ao.rst
@@ -112,6 +112,12 @@ Available audio output drivers are:
``openal``
Experimental OpenAL audio output driver
+ ``--openal-direct-channels=<yes|no>``
+ 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.
+
.. note:: This driver is not very useful. Playing multi-channel audio with
it is slow.
diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c
index 3638bbabbd..ab61c80763 100644
--- a/audio/out/ao_openal.c
+++ b/audio/out/ao_openal.c
@@ -70,6 +70,7 @@ static struct ao *ao_data;
struct priv {
ALenum al_format;
int chunk_size;
+ int direct_channels;
};
static void reset(struct ao *ao);
@@ -308,6 +309,10 @@ 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);
+ }
+
cur_buf = 0;
unqueue_buf = 0;
alGenBuffers(NUM_BUF, buffers);
@@ -449,4 +454,9 @@ const struct ao_driver audio_out_openal = {
.reset = reset,
.drain = drain,
.priv_size = sizeof(struct priv),
+ .options = (const struct m_option[]) {
+ OPT_FLAG("direct-channels", direct_channels, 0),
+ {0}
+ },
+ .options_prefix = "openal",
};