Merge pull request #18215 from marcelofg55/pulseaudio_latency

Fixed high cpu usage with PulseAudio
This commit is contained in:
Rémi Verschelde 2018-04-17 09:40:08 +02:00 committed by GitHub
commit 3d12d38d16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -177,7 +177,11 @@ Error AudioDriverPulseAudio::init_device() {
pa_buffer_attr attr;
// set to appropriate buffer length (in bytes) from global settings
attr.tlength = pa_buffer_size * sizeof(int16_t);
// Note: PulseAudio defaults to 4 fragments, which means that the actual
// latency is tlength / fragments. It seems that the PulseAudio has no way
// to get the fragments number so we're hardcoding this to the default of 4
const int fragments = 4;
attr.tlength = pa_buffer_size * sizeof(int16_t) * fragments;
// set them to be automatically chosen
attr.prebuf = (uint32_t)-1;
attr.maxlength = (uint32_t)-1;