ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
playback_start.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5
6namespace esphome::speaker {
7
11static constexpr uint32_t ANNOUNCEMENT_STALL_START_MS = 1500;
12
18 public:
19 bool ready(bool announcement, size_t raw_bytes, size_t initial_bytes, uint32_t now_ms) {
20 if (raw_bytes >= initial_bytes)
21 return true;
22 if (raw_bytes != this->last_raw_bytes_) {
23 this->last_raw_bytes_ = raw_bytes;
24 this->last_change_ms_ = now_ms;
25 return false;
26 }
27 return announcement && now_ms - this->last_change_ms_ >= ANNOUNCEMENT_STALL_START_MS;
28 }
29
30 protected:
31 // No level matches at first, so the first call starts the stall timer
32 size_t last_raw_bytes_{SIZE_MAX};
34};
35
36} // namespace esphome::speaker
Decides when buffered audio starts playing.
bool ready(bool announcement, size_t raw_bytes, size_t initial_bytes, uint32_t now_ms)
static void uint32_t