mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
AudioServer: Let ASMixer notify ASClientConnection about finished buffers.
Instead of posting a message directly from ASMixer, notify the client via ASClientConnection::did_finish_playing_buffer().
This commit is contained in:
parent
dbebf10131
commit
6a0319697c
3 changed files with 17 additions and 13 deletions
|
@ -1,17 +1,17 @@
|
||||||
#include "ASClientConnection.h"
|
#include "ASClientConnection.h"
|
||||||
#include "ASMixer.h"
|
#include "ASMixer.h"
|
||||||
|
|
||||||
#include <LibCore/CEventLoop.h>
|
|
||||||
#include <LibAudio/ASAPI.h>
|
|
||||||
#include <LibAudio/ABuffer.h>
|
#include <LibAudio/ABuffer.h>
|
||||||
|
#include <LibAudio/ASAPI.h>
|
||||||
|
#include <LibCore/CEventLoop.h>
|
||||||
#include <SharedBuffer.h>
|
#include <SharedBuffer.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
ASClientConnection::ASClientConnection(CLocalSocket& client_socket, int client_id, ASMixer& mixer)
|
ASClientConnection::ASClientConnection(CLocalSocket& client_socket, int client_id, ASMixer& mixer)
|
||||||
: Connection(client_socket, client_id)
|
: Connection(client_socket, client_id)
|
||||||
|
@ -63,3 +63,10 @@ bool ASClientConnection::handle_message(const ASAPI_ClientMessage& message, cons
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ASClientConnection::did_finish_playing_buffer(Badge<ASMixer>, int buffer_id)
|
||||||
|
{
|
||||||
|
ASAPI_ServerMessage reply;
|
||||||
|
reply.type = ASAPI_ServerMessage::Type::FinishedPlayingBuffer;
|
||||||
|
reply.playing_buffer.buffer_id = buffer_id;
|
||||||
|
post_message(reply);
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ public:
|
||||||
void send_greeting() override;
|
void send_greeting() override;
|
||||||
bool handle_message(const ASAPI_ClientMessage&, const ByteBuffer&& = {}) override;
|
bool handle_message(const ASAPI_ClientMessage&, const ByteBuffer&& = {}) override;
|
||||||
|
|
||||||
|
void did_finish_playing_buffer(Badge<ASMixer>, int buffer_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASMixer& m_mixer;
|
ASMixer& m_mixer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <AK/BufferStream.h>
|
#include <AK/BufferStream.h>
|
||||||
#include <AudioServer/ASClientConnection.h>
|
#include <AudioServer/ASClientConnection.h>
|
||||||
#include <AudioServer/ASMixer.h>
|
#include <AudioServer/ASMixer.h>
|
||||||
#include <LibAudio/ASAPI.h>
|
|
||||||
#include <LibCore/CThread.h>
|
#include <LibCore/CThread.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
@ -78,12 +77,8 @@ void ASMixer::mix()
|
||||||
|
|
||||||
// clear it later
|
// clear it later
|
||||||
if (buffer.pos == sample_count) {
|
if (buffer.pos == sample_count) {
|
||||||
if (buffer.m_client) {
|
if (buffer.m_client)
|
||||||
ASAPI_ServerMessage reply;
|
buffer.m_client->did_finish_playing_buffer({}, buffer.buffer->shared_buffer_id());
|
||||||
reply.type = ASAPI_ServerMessage::Type::FinishedPlayingBuffer;
|
|
||||||
reply.playing_buffer.buffer_id = buffer.buffer->shared_buffer_id();
|
|
||||||
buffer.m_client->post_message(reply);
|
|
||||||
}
|
|
||||||
buffer.done = true;
|
buffer.done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue