diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-18 17:02:17 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-18 17:02:17 +0200 |
commit | fc3df9e9aa1d701c109b68f3700c70a456854720 (patch) | |
tree | 74ed0d006c98d05c5dcb16b4162a20cd5d22669b | |
parent | 35702d95a8ae34279c0a21035a3b7f9a7286dcfa (diff) |
Add primitive latency calculation
-rw-r--r-- | main.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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"); |