diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-12 15:06:12 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-12 15:06:12 +0200 |
commit | 6d81c3b8a5d1bae39eb04f9ec775b979ee88454c (patch) | |
tree | 07fcd7ceb07c9107b8192367fb655be00f124db2 | |
parent | d511fae02fba6f6c8ea2896d5a6cefd8d3337ca3 (diff) |
Write raw audio frames to client
-rw-r--r-- | main.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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, |