summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2024-05-12 15:06:12 +0200
committerMikhail Burakov <mburakov@mailbox.org>2024-05-12 15:06:12 +0200
commit6d81c3b8a5d1bae39eb04f9ec775b979ee88454c (patch)
tree07fcd7ceb07c9107b8192367fb655be00f124db2 /main.c
parentd511fae02fba6f6c8ea2896d5a6cefd8d3337ca3 (diff)
Write raw audio frames to client
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/main.c b/main.c
index 001d0aa..c1ce446 100644
--- a/main.c
+++ b/main.c
@@ -32,6 +32,7 @@
#include "encode.h"
#include "gpu.h"
#include "input.h"
+#include "proto.h"
#include "toolbox/io_muxer.h"
#include "toolbox/perf.h"
#include "toolbox/utils.h"
@@ -121,11 +122,18 @@ static void MaybeDropClient(struct Contexts* contexts) {
static void OnAudioContextAudioReady(void* user, const void* buffer,
size_t size) {
struct Contexts* contexts = user;
- LOG("Got a buffer!");
- // TODO(mburakov): Implement this!
- (void)contexts;
- (void)buffer;
- (void)size;
+ if (contexts->client_fd == -1) return;
+
+ struct Proto proto = {
+ .size = (uint32_t)size,
+ .type = PROTO_TYPE_AUDIO,
+ .flags = 0,
+ .latency = 0, // TODO(mburakov): Implement this!
+ };
+ if (!WriteProto(contexts->client_fd, &proto, buffer)) {
+ LOG("Failed to write audio frame");
+ MaybeDropClient(contexts);
+ }
}
static void OnCaptureContextFrameReady(void* user,