summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Fernandez <marcelofg55@gmail.com>2018-04-15 11:29:16 -0300
committerMarcelo Fernandez <marcelofg55@gmail.com>2018-04-15 11:29:16 -0300
commit11078101db321ba94334d349caf3ff4778f4c18e (patch)
treee5554bc766f7425e7580e55432ff7302e57b51b1
parentecab0ea959665e7cceca481577bd0ea81cccd3bb (diff)
Fixed high cpu usage with PulseAudio
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp6
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;