From 3511852f39cd5023ec8e6d0b94cc69f34e9201ed Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 3 Aug 2023 15:32:28 +1000 Subject: Add very limited resampling (it's slow as shit) --- src/tasks/tasks.cpp | 16 ++++++++++++++++ src/tasks/tasks.hpp | 2 ++ 2 files changed, 18 insertions(+) (limited to 'src/tasks') diff --git a/src/tasks/tasks.cpp b/src/tasks/tasks.cpp index 861c7bf0..34c690f3 100644 --- a/src/tasks/tasks.cpp +++ b/src/tasks/tasks.cpp @@ -34,6 +34,10 @@ auto Name() -> std::string { return "AUDIO"; } template <> +auto Name() -> std::string { + return "MIXER"; +} +template <> auto Name() -> std::string { return "DB"; } @@ -77,6 +81,14 @@ auto AllocateStack() -> cpp::span { size}; } +template <> +auto AllocateStack() -> cpp::span { + std::size_t size = 4 * 1024; + return {static_cast( + heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)), + size}; +} + // Leveldb is designed for non-embedded use cases, where stack space isn't so // much of a concern. It therefore uses an eye-wateringly large amount of stack. template <> @@ -105,6 +117,10 @@ auto Priority() -> UBaseType_t; // Realtime audio is the entire point of this device, so give this task the // highest priority. template <> +auto Priority() -> UBaseType_t { + return 12; +} +template <> auto Priority() -> UBaseType_t { return 11; } diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index 742bb3cc..1321aab8 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -36,6 +36,8 @@ enum class Type { kFileStreamer, // The main audio pipeline task. kAudio, + // TODO + kMixer, // Task for running database queries. kDatabase, // Task for internal database operations -- cgit v1.2.3 From a66c3428063017f2233b6b15d5ce6c920d5c9095 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 7 Aug 2023 14:26:04 +1000 Subject: Resampling *basically* working? Just cleanup and buffering issues --- src/tasks/tasks.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/tasks') diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index 1321aab8..fe65ffcc 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -57,11 +57,20 @@ auto PersistentMain(void* fn) -> void; template auto StartPersistent(const std::function& fn) -> void { + StaticTask_t* task_buffer = new StaticTask_t; + cpp::span stack = AllocateStack(); + xTaskCreateStatic(&PersistentMain, Name().c_str(), + stack.size(), new std::function(fn), + Priority(), stack.data(), task_buffer); +} + +template +auto StartPersistent(BaseType_t core, const std::function& fn) -> void { StaticTask_t* task_buffer = new StaticTask_t; cpp::span stack = AllocateStack(); xTaskCreateStaticPinnedToCore(&PersistentMain, Name().c_str(), stack.size(), new std::function(fn), - Priority(), stack.data(), task_buffer, 0); + Priority(), stack.data(), task_buffer, core); } class Worker { -- cgit v1.2.3 From c38754401b95642b5e61fd273c2adf7d76a829fe Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 7 Aug 2023 18:22:15 +1000 Subject: Downscaling working! --- src/tasks/tasks.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/tasks') diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index fe65ffcc..a0c201d5 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -59,13 +59,14 @@ template auto StartPersistent(const std::function& fn) -> void { StaticTask_t* task_buffer = new StaticTask_t; cpp::span stack = AllocateStack(); - xTaskCreateStatic(&PersistentMain, Name().c_str(), - stack.size(), new std::function(fn), - Priority(), stack.data(), task_buffer); + xTaskCreateStatic(&PersistentMain, Name().c_str(), stack.size(), + new std::function(fn), Priority(), + stack.data(), task_buffer); } template -auto StartPersistent(BaseType_t core, const std::function& fn) -> void { +auto StartPersistent(BaseType_t core, const std::function& fn) + -> void { StaticTask_t* task_buffer = new StaticTask_t; cpp::span stack = AllocateStack(); xTaskCreateStaticPinnedToCore(&PersistentMain, Name().c_str(), -- cgit v1.2.3