diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2025-02-19 01:57:24 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2025-02-19 01:57:24 +0000 |
| commit | e7fa9bfbd1c0037c874cd156cc3146e2163438ef (patch) | |
| tree | d1f55d4c19b1c2116f73aa05a61e5fdd9663aa24 /src/tangara/tts/provider.cpp | |
| parent | 49e92c295ea8f2e2cd9b0b23c2ca1479e3f2db2a (diff) | |
| parent | eba8825d9f4df93e3f89010a4349c72046faa16a (diff) | |
| download | tangara-fw-e7fa9bfbd1c0037c874cd156cc3146e2163438ef.tar.gz | |
Merge pull request 'Avoid spamming logs if there is no /.tangara-tts/' (#275) from tursiae/tangara-fw:ttslogging into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/275
Diffstat (limited to 'src/tangara/tts/provider.cpp')
| -rw-r--r-- | src/tangara/tts/provider.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/tangara/tts/provider.cpp b/src/tangara/tts/provider.cpp index 2fb6c426..c101dbb1 100644 --- a/src/tangara/tts/provider.cpp +++ b/src/tangara/tts/provider.cpp @@ -75,4 +75,37 @@ auto Provider::feed(const Event& e) -> void { } } +bool Provider::SamplesOnSDCard() { + // Does the /.tangara-tts/ path exist on the SD card? + FILINFO fi; + FRESULT status = f_stat(kTtsPath, &fi); + + switch (status) { + case FR_NO_PATH: + case FR_NO_FILE: + case FR_NO_FILESYSTEM: + // If the SD card isn't mounted, or no matching file, then no samples. + return false; + + case FR_OK: + // If /.tangara-tts exists, let's check it out first. + break; + + default: + // If things look odd, then assume samples aren't present. + ESP_LOGW(kTag, "got unexpected %d status from f_stat(\"%s\")", status, + kTtsPath); + return false; + } + + // If /.tangara-tts exists and is a directory, it probably contains samples. + if (fi.fattrib & AM_DIR) + return true; + + // Otherwise, for example, if it's a file, assume no samples present. + ESP_LOGW(kTag, "got unexpected file attributes for %s: %d", kTtsPath, + fi.fattrib); + return false; +} + } // namespace tts |
