[speaker] Build the pipeline task names on the stack (#21203)

This commit is contained in:
J. Nick Koston
2026-10-21 08:41:59 -10:00
committed by GitHub
parent 35883270fe
commit 9ab230f98d
2 changed files with 10 additions and 8 deletions
@@ -48,8 +48,8 @@ enum EventGroupBits : uint32_t {
};
AudioPipeline::AudioPipeline(speaker::Speaker *speaker, size_t buffer_size, bool task_stack_in_psram,
std::string base_name, UBaseType_t priority)
: base_name_(std::move(base_name)),
const char *base_name, UBaseType_t priority)
: base_name_(base_name),
priority_(priority),
task_stack_in_psram_(task_stack_in_psram),
speaker_(speaker),
@@ -269,18 +269,20 @@ esp_err_t AudioPipeline::allocate_communications_() {
}
esp_err_t AudioPipeline::start_tasks_() {
char task_name[configMAX_TASK_NAME_LEN];
if (!this->read_task_.is_created()) {
// Reader task uses the AudioReader class which uses esp_http_client. This crashes on IDF 5.4 if the task stack is
// in PSRAM. As a workaround, always allocate the read task in internal memory.
if (!this->read_task_.create(read_task, (this->base_name_ + "_read").c_str(), READ_TASK_STACK_SIZE, (void *) this,
this->priority_, false)) {
snprintf(task_name, sizeof(task_name), "%s_read", this->base_name_);
if (!this->read_task_.create(read_task, task_name, READ_TASK_STACK_SIZE, (void *) this, this->priority_, false)) {
return ESP_ERR_NO_MEM;
}
}
if (!this->decode_task_.is_created()) {
if (!this->decode_task_.create(decode_task, (this->base_name_ + "_decode").c_str(), DECODE_TASK_STACK_SIZE,
(void *) this, this->priority_, this->task_stack_in_psram_)) {
snprintf(task_name, sizeof(task_name), "%s_decode", this->base_name_);
if (!this->decode_task_.create(decode_task, task_name, DECODE_TASK_STACK_SIZE, (void *) this, this->priority_,
this->task_stack_in_psram_)) {
return ESP_ERR_NO_MEM;
}
}
@@ -63,7 +63,7 @@ class AudioPipeline final {
/// @param task_stack_in_psram True if the task stack should be allocated in PSRAM, false otherwise
/// @param task_name FreeRTOS task base name
/// @param priority FreeRTOS task priority
AudioPipeline(speaker::Speaker *speaker, size_t buffer_size, bool task_stack_in_psram, std::string base_name,
AudioPipeline(speaker::Speaker *speaker, size_t buffer_size, bool task_stack_in_psram, const char *base_name,
UBaseType_t priority);
/// @brief Starts an audio pipeline given a media url
@@ -103,7 +103,7 @@ class AudioPipeline final {
/// @return ESP_OK if successful or an appropriate error if not
esp_err_t start_tasks_();
std::string base_name_;
const char *base_name_;
UBaseType_t priority_;
uint32_t playback_ms_{0};