summaryrefslogtreecommitdiffstats
path: root/audio/out/push.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-11-29 21:30:10 +0100
committerwm4 <wm4@nowhere>2017-11-29 21:30:51 +0100
commitd725630b5f5817287d44cb31c3c7b9d815c187db (patch)
tree6c54b58b8bb3a4bfc25e0eafb253266a3a10f766 /audio/out/push.c
parent9c909fbb4d4abeabe9ac6731cb0c3f966dacf0ff (diff)
downloadmpv-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/push.c')
-rw-r--r--audio/out/push.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/audio/out/push.c b/audio/out/push.c
index 8546ec816d..1f87481183 100644
--- a/audio/out/push.c
+++ b/audio/out/push.c
@@ -304,6 +304,7 @@ static void ao_play_data(struct ao *ao)
samples = samples / ao->period_size * ao->period_size;
}
MP_STATS(ao, "start ao fill");
+ ao_post_process_data(ao, (void **)planes, samples);
int r = 0;
if (samples)
r = ao->driver->play(ao, (void **)planes, samples, flags);