From 34a3d08e651d75b5f83deec0282cf54092c4d753 Mon Sep 17 00:00:00 2001 From: Nick Miller Date: Sat, 12 Jun 2021 11:54:46 -0700 Subject: [PATCH] LibAudio: Sleep less when the audio buffer is full When using `aplay` to play audio files with a sample rate of 96000, there were occasional one-second gaps in playback. This is because the Audio::ClientConnection sleeps for a full second when the audio buffer is full. One second is too long to sleep, especially for high-bitrate files. Changing the sleep to a more reasonable value like 100 ms ensures we attempt to enqueue again before the audio buffer runs empty. --- Userland/Libraries/LibAudio/ClientConnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibAudio/ClientConnection.cpp b/Userland/Libraries/LibAudio/ClientConnection.cpp index 0165b63c1e..2947dfbeb9 100644 --- a/Userland/Libraries/LibAudio/ClientConnection.cpp +++ b/Userland/Libraries/LibAudio/ClientConnection.cpp @@ -20,7 +20,7 @@ void ClientConnection::enqueue(const Buffer& buffer) auto success = enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); if (success) break; - sleep(1); + sleep(.1); } }