diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 21:28:45 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 21:28:45 +0200 |
commit | de3d1f2275ef5e3ad4d789666166942ae1a2f4f2 (patch) | |
tree | f8ae5a7cb57f69f80d8f21f9b160022951a242e7 /Libraries/LibAudio | |
parent | b98c77229dbdac7b044c7b41b7fa79bb260b7b19 (diff) | |
download | serenity-de3d1f2275ef5e3ad4d789666166942ae1a2f4f2.zip |
LibAudio: Remove an unnecessary copy of sample buffers before sending them.
I missed this earlier, but *now* we're actually using the same SharedBuffer
all the way from client-side WAV reading to server-side mixing. :^)
Diffstat (limited to 'Libraries/LibAudio')
-rw-r--r-- | Libraries/LibAudio/ABuffer.h | 1 | ||||
-rw-r--r-- | Libraries/LibAudio/AClientConnection.cpp | 12 |
2 files changed, 3 insertions, 10 deletions
diff --git a/Libraries/LibAudio/ABuffer.h b/Libraries/LibAudio/ABuffer.h index 4aa23520cb..a8a7d2a580 100644 --- a/Libraries/LibAudio/ABuffer.h +++ b/Libraries/LibAudio/ABuffer.h @@ -68,6 +68,7 @@ public: const void* data() const { return m_buffer->data(); } int size_in_bytes() const { return m_buffer->size(); } int shared_buffer_id() const { return m_buffer->shared_buffer_id(); } + SharedBuffer& shared_buffer() { return *m_buffer; } private: explicit ABuffer(Vector<ASample>&& samples) diff --git a/Libraries/LibAudio/AClientConnection.cpp b/Libraries/LibAudio/AClientConnection.cpp index 011f416172..0cb64578b2 100644 --- a/Libraries/LibAudio/AClientConnection.cpp +++ b/Libraries/LibAudio/AClientConnection.cpp @@ -19,17 +19,9 @@ void AClientConnection::handshake() void AClientConnection::play(const ABuffer& buffer, bool block) { - auto shared_buf = SharedBuffer::create_with_size(buffer.size_in_bytes()); - if (!shared_buf) { - dbg() << "Failed to create a shared buffer!"; - return; - } - - memcpy(shared_buf->data(), buffer.data(), buffer.size_in_bytes()); - shared_buf->seal(); - shared_buf->share_with(server_pid()); + const_cast<ABuffer&>(buffer).shared_buffer().share_with(server_pid()); ASAPI_ClientMessage request; request.type = ASAPI_ClientMessage::Type::PlayBuffer; - request.play_buffer.buffer_id = shared_buf->shared_buffer_id(); + request.play_buffer.buffer_id = buffer.shared_buffer_id(); sync_request(request, block ? ASAPI_ServerMessage::Type::FinishedPlayingBuffer : ASAPI_ServerMessage::Type::PlayingBuffer); } |