1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

AudioServer+LibAudio: Make mixing queue-based instead of buffer-based.

Each client connection now sets up an ASBufferQueue, which is basically a
queue of ABuffers. This allows us to immediately start streaming the next
pending buffer whenever our current buffer runs out of samples.

This makes the majority of the skippiness go away for me. :^)

Also get rid of the old PlayBuffer API, since we don't need it anymore.
This commit is contained in:
Andreas Kling 2019-07-28 21:27:18 +02:00
parent 66db6f4f92
commit be31e2232c
7 changed files with 78 additions and 112 deletions

View file

@ -17,15 +17,6 @@ void AClientConnection::handshake()
set_my_client_id(response.greeting.your_client_id);
}
void AClientConnection::play(const ABuffer& buffer, bool block)
{
const_cast<ABuffer&>(buffer).shared_buffer().share_with(server_pid());
ASAPI_ClientMessage request;
request.type = ASAPI_ClientMessage::Type::PlayBuffer;
request.play_buffer.buffer_id = buffer.shared_buffer_id();
sync_request(request, block ? ASAPI_ServerMessage::Type::FinishedPlayingBuffer : ASAPI_ServerMessage::Type::PlayingBuffer);
}
void AClientConnection::enqueue(const ABuffer& buffer)
{
for (;;) {
@ -36,7 +27,6 @@ void AClientConnection::enqueue(const ABuffer& buffer)
auto response = sync_request(request, ASAPI_ServerMessage::Type::EnqueueBufferResponse);
if (response.success)
break;
dbg() << "EnqueueBuffer failed, retrying...";
sleep(1);
}
}