mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:47:46 +00:00
Audio: Make ABuffer sit on top of a SharedBuffer.
This allows us to carry the same buffer all the way from the WAV loader to the AudioServer mixer. This alleviates some of the stutter, but there's still a noticeable skip when switching buffers. We're gonna need to do better. :^)
This commit is contained in:
parent
b805f112c2
commit
5e01dde7b1
6 changed files with 38 additions and 31 deletions
|
@ -40,16 +40,11 @@ bool ASClientConnection::handle_message(const ASAPI_ClientMessage& message, cons
|
|||
break;
|
||||
case ASAPI_ClientMessage::Type::PlayBuffer: {
|
||||
// ### ensure that the size is that of a Vector<ASample>
|
||||
Vector<ASample> samples;
|
||||
|
||||
{
|
||||
const auto& shared_buf = SharedBuffer::create_from_shared_buffer_id(message.play_buffer.buffer_id);
|
||||
if (!shared_buf) {
|
||||
did_misbehave();
|
||||
return false;
|
||||
}
|
||||
samples.resize(shared_buf->size() / sizeof(ASample));
|
||||
memcpy(samples.data(), shared_buf->data(), shared_buf->size());
|
||||
auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(message.play_buffer.buffer_id);
|
||||
if (!shared_buffer) {
|
||||
did_misbehave();
|
||||
return false;
|
||||
}
|
||||
|
||||
// we no longer need the buffer, so acknowledge that it's playing
|
||||
|
@ -59,7 +54,7 @@ bool ASClientConnection::handle_message(const ASAPI_ClientMessage& message, cons
|
|||
reply.playing_buffer.buffer_id = message.play_buffer.buffer_id;
|
||||
post_message(reply);
|
||||
|
||||
m_mixer.queue(*this, ABuffer::create_with_samples(move(samples)), message.play_buffer.buffer_id);
|
||||
m_mixer.queue(*this, ABuffer::create_with_shared_buffer(*shared_buffer));
|
||||
break;
|
||||
}
|
||||
case ASAPI_ClientMessage::Type::Invalid:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue