diff options
| author | Marcelo Fernandez | 2018-04-15 11:29:16 -0300 |
|---|---|---|
| committer | Your Name | 2018-05-01 22:04:51 +0200 |
| commit | 4fe0a8efd84e459804021502270daf2f937cabfb (patch) | |
| tree | b77c040fbb4bc607e3fc787bce5b2ecee98f9ad8 /drivers/pulseaudio/audio_driver_pulseaudio.cpp | |
| parent | 0551c5c2cd3e18f00ff71049a1eaa3abd95a1d40 (diff) | |
| download | godot-4fe0a8efd84e459804021502270daf2f937cabfb.tar.gz godot-4fe0a8efd84e459804021502270daf2f937cabfb.tar.zst godot-4fe0a8efd84e459804021502270daf2f937cabfb.zip | |
Fixed high cpu usage with PulseAudio
(cherry picked from commit 11078101db321ba94334d349caf3ff4778f4c18e)
Diffstat (limited to 'drivers/pulseaudio/audio_driver_pulseaudio.cpp')
| -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 0f91c9453..733c7cc80 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; |
