mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 01:34:18 +01:00
update audio files
This commit is contained in:
parent
b67adcd202
commit
5a942247a7
2 changed files with 8 additions and 11 deletions
|
@ -5,11 +5,11 @@ namespace audio {
|
|||
|
||||
/* *************** AudioListener **************** */
|
||||
|
||||
AudioStreamer *AudioListener::start(AudioStreamInfo &info) {
|
||||
AudioStreamer *AudioListener::start(const AudioStreamInfo &audio_stream_info) {
|
||||
if (current_streamer_ != nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (this->starting(info)) {
|
||||
if (this->starting(audio_stream_info)) {
|
||||
this->current_streamer_ = new AudioStreamer();
|
||||
this->current_streamer_->set_parent(this);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ AudioStreamer *AudioListener::start(AudioStreamInfo &info) {
|
|||
AudioStreamer *AudioListener::start() {
|
||||
AudioStreamInfo info;
|
||||
this->get_default_audio_stream_info(info);
|
||||
this->start(info);
|
||||
return this->start(info);
|
||||
}
|
||||
|
||||
bool AudioListener::can_stream(AudioStreamer *streamer) {
|
||||
|
@ -38,8 +38,8 @@ AudioStreamer::~AudioStreamer() {
|
|||
|
||||
bool AudioStreamer::is_running() { return (this->parent_ == nullptr) ? false : this->parent_->can_stream(this); }
|
||||
|
||||
size_t AudioStreamer::stream(const uint8_t *data, const size_t size, TickType_t ticks_to_wait) {
|
||||
if (!this->is_running(this))
|
||||
size_t AudioStreamer::stream(const uint8_t *data, size_t size, TickType_t ticks_to_wait) {
|
||||
if (!this->is_running())
|
||||
return 0;
|
||||
return this->parent_->streaming(data, size, ticks_to_wait);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class AudioStreamer : public Parented<AudioListener> {
|
|||
/// @param length The length of the audio data in bytes.
|
||||
/// @return The number of bytes that were actually written to the speaker's internal buffer.
|
||||
|
||||
size_t stream(const uint8_t *data, const size_t size, TickType_t ticks_to_wait = 0);
|
||||
size_t stream(const uint8_t *data, size_t size, TickType_t ticks_to_wait = 0);
|
||||
bool is_running();
|
||||
};
|
||||
|
||||
|
@ -54,11 +54,7 @@ class AudioListener {
|
|||
AudioStreamer *start(const AudioStreamInfo &audio_stream_info);
|
||||
AudioStreamer *start();
|
||||
|
||||
void stop() {
|
||||
if (this->current_streamer_ != nullptr) {
|
||||
delete this->current_streamer_;
|
||||
}
|
||||
}
|
||||
void stop() { delete this->current_streamer_; }
|
||||
|
||||
virtual bool can_stream(AudioStreamer *streamer);
|
||||
|
||||
|
@ -69,6 +65,7 @@ class AudioListener {
|
|||
virtual void get_default_audio_stream_info(AudioStreamInfo &audio_stream_info) {}
|
||||
|
||||
protected:
|
||||
friend class AudioStreamer;
|
||||
virtual bool starting(const AudioStreamInfo &audio_stream_info) = 0;
|
||||
virtual size_t streaming(const uint8_t *data, size_t size, TickType_t ticks_to_wait) = 0;
|
||||
virtual void stopping(){};
|
||||
|
|
Loading…
Reference in a new issue