mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 14:46:40 +00:00
[speaker] Media player's pipeline properly returns playing state near end of file (#9668)
This commit is contained in:
parent
32d8c60a0b
commit
8664ec0a3b
@ -200,7 +200,7 @@ AudioPipelineState AudioPipeline::process_state() {
|
|||||||
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_();
|
||||||
if (this->hard_stop_) {
|
if (this->hard_stop_) {
|
||||||
// Stop command was sent, so immediately end of the playback
|
// Stop command was sent, so immediately end the playback
|
||||||
this->speaker_->stop();
|
this->speaker_->stop();
|
||||||
this->hard_stop_ = false;
|
this->hard_stop_ = false;
|
||||||
} else {
|
} else {
|
||||||
@ -210,13 +210,25 @@ AudioPipelineState AudioPipeline::process_state() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->is_playing_ = false;
|
this->is_playing_ = false;
|
||||||
return AudioPipelineState::STOPPED;
|
if (!this->speaker_->is_running()) {
|
||||||
|
return AudioPipelineState::STOPPED;
|
||||||
|
} else {
|
||||||
|
this->is_finishing_ = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->pause_state_) {
|
if (this->pause_state_) {
|
||||||
return AudioPipelineState::PAUSED;
|
return AudioPipelineState::PAUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->is_finishing_) {
|
||||||
|
if (!this->speaker_->is_running()) {
|
||||||
|
this->is_finishing_ = false;
|
||||||
|
} else {
|
||||||
|
return AudioPipelineState::PLAYING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((this->read_task_handle_ == nullptr) && (this->decode_task_handle_ == nullptr)) {
|
if ((this->read_task_handle_ == nullptr) && (this->decode_task_handle_ == nullptr)) {
|
||||||
// No tasks are running, so the pipeline is stopped.
|
// No tasks are running, so the pipeline is stopped.
|
||||||
xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP);
|
xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP);
|
||||||
|
@ -114,6 +114,7 @@ class AudioPipeline {
|
|||||||
|
|
||||||
bool hard_stop_{false};
|
bool hard_stop_{false};
|
||||||
bool is_playing_{false};
|
bool is_playing_{false};
|
||||||
|
bool is_finishing_{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