1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-15 23:30:28 +01:00

[speaker] Bugfix: Ensure all audio is played after completely decoding a file (#8231)

This commit is contained in:
Kevin Ahrendt 2025-02-11 12:14:59 -06:00 committed by GitHub
parent c9e7562aff
commit 46d19d82c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -182,13 +182,21 @@ AudioPipelineState AudioPipeline::process_state() {
if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) {
// Stop command is fully processed, so clear the command bit
xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP);
this->hard_stop_ = true;
}
if (!this->is_playing_) {
// The tasks have been stopped for two ``process_state`` calls in a row, so delete the tasks
if ((this->read_task_handle_ != nullptr) || (this->decode_task_handle_ != nullptr)) {
this->delete_tasks_();
this->speaker_->stop();
if (this->hard_stop_) {
// Stop command was sent, so immediately end of the playback
this->speaker_->stop();
this->hard_stop_ = false;
} else {
// Decoded all the audio, so let the speaker finish playing before stopping
this->speaker_->finish();
}
}
}
this->is_playing_ = false;

View File

@ -112,6 +112,7 @@ class AudioPipeline {
uint32_t playback_ms_{0};
bool hard_stop_{false};
bool is_playing_{false};
bool pause_state_{false};
bool task_stack_in_psram_;