ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
sendspin_media_source.h
Go to the documentation of this file.
1#pragma once
2
4
5#if defined(USE_ESP32) && defined(USE_SENDSPIN_CONTROLLER) && defined(USE_SENDSPIN_PLAYER)
6
8
10
11#include <sendspin/player_role.h>
12
13namespace esphome::sendspin_ {
14
22 public sendspin::PlayerRoleListener {
23 public:
24 void setup() override;
25 void dump_config() override;
26
27 void set_static_delay_adjustable(bool adjustable);
28
29 // MediaSource interface implementation
30 bool play_uri(const std::string &uri) override;
32 bool can_handle(const std::string &uri) const override;
33 bool has_internal_playlist() const override { return true; }
34
35 void notify_volume_changed(float volume) override;
36 void notify_mute_changed(bool is_muted) override;
37 void notify_audio_played(uint32_t frames, int64_t timestamp) override;
38
39 protected:
40 // --- Sendspin PlayerRoleListener overrides ---
41
44 size_t on_audio_write(uint8_t *data, size_t length, uint32_t timeout_ms) override;
45
47 void on_stream_start() override;
48
50 void on_stream_end() override;
51
53 void on_volume_changed(uint8_t volume) override;
54
56 void on_mute_changed(bool muted) override;
57
58 sendspin::PlayerRole *player_role_{nullptr};
59
60 float cached_volume_{0.0f};
61
62 bool cached_muted_{false};
63 bool pending_start_{false};
65};
66
67} // namespace esphome::sendspin_
68
69#endif
Abstract base class for media sources MediaSource provides audio data to an orchestrator via the Medi...
Base class for all sendspin subcomponents.
Thin adapter media source for Sendspin.
void on_stream_end() override
Called when the audio stream ends (main loop thread).
void on_stream_start() override
Called when a new audio stream starts (main loop thread).
void on_mute_changed(bool muted) override
Called when mute state changes (main loop thread).
bool can_handle(const std::string &uri) const override
void handle_command(media_source::MediaSourceCommand command) override
size_t on_audio_write(uint8_t *data, size_t length, uint32_t timeout_ms) override
Writes decoded PCM audio to ESPHome's media source output pipeline.
void on_volume_changed(uint8_t volume) override
Called when volume changes (main loop thread).
bool play_uri(const std::string &uri) override
void notify_audio_played(uint32_t frames, int64_t timestamp) override
MediaSourceCommand
Commands that are sent from the orchestrator to a media source.
static void uint32_t
uint16_t length
Definition tt21100.cpp:0
uint16_t timestamp
Definition tt21100.cpp:2