Speaker support (#4743)

This commit is contained in:
Jesse Hills
2023-05-08 10:36:17 +12:00
committed by GitHub
parent 3498aade85
commit ce8a77c765
17 changed files with 622 additions and 19 deletions
+27
View File
@@ -0,0 +1,27 @@
#pragma once
namespace esphome {
namespace speaker {
enum State : uint8_t {
STATE_STOPPED = 0,
STATE_STARTING,
STATE_RUNNING,
STATE_STOPPING,
};
class Speaker {
public:
virtual bool play(const uint8_t *data, size_t length) = 0;
virtual bool play(const std::vector<uint8_t> &data) { return this->play(data.data(), data.size()); }
virtual void stop() = 0;
bool is_running() const { return this->state_ == STATE_RUNNING; }
protected:
State state_{STATE_STOPPED};
};
} // namespace speaker
} // namespace esphome