#pragma once
#include <cstddef>
#include <cstdint>
namespace wearable {
// 普通 ACK 只能确认刚发送的块；握手只能回到曾发送过的范围。
inline bool voice_ack_valid(unsigned next, unsigned sent, bool handshake, unsigned sent_limit) {
    return handshake ? next <= sent_limit : uint64_t(next) == uint64_t(sent) + 1;
}
// 录音结束不等于上传结束，录音期间仅发送完整块。
inline bool voice_chunk_ready(unsigned sequence, size_t bytes, size_t chunk, bool ended) {
    const size_t offset = size_t(sequence) * chunk;
    return offset < bytes && (ended || bytes - offset >= chunk);
}
}
