From e4f3a952d512c2a4142f015ffe3c18f7de7f13f8 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Thu, 22 May 2025 14:20:15 -0500 Subject: [PATCH] [speaker] ensure the pipeline returns an error state before returning its stopped (#8878) --- .../speaker/media_player/audio_pipeline.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/esphome/components/speaker/media_player/audio_pipeline.cpp b/esphome/components/speaker/media_player/audio_pipeline.cpp index 60f562cc2c..ac122b6e0c 100644 --- a/esphome/components/speaker/media_player/audio_pipeline.cpp +++ b/esphome/components/speaker/media_player/audio_pipeline.cpp @@ -174,6 +174,16 @@ AudioPipelineState AudioPipeline::process_state() { } } + if ((event_bits & EventGroupBits::READER_MESSAGE_ERROR)) { + xEventGroupClearBits(this->event_group_, EventGroupBits::READER_MESSAGE_ERROR); + return AudioPipelineState::ERROR_READING; + } + + if ((event_bits & EventGroupBits::DECODER_MESSAGE_ERROR)) { + xEventGroupClearBits(this->event_group_, EventGroupBits::DECODER_MESSAGE_ERROR); + return AudioPipelineState::ERROR_DECODING; + } + if ((event_bits & EventGroupBits::READER_MESSAGE_FINISHED) && (!(event_bits & EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE) && (event_bits & EventGroupBits::DECODER_MESSAGE_FINISHED))) { @@ -203,16 +213,6 @@ AudioPipelineState AudioPipeline::process_state() { return AudioPipelineState::STOPPED; } - if ((event_bits & EventGroupBits::READER_MESSAGE_ERROR)) { - xEventGroupClearBits(this->event_group_, EventGroupBits::READER_MESSAGE_ERROR); - return AudioPipelineState::ERROR_READING; - } - - if ((event_bits & EventGroupBits::DECODER_MESSAGE_ERROR)) { - xEventGroupClearBits(this->event_group_, EventGroupBits::DECODER_MESSAGE_ERROR); - return AudioPipelineState::ERROR_DECODING; - } - if (this->pause_state_) { return AudioPipelineState::PAUSED; }