1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibAudio: Fixed stuttery playback of audio

When playing an ABuffer, the count of samples were determined by the
size of the SharedBuffer. This caused small pauses of up to 512
samples during the playback, when the size of the shared buffer was
rounded up to a multiple of 4096. This problem was amplified by the
fact that the AResampleHelper was created every time a new chunk of
audio was to be processed, causing inconsistencies in the playback of
wav files.
This commit is contained in:
Till Mayer 2019-10-16 15:31:01 +02:00 committed by Andreas Kling
parent 7e97e1c5d9
commit 4c8341d080
6 changed files with 78 additions and 62 deletions

View file

@ -18,7 +18,7 @@ void AClientConnection::enqueue(const ABuffer& buffer)
{
for (;;) {
const_cast<ABuffer&>(buffer).shared_buffer().share_with(server_pid());
auto response = send_sync<AudioServer::EnqueueBuffer>(buffer.shared_buffer_id());
auto response = send_sync<AudioServer::EnqueueBuffer>(buffer.shared_buffer_id(), buffer.sample_count());
if (response->success())
break;
sleep(1);
@ -28,7 +28,7 @@ void AClientConnection::enqueue(const ABuffer& buffer)
bool AClientConnection::try_enqueue(const ABuffer& buffer)
{
const_cast<ABuffer&>(buffer).shared_buffer().share_with(server_pid());
auto response = send_sync<AudioServer::EnqueueBuffer>(buffer.shared_buffer_id());
auto response = send_sync<AudioServer::EnqueueBuffer>(buffer.shared_buffer_id(), buffer.sample_count());
return response->success();
}