summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-27 21:15:33 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-27 21:17:14 +0200
commit6a0319697c554e54f5a6b3a2a78d82e7cc073d55 (patch)
tree61ed6fe1823f374cd10206abaae54fa3d07f38e8 /Servers
parentdbebf1013112bc942ad222d54f5fd2caf2e0adeb (diff)
downloadserenity-6a0319697c554e54f5a6b3a2a78d82e7cc073d55.zip
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().
Diffstat (limited to 'Servers')
-rw-r--r--Servers/AudioServer/ASClientConnection.cpp19
-rw-r--r--Servers/AudioServer/ASClientConnection.h2
-rw-r--r--Servers/AudioServer/ASMixer.cpp9
3 files changed, 17 insertions, 13 deletions
diff --git a/Servers/AudioServer/ASClientConnection.cpp b/Servers/AudioServer/ASClientConnection.cpp
index 23d0c2f018..96cf328fcc 100644
--- a/Servers/AudioServer/ASClientConnection.cpp
+++ b/Servers/AudioServer/ASClientConnection.cpp
@@ -1,17 +1,17 @@
#include "ASClientConnection.h"
#include "ASMixer.h"
-#include <LibCore/CEventLoop.h>
-#include <LibAudio/ASAPI.h>
#include <LibAudio/ABuffer.h>
+#include <LibAudio/ASAPI.h>
+#include <LibCore/CEventLoop.h>
#include <SharedBuffer.h>
#include <errno.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <sys/types.h>
-#include <sys/socket.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)
: Connection(client_socket, client_id)
@@ -63,3 +63,10 @@ bool ASClientConnection::handle_message(const ASAPI_ClientMessage& message, cons
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);
+}
diff --git a/Servers/AudioServer/ASClientConnection.h b/Servers/AudioServer/ASClientConnection.h
index 78a9d19e7a..295adfc221 100644
--- a/Servers/AudioServer/ASClientConnection.h
+++ b/Servers/AudioServer/ASClientConnection.h
@@ -13,6 +13,8 @@ public:
void send_greeting() override;
bool handle_message(const ASAPI_ClientMessage&, const ByteBuffer&& = {}) override;
+ void did_finish_playing_buffer(Badge<ASMixer>, int buffer_id);
+
private:
ASMixer& m_mixer;
};
diff --git a/Servers/AudioServer/ASMixer.cpp b/Servers/AudioServer/ASMixer.cpp
index e4b618adc0..1c9dcf7ed5 100644
--- a/Servers/AudioServer/ASMixer.cpp
+++ b/Servers/AudioServer/ASMixer.cpp
@@ -1,7 +1,6 @@
#include <AK/BufferStream.h>
#include <AudioServer/ASClientConnection.h>
#include <AudioServer/ASMixer.h>
-#include <LibAudio/ASAPI.h>
#include <LibCore/CThread.h>
#include <limits>
@@ -78,12 +77,8 @@ void ASMixer::mix()
// clear it later
if (buffer.pos == sample_count) {
- if (buffer.m_client) {
- ASAPI_ServerMessage reply;
- reply.type = ASAPI_ServerMessage::Type::FinishedPlayingBuffer;
- reply.playing_buffer.buffer_id = buffer.buffer->shared_buffer_id();
- buffer.m_client->post_message(reply);
- }
+ if (buffer.m_client)
+ buffer.m_client->did_finish_playing_buffer({}, buffer.buffer->shared_buffer_id());
buffer.done = true;
}
}