mirror of
https://github.com/esphome/esphome.git
synced 2025-04-16 07:40:29 +01:00
[speaker] Bugfix: Ensure all audio is played after completely decoding a file (#8231)
This commit is contained in:
parent
c9e7562aff
commit
46d19d82c2
@ -182,13 +182,21 @@ AudioPipelineState AudioPipeline::process_state() {
|
|||||||
if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) {
|
if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) {
|
||||||
// Stop command is fully processed, so clear the command bit
|
// Stop command is fully processed, so clear the command bit
|
||||||
xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP);
|
xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP);
|
||||||
|
this->hard_stop_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->is_playing_) {
|
if (!this->is_playing_) {
|
||||||
// The tasks have been stopped for two ``process_state`` calls in a row, so delete the tasks
|
// 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)) {
|
if ((this->read_task_handle_ != nullptr) || (this->decode_task_handle_ != nullptr)) {
|
||||||
this->delete_tasks_();
|
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;
|
this->is_playing_ = false;
|
||||||
|
@ -112,6 +112,7 @@ class AudioPipeline {
|
|||||||
|
|
||||||
uint32_t playback_ms_{0};
|
uint32_t playback_ms_{0};
|
||||||
|
|
||||||
|
bool hard_stop_{false};
|
||||||
bool is_playing_{false};
|
bool is_playing_{false};
|
||||||
bool pause_state_{false};
|
bool pause_state_{false};
|
||||||
bool task_stack_in_psram_;
|
bool task_stack_in_psram_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user