mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:57:46 +00:00
AudioServer+LibAudio: Pass audio buffers as Core::AnonymousBuffer
This was the last remaining user of shbufs! :^)
This commit is contained in:
parent
cc8b3c92ba
commit
2cd16778b5
9 changed files with 36 additions and 34 deletions
|
@ -10,7 +10,7 @@ endpoint AudioServer = 85
|
|||
SetMainMixVolume(i32 volume) => ()
|
||||
|
||||
// Buffer playback
|
||||
EnqueueBuffer(i32 buffer_id, int sample_count) => (bool success)
|
||||
EnqueueBuffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count) => (bool success)
|
||||
SetPaused(bool paused) => ()
|
||||
ClearBuffer(bool paused) => ()
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "ClientConnection.h"
|
||||
#include "Mixer.h"
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <AudioServer/AudioClientEndpoint.h>
|
||||
#include <LibAudio/Buffer.h>
|
||||
#include <errno.h>
|
||||
|
@ -98,20 +97,13 @@ OwnPtr<Messages::AudioServer::SetMainMixVolumeResponse> ClientConnection::handle
|
|||
|
||||
OwnPtr<Messages::AudioServer::EnqueueBufferResponse> ClientConnection::handle(const Messages::AudioServer::EnqueueBuffer& message)
|
||||
{
|
||||
auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.buffer_id());
|
||||
if (!shared_buffer) {
|
||||
// FIXME: The shared buffer should have been retrieved for us already.
|
||||
// We don't want to do IPC error checking at this layer.
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (!m_queue)
|
||||
m_queue = m_mixer.create_queue(*this);
|
||||
|
||||
if (m_queue->is_full())
|
||||
return make<Messages::AudioServer::EnqueueBufferResponse>(false);
|
||||
|
||||
m_queue->enqueue(Audio::Buffer::create_with_shared_buffer(*shared_buffer, message.sample_count()));
|
||||
m_queue->enqueue(Audio::Buffer::create_with_anonymous_buffer(message.buffer(), message.buffer_id(), message.sample_count()));
|
||||
return make<Messages::AudioServer::EnqueueBufferResponse>(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
++m_played_samples;
|
||||
|
||||
if (m_position >= m_current->sample_count()) {
|
||||
m_client->did_finish_playing_buffer({}, m_current->shbuf_id());
|
||||
m_client->did_finish_playing_buffer({}, m_current->id());
|
||||
m_current = nullptr;
|
||||
m_position = 0;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
int get_playing_buffer() const
|
||||
{
|
||||
if (m_current)
|
||||
return m_current->shbuf_id();
|
||||
return m_current->id();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
int main(int, char**)
|
||||
{
|
||||
if (pledge("stdio thread shared_buffer accept rpath wpath cpath unix fattr", nullptr) < 0) {
|
||||
if (pledge("stdio recvfd thread accept rpath wpath cpath unix fattr", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ int main(int, char**)
|
|||
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, mixer);
|
||||
};
|
||||
|
||||
if (pledge("stdio thread shared_buffer accept", nullptr) < 0) {
|
||||
if (pledge("stdio recvfd thread accept", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue