summaryrefslogtreecommitdiff
path: root/src/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'src/tasks')
-rw-r--r--src/tasks/tasks.cpp17
-rw-r--r--src/tasks/tasks.hpp8
2 files changed, 22 insertions, 3 deletions
diff --git a/src/tasks/tasks.cpp b/src/tasks/tasks.cpp
index 7365813e..abce0bde 100644
--- a/src/tasks/tasks.cpp
+++ b/src/tasks/tasks.cpp
@@ -26,6 +26,10 @@ auto Name<Type::kUiFlush>() -> std::string {
return "DISPLAY";
}
template <>
+auto Name<Type::kFileStreamer>() -> std::string {
+ return "FSTREAMER";
+}
+template <>
auto Name<Type::kAudio>() -> std::string {
return "AUDIO";
}
@@ -65,6 +69,14 @@ auto AllocateStack<Type::kUiFlush>() -> cpp::span<StackType_t> {
return {static_cast<StackType_t*>(heap_caps_malloc(size, MALLOC_CAP_DEFAULT)),
size};
}
+
+template <>
+auto AllocateStack<Type::kFileStreamer>() -> cpp::span<StackType_t> {
+ std::size_t size = 4 * 1024;
+ return {static_cast<StackType_t*>(heap_caps_malloc(size, MALLOC_CAP_SPIRAM)),
+ 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 <>
@@ -110,6 +122,11 @@ template <>
auto Priority<Type::kUiFlush>() -> UBaseType_t {
return 9;
}
+
+template <>
+auto Priority<Type::kFileStreamer>() -> UBaseType_t {
+ return 10;
+}
// Database interactions are all inherently async already, due to their
// potential for disk access. The user likely won't notice or care about a
// couple of ms extra delay due to scheduling, so give this task the lowest
diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp
index 4e5dfd17..742bb3cc 100644
--- a/src/tasks/tasks.hpp
+++ b/src/tasks/tasks.hpp
@@ -32,6 +32,8 @@ enum class Type {
kUi,
// Task for flushing graphics buffers to the display.
kUiFlush,
+ // TODO.
+ kFileStreamer,
// The main audio pipeline task.
kAudio,
// Task for running database queries.
@@ -55,9 +57,9 @@ 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);
+ xTaskCreateStaticPinnedToCore(&PersistentMain, Name<t>().c_str(),
+ stack.size(), new std::function<void(void)>(fn),
+ Priority<t>(), stack.data(), task_buffer, 0);
}
class Worker {