ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
speaker
media_player
playback_start.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstddef>
4
#include <cstdint>
5
6
namespace
esphome::speaker
{
7
11
static
constexpr
uint32_t
ANNOUNCEMENT_STALL_START_MS = 1500;
12
17
class
PlaybackStartGate
{
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};
33
uint32_t
last_change_ms_
{0};
34
};
35
36
}
// namespace esphome::speaker
esphome::speaker::PlaybackStartGate
Decides when buffered audio starts playing.
Definition
playback_start.h:17
esphome::speaker::PlaybackStartGate::ready
bool ready(bool announcement, size_t raw_bytes, size_t initial_bytes, uint32_t now_ms)
Definition
playback_start.h:19
esphome::speaker::PlaybackStartGate::last_change_ms_
uint32_t last_change_ms_
Definition
playback_start.h:33
esphome::speaker::PlaybackStartGate::last_raw_bytes_
size_t last_raw_bytes_
Definition
playback_start.h:32
esphome::speaker
Definition
announcement_volume.cpp:5
uint32_t
static void uint32_t
Definition
crash_handler.cpp:153
Generated by
1.12.0