summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorNicolas F <ovdev@fratti.ch>2020-06-07 20:14:01 +0200
committerJan Ekström <jeebjp@gmail.com>2020-06-07 22:16:49 +0300
commit0fb02f181f3df9e8336939b42c3412e01fb60427 (patch)
tree31c9a73e81ebdeb0979f59d5436739c4ae23d938 /audio/out
parent12415db3a60ce8a044ccc7ef510c85a1a95218e2 (diff)
downloadmpv-0fb02f181f3df9e8336939b42c3412e01fb60427.tar.bz2
mpv-0fb02f181f3df9e8336939b42c3412e01fb60427.tar.xz
ao/pulse: properly set device_buffer
Previously, device_buffer defaulted to 0 on pulse. This meant that commit baa7b5c would always wait with a timeout of 0, leading to high CPU usage for PulseAudio users. By setting device_buffer to the number of samples per channel that PulseAudio sets as its target, this commit fixes this behaviour.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_pulse.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index c826a6c993..7ffbeb43ef 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -465,6 +465,14 @@ static int init(struct ao *ao)
goto unlock_and_fail;
}
+ const pa_buffer_attr* final_bufattr = pa_stream_get_buffer_attr(priv->stream);
+ if(!final_bufattr) {
+ MP_ERR(ao, "PulseAudio didn't tell us what buffer sizes it set. Bailing out.\n");
+ goto unlock_and_fail;
+ }
+ ao->device_buffer = final_bufattr->tlength /
+ af_fmt_to_bytes(ao->format) / ao->channels.num;
+
pa_threaded_mainloop_unlock(priv->mainloop);
return 0;