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
commit 4c8341d080
Notes: sideshowbarker 2024-07-19 11:40:44 +09:00
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();
}