[speaker] Media player's pipeline properly returns playing state near end of file (#9668)

This commit is contained in:
Kevin Ahrendt 2025-07-18 20:21:36 +01:00 committed by GitHub
parent 95a08579f6
commit 3f8494bf8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View File

@ -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);

View File

@ -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_;