mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
SharedBuffer: Split the creation and share steps
This allows us to seal a buffer *before* anyone else has access to it (well, ok, the creating process still does, but you can't win them all). It also means that a SharedBuffer can be shared with multiple clients: all you need is to have access to it to share it on again.
This commit is contained in:
parent
f60d7e5d1f
commit
b907608e46
12 changed files with 58 additions and 22 deletions
|
@ -19,7 +19,7 @@ void AClientConnection::handshake()
|
|||
|
||||
void AClientConnection::play(const ABuffer& buffer)
|
||||
{
|
||||
auto shared_buf = SharedBuffer::create(server_pid(), buffer.size_in_bytes());
|
||||
auto shared_buf = SharedBuffer::create_with_size(buffer.size_in_bytes());
|
||||
if (!shared_buf) {
|
||||
dbg() << "Failed to create a shared buffer!";
|
||||
return;
|
||||
|
@ -27,6 +27,7 @@ void AClientConnection::play(const ABuffer& buffer)
|
|||
|
||||
memcpy(shared_buf->data(), buffer.data(), buffer.size_in_bytes());
|
||||
shared_buf->seal();
|
||||
shared_buf->share_with(server_pid());
|
||||
ASAPI_ClientMessage request;
|
||||
request.type = ASAPI_ClientMessage::Type::PlayBuffer;
|
||||
request.play_buffer.buffer_id = shared_buf->shared_buffer_id();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue