From 9d00db618da3d10abc93ade84774be32170f232c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Mon, 5 Jul 2021 14:40:02 +0200 Subject: LibAudio: Add ClientConnection::async_enqueue() async_enqueue() is a wrapper over the async_enqueue_buffer() call to AudioServer. This allows users to asyncronously enqueue audio samples, when the program requires non-blocking audio streaming. This also makes ClientConnection use east-const everywhere. --- Userland/Libraries/LibAudio/ClientConnection.cpp | 9 +++++++-- Userland/Libraries/LibAudio/ClientConnection.h | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibAudio/ClientConnection.cpp b/Userland/Libraries/LibAudio/ClientConnection.cpp index b7875bc25e..81e69e14df 100644 --- a/Userland/Libraries/LibAudio/ClientConnection.cpp +++ b/Userland/Libraries/LibAudio/ClientConnection.cpp @@ -14,7 +14,7 @@ ClientConnection::ClientConnection() { } -void ClientConnection::enqueue(const Buffer& buffer) +void ClientConnection::enqueue(Buffer const& buffer) { for (;;) { auto success = enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); @@ -26,7 +26,12 @@ void ClientConnection::enqueue(const Buffer& buffer) } } -bool ClientConnection::try_enqueue(const Buffer& buffer) +void ClientConnection::async_enqueue(Buffer const& buffer) +{ + async_enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); +} + +bool ClientConnection::try_enqueue(Buffer const& buffer) { return enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); } diff --git a/Userland/Libraries/LibAudio/ClientConnection.h b/Userland/Libraries/LibAudio/ClientConnection.h index f9c0a1dca3..b69696642b 100644 --- a/Userland/Libraries/LibAudio/ClientConnection.h +++ b/Userland/Libraries/LibAudio/ClientConnection.h @@ -21,8 +21,9 @@ class ClientConnection final public: ClientConnection(); - void enqueue(const Buffer&); - bool try_enqueue(const Buffer&); + void enqueue(Buffer const&); + bool try_enqueue(Buffer const&); + void async_enqueue(Buffer const&); Function on_finish_playing_buffer; Function on_muted_state_change; -- cgit v1.2.3