From 04919f7b6edd18a3ceceea0ec22513de4fa4af71 Mon Sep 17 00:00:00 2001 From: Philippe G Date: Tue, 11 Jan 2022 14:44:06 -0800 Subject: [PATCH] change priorities and force spdif_convert in IRAM --- components/spotify/Shim.cpp | 2 +- components/spotify/cspot/bell/include/Task.h | 2 +- components/spotify/cspot/src/AudioChunkManager.cpp | 2 +- components/spotify/cspot/src/MercuryManager.cpp | 2 +- components/spotify/cspot/src/Player.cpp | 2 +- components/squeezelite/output_i2s.c | 2 +- components/tools/tools.c | 5 ++--- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/spotify/Shim.cpp b/components/spotify/Shim.cpp index fa212257..54560b9a 100644 --- a/components/spotify/Shim.cpp +++ b/components/spotify/Shim.cpp @@ -193,7 +193,7 @@ struct cspot_s* cspot_create(const char *name, cspot_cmd_cb_t cmd_cb, cspot_data cspot.cHandler = cmd_cb; cspot.dHandler = data_cb; strncpy(cspot.name, name, sizeof(cspot.name) - 1); - cspot.TaskHandle = xTaskCreateStatic(&cspotTask, "cspot", CSPOT_STACK_SIZE, NULL, CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT, xStack, &xTaskBuffer); + cspot.TaskHandle = xTaskCreateStatic(&cspotTask, "cspot", CSPOT_STACK_SIZE, NULL, CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT - 2, xStack, &xTaskBuffer); return &cspot; } diff --git a/components/spotify/cspot/bell/include/Task.h b/components/spotify/cspot/bell/include/Task.h index 72f9412b..425b2072 100644 --- a/components/spotify/cspot/bell/include/Task.h +++ b/components/spotify/cspot/bell/include/Task.h @@ -29,7 +29,7 @@ namespace bell #ifdef ESP_PLATFORM this->xStack = NULL; this->priority = CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT + priority; - if (this->priority < 0) this->priority = ESP_TASK_PRIO_MIN; + if (this->priority <= ESP_TASK_PRIO_MIN) this->priority = ESP_TASK_PRIO_MIN + 1; if (runOnPSRAM) { this->xStack = (StackType_t*) heap_caps_malloc(this->stackSize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); } diff --git a/components/spotify/cspot/src/AudioChunkManager.cpp b/components/spotify/cspot/src/AudioChunkManager.cpp index 98426814..256ee13a 100644 --- a/components/spotify/cspot/src/AudioChunkManager.cpp +++ b/components/spotify/cspot/src/AudioChunkManager.cpp @@ -3,7 +3,7 @@ #include "Logger.h" AudioChunkManager::AudioChunkManager() - : bell::Task("AudioChunkManager", 4 * 1024, 2, 0) { + : bell::Task("AudioChunkManager", 4 * 1024, -1, 0) { this->chunks = std::vector>(); startTask(); } diff --git a/components/spotify/cspot/src/MercuryManager.cpp b/components/spotify/cspot/src/MercuryManager.cpp index 36a3d9d3..a02b4c15 100644 --- a/components/spotify/cspot/src/MercuryManager.cpp +++ b/components/spotify/cspot/src/MercuryManager.cpp @@ -9,7 +9,7 @@ std::map MercuryTypeMap({ {MercuryType::UNSUB, "UNSUB"}, }); -MercuryManager::MercuryManager(std::unique_ptr session): bell::Task("mercuryManager", 6 * 1024, 2, 1) +MercuryManager::MercuryManager(std::unique_ptr session): bell::Task("mercuryManager", 6 * 1024, -2, 1) { tempMercuryHeader = {}; this->timeProvider = std::make_shared(); diff --git a/components/spotify/cspot/src/Player.cpp b/components/spotify/cspot/src/Player.cpp index 0fb32b6d..3bccc0b0 100644 --- a/components/spotify/cspot/src/Player.cpp +++ b/components/spotify/cspot/src/Player.cpp @@ -3,7 +3,7 @@ // #include -Player::Player(std::shared_ptr manager, std::shared_ptr audioSink): bell::Task("player", 10 * 1024, +0, 1) +Player::Player(std::shared_ptr manager, std::shared_ptr audioSink): bell::Task("player", 10 * 1024, -2, 1) { this->audioSink = audioSink; this->manager = manager; diff --git a/components/squeezelite/output_i2s.c b/components/squeezelite/output_i2s.c index 2da4d583..af77cd4a 100644 --- a/components/squeezelite/output_i2s.c +++ b/components/squeezelite/output_i2s.c @@ -672,7 +672,7 @@ static const u16_t spdif_bmclookup[256] = { //biphase mark encoded values (least audio is transmitted first (not the MSB) and that ESP32 libray sends R then L, contrary to what seems to be usually done, so (dst) order had to be changed */ -void spdif_convert(ISAMPLE_T *src, size_t frames, u32_t *dst, size_t *count) { +static void IRAM_ATTR spdif_convert(ISAMPLE_T *src, size_t frames, u32_t *dst, size_t *count) { register u16_t hi, lo, aux; size_t cnt = *count; diff --git a/components/tools/tools.c b/components/tools/tools.c index 1ee41680..9a6af79a 100644 --- a/components/tools/tools.c +++ b/components/tools/tools.c @@ -13,11 +13,12 @@ #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "tools.h" +#include "esp_task.h" #include "esp_tls.h" #include "esp_http_client.h" #include "esp_heap_caps.h" #include "esp_log.h" +#include "tools.h" const static char TAG[] = "tools"; @@ -199,8 +200,6 @@ void http_download(char *url, size_t max, http_download_cb_t callback, void *con .url = url, .event_handler = http_event_handler, .user_data = http_context, - //.cert_pem = howsmyssl_com_root_cert_pem_start, - //.skip_cert_common_name_check = true, }; http_context->callback = callback;