summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2025-02-11 11:02:15 +1100
committerailurux <ailuruxx@gmail.com>2025-02-11 11:02:15 +1100
commit29ad80d113970c5dcaed5a99c5478277a349b1a6 (patch)
tree975e7503162c3f51b231c88a38bf22f87c6afab2
parentfff980a979aa6be6ad5697f73017a2da6649de86 (diff)
parent167fea6b5b87a1cd97165d4e425699c2ecdb2bbf (diff)
downloadtangara-fw-29ad80d113970c5dcaed5a99c5478277a349b1a6.tar.gz
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
-rw-r--r--lua/img/back.pngbin165 -> 88 bytes
-rw-r--r--lua/img/bat/0.pngbin198 -> 96 bytes
-rw-r--r--lua/img/bat/100.pngbin285 -> 101 bytes
-rw-r--r--lua/img/bat/20.pngbin234 -> 101 bytes
-rw-r--r--lua/img/bat/40.pngbin258 -> 101 bytes
-rw-r--r--lua/img/bat/60.pngbin249 -> 101 bytes
-rw-r--r--lua/img/bat/80.pngbin270 -> 101 bytes
-rw-r--r--lua/img/bat/chg.pngbin207 -> 91 bytes
-rw-r--r--lua/img/bat/chg_outline.pngbin225 -> 104 bytes
-rw-r--r--lua/img/bt.pngbin210 -> 97 bytes
-rw-r--r--lua/img/bt_conn.pngbin246 -> 105 bytes
-rw-r--r--lua/img/chevron.pngbin141 -> 83 bytes
-rw-r--r--lua/img/db.pngbin228 -> 104 bytes
-rw-r--r--lua/img/enqueue.pngbin162 -> 87 bytes
-rw-r--r--lua/img/file_icons/directory.pngbin198 -> 90 bytes
-rw-r--r--lua/img/file_icons/playlist.pngbin162 -> 87 bytes
-rw-r--r--lua/img/files.pngbin279 -> 105 bytes
-rw-r--r--lua/img/info.pngbin156 -> 79 bytes
-rw-r--r--lua/img/listened.pngbin189 -> 98 bytes
-rw-r--r--lua/img/menu.pngbin138 -> 77 bytes
-rw-r--r--lua/img/next.pngbin297 -> 96 bytes
-rw-r--r--lua/img/pause.pngbin234 -> 76 bytes
-rw-r--r--lua/img/pausecirc.pngbin360 -> 104 bytes
-rw-r--r--lua/img/play.pngbin225 -> 94 bytes
-rw-r--r--lua/img/play_small.pngbin165 -> 83 bytes
-rw-r--r--lua/img/playcirc.pngbin348 -> 111 bytes
-rw-r--r--lua/img/prev.pngbin288 -> 97 bytes
-rw-r--r--lua/img/queue.pngbin195 -> 83 bytes
-rw-r--r--lua/img/repeat.pngbin225 -> 99 bytes
-rw-r--r--lua/img/repeat_off.pngbin249 -> 108 bytes
-rw-r--r--lua/img/repeat_queue.pngbin264 -> 108 bytes
-rw-r--r--lua/img/settings.pngbin291 -> 113 bytes
-rw-r--r--lua/img/shuffle.pngbin264 -> 112 bytes
-rw-r--r--lua/img/shuffle_off.pngbin228 -> 97 bytes
-rw-r--r--lua/img/shuffleplay.pngbin189 -> 85 bytes
-rw-r--r--lua/img/unlistened.pngbin174 -> 87 bytes
-rw-r--r--lua/img/usb.pngbin276 -> 113 bytes
-rw-r--r--src/tangara/app_console/app_console.cpp36
-rw-r--r--src/tangara/tts/README.md34
-rw-r--r--src/tangara/tts/player.cpp2
40 files changed, 68 insertions, 4 deletions
diff --git a/lua/img/back.png b/lua/img/back.png
index 7c6d28c2..59958831 100644
--- a/lua/img/back.png
+++ b/lua/img/back.png
Binary files differ
diff --git a/lua/img/bat/0.png b/lua/img/bat/0.png
index 93e6e3ec..37ca99e2 100644
--- a/lua/img/bat/0.png
+++ b/lua/img/bat/0.png
Binary files differ
diff --git a/lua/img/bat/100.png b/lua/img/bat/100.png
index 85c8fe97..d01f114a 100644
--- a/lua/img/bat/100.png
+++ b/lua/img/bat/100.png
Binary files differ
diff --git a/lua/img/bat/20.png b/lua/img/bat/20.png
index dee3fdf9..c88943bb 100644
--- a/lua/img/bat/20.png
+++ b/lua/img/bat/20.png
Binary files differ
diff --git a/lua/img/bat/40.png b/lua/img/bat/40.png
index ba61650e..dbbe6874 100644
--- a/lua/img/bat/40.png
+++ b/lua/img/bat/40.png
Binary files differ
diff --git a/lua/img/bat/60.png b/lua/img/bat/60.png
index fc00c4ba..1d970040 100644
--- a/lua/img/bat/60.png
+++ b/lua/img/bat/60.png
Binary files differ
diff --git a/lua/img/bat/80.png b/lua/img/bat/80.png
index bbc2a0a4..af1b0c1d 100644
--- a/lua/img/bat/80.png
+++ b/lua/img/bat/80.png
Binary files differ
diff --git a/lua/img/bat/chg.png b/lua/img/bat/chg.png
index 17af13c9..a9b7aee8 100644
--- a/lua/img/bat/chg.png
+++ b/lua/img/bat/chg.png
Binary files differ
diff --git a/lua/img/bat/chg_outline.png b/lua/img/bat/chg_outline.png
index e15fb0e9..86f2b6cb 100644
--- a/lua/img/bat/chg_outline.png
+++ b/lua/img/bat/chg_outline.png
Binary files differ
diff --git a/lua/img/bt.png b/lua/img/bt.png
index 632a81c2..2909057d 100644
--- a/lua/img/bt.png
+++ b/lua/img/bt.png
Binary files differ
diff --git a/lua/img/bt_conn.png b/lua/img/bt_conn.png
index e569d827..995422b2 100644
--- a/lua/img/bt_conn.png
+++ b/lua/img/bt_conn.png
Binary files differ
diff --git a/lua/img/chevron.png b/lua/img/chevron.png
index deaf47e7..4584ecb5 100644
--- a/lua/img/chevron.png
+++ b/lua/img/chevron.png
Binary files differ
diff --git a/lua/img/db.png b/lua/img/db.png
index d6c51688..6bd5bcc0 100644
--- a/lua/img/db.png
+++ b/lua/img/db.png
Binary files differ
diff --git a/lua/img/enqueue.png b/lua/img/enqueue.png
index a0b58176..1f512df2 100644
--- a/lua/img/enqueue.png
+++ b/lua/img/enqueue.png
Binary files differ
diff --git a/lua/img/file_icons/directory.png b/lua/img/file_icons/directory.png
index f9fe5071..d6a09798 100644
--- a/lua/img/file_icons/directory.png
+++ b/lua/img/file_icons/directory.png
Binary files differ
diff --git a/lua/img/file_icons/playlist.png b/lua/img/file_icons/playlist.png
index b4ab3c0a..2b30fccd 100644
--- a/lua/img/file_icons/playlist.png
+++ b/lua/img/file_icons/playlist.png
Binary files differ
diff --git a/lua/img/files.png b/lua/img/files.png
index b9f1268d..f6847f21 100644
--- a/lua/img/files.png
+++ b/lua/img/files.png
Binary files differ
diff --git a/lua/img/info.png b/lua/img/info.png
index 67fc526d..6012ab92 100644
--- a/lua/img/info.png
+++ b/lua/img/info.png
Binary files differ
diff --git a/lua/img/listened.png b/lua/img/listened.png
index e3055864..41fd46b5 100644
--- a/lua/img/listened.png
+++ b/lua/img/listened.png
Binary files differ
diff --git a/lua/img/menu.png b/lua/img/menu.png
index 4226361b..4609939e 100644
--- a/lua/img/menu.png
+++ b/lua/img/menu.png
Binary files differ
diff --git a/lua/img/next.png b/lua/img/next.png
index 72095b52..bb8173e9 100644
--- a/lua/img/next.png
+++ b/lua/img/next.png
Binary files differ
diff --git a/lua/img/pause.png b/lua/img/pause.png
index 3db657a0..7fe61e22 100644
--- a/lua/img/pause.png
+++ b/lua/img/pause.png
Binary files differ
diff --git a/lua/img/pausecirc.png b/lua/img/pausecirc.png
index b1358953..c8122432 100644
--- a/lua/img/pausecirc.png
+++ b/lua/img/pausecirc.png
Binary files differ
diff --git a/lua/img/play.png b/lua/img/play.png
index 39fa3d66..4907e4a1 100644
--- a/lua/img/play.png
+++ b/lua/img/play.png
Binary files differ
diff --git a/lua/img/play_small.png b/lua/img/play_small.png
index 471bbf01..91d842cd 100644
--- a/lua/img/play_small.png
+++ b/lua/img/play_small.png
Binary files differ
diff --git a/lua/img/playcirc.png b/lua/img/playcirc.png
index c76b9ea0..aa44915c 100644
--- a/lua/img/playcirc.png
+++ b/lua/img/playcirc.png
Binary files differ
diff --git a/lua/img/prev.png b/lua/img/prev.png
index b8a591fe..85834eaa 100644
--- a/lua/img/prev.png
+++ b/lua/img/prev.png
Binary files differ
diff --git a/lua/img/queue.png b/lua/img/queue.png
index ec89c164..77e6c6c8 100644
--- a/lua/img/queue.png
+++ b/lua/img/queue.png
Binary files differ
diff --git a/lua/img/repeat.png b/lua/img/repeat.png
index d5d92ef8..4c45f975 100644
--- a/lua/img/repeat.png
+++ b/lua/img/repeat.png
Binary files differ
diff --git a/lua/img/repeat_off.png b/lua/img/repeat_off.png
index a42f0a2f..d1c4fecc 100644
--- a/lua/img/repeat_off.png
+++ b/lua/img/repeat_off.png
Binary files differ
diff --git a/lua/img/repeat_queue.png b/lua/img/repeat_queue.png
index f9c10124..928e1467 100644
--- a/lua/img/repeat_queue.png
+++ b/lua/img/repeat_queue.png
Binary files differ
diff --git a/lua/img/settings.png b/lua/img/settings.png
index 96ee9216..91928081 100644
--- a/lua/img/settings.png
+++ b/lua/img/settings.png
Binary files differ
diff --git a/lua/img/shuffle.png b/lua/img/shuffle.png
index ce087783..39b13ba8 100644
--- a/lua/img/shuffle.png
+++ b/lua/img/shuffle.png
Binary files differ
diff --git a/lua/img/shuffle_off.png b/lua/img/shuffle_off.png
index 8942522f..b5dbcc03 100644
--- a/lua/img/shuffle_off.png
+++ b/lua/img/shuffle_off.png
Binary files differ
diff --git a/lua/img/shuffleplay.png b/lua/img/shuffleplay.png
index 5ec9dbc2..c35318e3 100644
--- a/lua/img/shuffleplay.png
+++ b/lua/img/shuffleplay.png
Binary files differ
diff --git a/lua/img/unlistened.png b/lua/img/unlistened.png
index 8d70e792..a9169a5a 100644
--- a/lua/img/unlistened.png
+++ b/lua/img/unlistened.png
Binary files differ
diff --git a/lua/img/usb.png b/lua/img/usb.png
index 522be6a2..8a83a181 100644
--- a/lua/img/usb.png
+++ b/lua/img/usb.png
Binary files differ
diff --git a/src/tangara/app_console/app_console.cpp b/src/tangara/app_console/app_console.cpp
index 394a47f2..2a8f290b 100644
--- a/src/tangara/app_console/app_console.cpp
+++ b/src/tangara/app_console/app_console.cpp
@@ -207,8 +207,14 @@ void RegisterDbInit() {
int CmdTasks(int argc, char** argv) {
#if (configUSE_TRACE_FACILITY == 0)
- std::cout << "configUSE_TRACE_FACILITY must be enabled" << std::endl;
- std::cout << "also consider configTASKLIST_USE_COREID" << std::endl;
+ std::cout
+ << "FreeRTOS is not configured to track task info." << std::endl
+ << "You can enable task tracing via sdkconfig, by setting" << std::endl
+ << "CONFIG_FREERTOS_USE_TRACE_FACILITY=y. Alternately, use" << std::endl
+ << "idf.py menuconfig to enable Components/FreeRTOS/Kernel" << std::endl
+ << "configUSE_TRACE_FACILITY to do the same." << std::endl << std::endl
+ << "Also consider 'Enable display of xCoreID in vTaskList'," << std::endl
+ << "or CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y" << std::endl;
return 1;
#endif
@@ -218,6 +224,14 @@ int CmdTasks(int argc, char** argv) {
return 1;
}
+ // Sample the task runtime percentage over 2.5 seconds if collecting
+ // task statistics. Else, we don't need to sample for as long.
+#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
+ const int kSamplePeriodMs = 2500;
+#else
+ const int kSamplePeriodMs = 10;
+#endif
+
// Pad the number of tasks so that uxTaskGetSystemState still returns info
// if new tasks are started during measurement.
size_t num_tasks = uxTaskGetNumberOfTasks() + 4;
@@ -229,11 +243,23 @@ int CmdTasks(int argc, char** argv) {
size_t start_num_tasks =
uxTaskGetSystemState(start_status, num_tasks, &start_elapsed_ticks);
- vTaskDelay(pdMS_TO_TICKS(2500));
+ vTaskDelay(pdMS_TO_TICKS(kSamplePeriodMs));
size_t end_num_tasks =
uxTaskGetSystemState(end_status, num_tasks, &end_elapsed_ticks);
+ uint32_t elapsed_ticks = end_elapsed_ticks - start_elapsed_ticks;
+
+ if (0 == elapsed_ticks) {
+ std::cout << "Warning: the scheduler is not recording run-time" << std::endl
+ << "statistics, and this means that detailed task" << std::endl
+ << "information is not available." << std::endl
+ << "Enable CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS" << std::endl
+ << "in sdkconfig to capture these stats, or via" << std::endl
+ << "idf.py menuconfig, in Components/FreeRTOS/Kernel" << std::endl
+ << "configGENERATE_RUN_TIME_STATS." << std::endl;
+ }
+
std::vector<std::pair<uint32_t, std::pmr::string>> info_strings;
for (int i = 0; i < start_num_tasks; i++) {
int k = -1;
@@ -279,8 +305,12 @@ int CmdTasks(int argc, char** argv) {
str << "\t\t";
}
+#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
str << std::fixed << std::setprecision(1) << (time_percent * 100);
str << "%";
+#else
+ str << "(unavailable)";
+#endif
info_strings.push_back({run_time, std::pmr::string{str.str()}});
}
diff --git a/src/tangara/tts/README.md b/src/tangara/tts/README.md
index 63d587da..54aae8ef 100644
--- a/src/tangara/tts/README.md
+++ b/src/tangara/tts/README.md
@@ -47,3 +47,37 @@ logs a `WARN`ing each time it cannot find a TTS sample. You can enable
these log messages on the console by using the command `loglevel warn`,
and then manipulating the click wheel to move through the UI to discover
other missing TTS samples.
+
+## Tasks and Event Passing
+
+### In the `ui` task
+
+There are two main threads involved with running TTS - firstly, the `ui`
+task, which is rooted in `ui::UiTask::Main()` (`src/tangara/ui/lvgl_task.hpp)`.
+By way of the LVGL stack, eventually navigation in the UI results in sending
+a `tts::SelectionChanged` message from `input::TextToSpeech::describe()`
+(`src/tangara/input/feedback_tts.cpp`) to `tts::Provider::feed()`
+(`src/tangara/tts/provider.cpp`), all in the UI task.
+
+The `tts::Provider` is responsible for translating the UI string from a lump
+of text to a TTS sample filename, which is then passed along to the player
+in `tts::Player::playFile()` (`src/tangara/tts/player.cpp`), still on the UI
+thread.
+
+The UI task has a smaller stack than the `worker_X` tasks, and are not
+appropriate to use for audio decoding work, both because they would block any
+UI updates, and also have insufficient stack space for audio decode activity.
+
+### Transitioning to the `WorkerPool` background threads
+
+`playFile()` uses `tasks::WorkerPool::Dispatch()` to fire off a lambda in a
+different task - one of the background `worker_X` tasks, owned by `WorkerPool`.
+Control returns to the UI thread in under 2ms, so it remains pretty responsive
+throughout this flow.
+
+The background worker uses `tts::Player::openAndDecode` to do the bulk of the
+decode/resample/playback work, and it is on this background task that the
+majority of the work occurs. Note that there is nothing stopping the TTS worker
+from consuming a number of worker tasks at once, but we rely on the interaction
+of stream cancellation behaviour between the workers to ensure that previous
+samples' playback is promptly terminated after a new sample is requested.
diff --git a/src/tangara/tts/player.cpp b/src/tangara/tts/player.cpp
index 46e8c48a..9cc7a1f7 100644
--- a/src/tangara/tts/player.cpp
+++ b/src/tangara/tts/player.cpp
@@ -174,7 +174,7 @@ auto Player::decodeToSink(const codecs::ICodec::OutputFormat& format,
// The mixin PcmBuffer should almost always be draining, so we can force
// samples into it more aggressively than with the main music PcmBuffer.
- while (!stereo_buf.isEmpty()) {
+ while (!stereo_buf.isEmpty() && !stream_cancelled_) {
size_t sent = output_.send(stereo_buf.readAcquire());
stereo_buf.readCommit(sent);
}