diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-08 20:25:42 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-08 20:25:42 +1000 |
| commit | e1181fbe59a835ea9c93d6e067e9757e8c522d3c (patch) | |
| tree | 2fd61bb93713de8c2205b7b6d0a8c84c49832e93 /src/tasks | |
| parent | c3f40a8cc37114365ef3ec6f2888df64e5206b39 (diff) | |
| parent | 592f231627843bc44ebaaa4506aec26da1f56499 (diff) | |
| download | tangara-fw-e1181fbe59a835ea9c93d6e067e9757e8c522d3c.tar.gz | |
Merge branch 'main' into opus
Diffstat (limited to 'src/tasks')
| -rw-r--r-- | src/tasks/tasks.cpp | 16 | ||||
| -rw-r--r-- | src/tasks/tasks.hpp | 14 |
2 files changed, 29 insertions, 1 deletions
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<Type::kAudio>() -> std::string { return "AUDIO"; } template <> +auto Name<Type::kMixer>() -> std::string { + return "MIXER"; +} +template <> auto Name<Type::kDatabase>() -> std::string { return "DB"; } @@ -77,6 +81,14 @@ auto AllocateStack<Type::kFileStreamer>() -> cpp::span<StackType_t> { size}; } +template <> +auto AllocateStack<Type::kMixer>() -> cpp::span<StackType_t> { + std::size_t size = 4 * 1024; + return {static_cast<StackType_t*>( + 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<Type::kMixer>() -> UBaseType_t { + return 12; +} +template <> auto Priority<Type::kAudio>() -> UBaseType_t { return 11; } diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index 742bb3cc..a0c201d5 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 @@ -57,9 +59,19 @@ template <Type t> auto StartPersistent(const std::function<void(void)>& fn) -> void { StaticTask_t* task_buffer = new StaticTask_t; cpp::span<StackType_t> stack = AllocateStack<t>(); + xTaskCreateStatic(&PersistentMain, Name<t>().c_str(), stack.size(), + new std::function<void(void)>(fn), Priority<t>(), + stack.data(), task_buffer); +} + +template <Type t> +auto StartPersistent(BaseType_t core, const std::function<void(void)>& fn) + -> void { + StaticTask_t* task_buffer = new StaticTask_t; + cpp::span<StackType_t> stack = AllocateStack<t>(); xTaskCreateStaticPinnedToCore(&PersistentMain, Name<t>().c_str(), stack.size(), new std::function<void(void)>(fn), - Priority<t>(), stack.data(), task_buffer, 0); + Priority<t>(), stack.data(), task_buffer, core); } class Worker { |
