diff options
author | wm4 <wm4@nowhere> | 2017-11-29 21:30:10 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-11-29 21:30:51 +0100 |
commit | d725630b5f5817287d44cb31c3c7b9d815c187db (patch) | |
tree | 6c54b58b8bb3a4bfc25e0eafb253266a3a10f766 /audio/out/ao.h | |
parent | 9c909fbb4d4abeabe9ac6731cb0c3f966dacf0ff (diff) | |
download | mpv-d725630b5f5817287d44cb31c3c7b9d815c187db.tar.bz2 mpv-d725630b5f5817287d44cb31c3c7b9d815c187db.tar.xz |
audio: add audio softvol processing to AO
This does what af_volume used to do. Since we couldn't relicense it,
just rewrite it. Since we don't have a new filter mechanism yet, and the
libavfilter is too inconvenient, do applying the volume gain in ao.c
directly. This is done before handling the audio data to the driver.
Since push.c runs a separate thread, and pull.c is called asynchronously
from the audio driver's thread, the volume value needs to be
synchronized. There's no existing central mutex, so do some shit with
atomics. Since there's no atomic_float type predefined (which is at
least needed when using the legacy wrapper), do some nonsense about
reinterpret casting the float value to an int for the purpose of atomic
access. Not sure if using memcpy() is undefined behavior, but for now I
don't care.
The advantage of not using a filter is lower complexity (no filter auto
insertion), and lower latency (gain processing is done after our
internal audio buffer of at least 200ms).
Disavdantages include inability to use native volume control _before_
other filters with custom filter chains, and the need to add new
processing for each new sample type.
Since this doesn't reuse any of the old GPL code, nor does indirectly
rely on it, volume and replaygain handling now works in LGPL mode.
How to process the gain is inspired by libavfilter's af_volume (LGPL).
In particular, we use exactly the same rounding, and we quantize
processing for integer sample types by 256 steps. Some of libavfilter's
copyright may or may not apply, but I think not, and it's the same
license anyway.
Diffstat (limited to 'audio/out/ao.h')
-rw-r--r-- | audio/out/ao.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/audio/out/ao.h b/audio/out/ao.h index 116733fb39..b9df4ebb00 100644 --- a/audio/out/ao.h +++ b/audio/out/ao.h @@ -95,6 +95,7 @@ const char *ao_get_description(struct ao *ao); bool ao_untimed(struct ao *ao); int ao_play(struct ao *ao, void **data, int samples, int flags); int ao_control(struct ao *ao, enum aocontrol cmd, void *arg); +void ao_set_gain(struct ao *ao, float gain); double ao_get_delay(struct ao *ao); int ao_get_space(struct ao *ao); void ao_reset(struct ao *ao); |