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.
This commit is contained in:
parent
c8ced9f11d
commit
9d00db618d
Notes:
sideshowbarker
2024-07-18 10:21:57 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/9d00db618da Pull-request: https://github.com/SerenityOS/serenity/pull/8456
2 changed files with 10 additions and 4 deletions
Userland/Libraries/LibAudio
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue