diff options
author | kleines Filmröllchen <malu.bertsch@gmail.com> | 2021-07-05 14:40:02 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-05 19:33:55 +0200 |
commit | 9d00db618da3d10abc93ade84774be32170f232c (patch) | |
tree | 2440171779eae968f99fb03324192ad91ec4dc33 /Userland/Libraries/LibAudio | |
parent | c8ced9f11d9194635f6ce09826736619ac42562b (diff) | |
download | serenity-9d00db618da3d10abc93ade84774be32170f232c.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibAudio')
-rw-r--r-- | Userland/Libraries/LibAudio/ClientConnection.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibAudio/ClientConnection.h | 5 |
2 files changed, 10 insertions, 4 deletions
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<void(i32 buffer_id)> on_finish_playing_buffer; Function<void(bool muted)> on_muted_state_change; |