diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-04-17 09:40:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 09:40:08 +0200 |
commit | 3d12d38d161bc31cb8d50d31775a15a708e38096 (patch) | |
tree | 96264c4bfa110dfef4c39dfadd5a4e5b8168db9b /drivers | |
parent | 7b5703bc41460c5c8b955f879190625da85a2a81 (diff) | |
parent | 11078101db321ba94334d349caf3ff4778f4c18e (diff) |
Merge pull request #18215 from marcelofg55/pulseaudio_latency
Fixed high cpu usage with PulseAudio
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pulseaudio/audio_driver_pulseaudio.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 0f91c94539..733c7cc80c 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -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; |