summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2024-05-18 17:02:17 +0200
committerMikhail Burakov <mburakov@mailbox.org>2024-05-18 17:02:17 +0200
commitfc3df9e9aa1d701c109b68f3700c70a456854720 (patch)
tree74ed0d006c98d05c5dcb16b4162a20cd5d22669b
parent35702d95a8ae34279c0a21035a3b7f9a7286dcfa (diff)
Add primitive latency calculation
-rw-r--r--main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main.c b/main.c
index 8676a14..4eb43b0 100644
--- a/main.c
+++ b/main.c
@@ -124,11 +124,15 @@ static void OnAudioContextAudioReady(void* user, const void* buffer,
struct Contexts* contexts = user;
if (contexts->client_fd == -1) return;
+ // TODO(mburakov): Stride must be calculated from commandline arguments!
+ static const size_t stride = sizeof(int16_t) * 2;
+ size_t latency = MIN(size / stride, UINT16_MAX);
+
struct Proto proto = {
.size = (uint32_t)size,
.type = PROTO_TYPE_AUDIO,
.flags = 0,
- .latency = 0, // TODO(mburakov): Implement this!
+ .latency = (uint16_t)latency,
};
if (!WriteProto(contexts->client_fd, &proto, buffer)) {
LOG("Failed to write audio frame");