diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-06-04 08:09:40 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-06-04 08:09:40 +1000 |
| commit | 72344b5777dd78bbad6bbc8b52c0fa271671cf90 (patch) | |
| tree | e060c1a54cafed5c8c0cd5974250e8fab95e3349 /src/tangara/database | |
| parent | 39460931d8e3d044f00f7a4f58b44b1035338f09 (diff) | |
| download | tangara-fw-72344b5777dd78bbad6bbc8b52c0fa271671cf90.tar.gz | |
no more acquire_spi :)
Diffstat (limited to 'src/tangara/database')
| -rw-r--r-- | src/tangara/database/database.cpp | 8 | ||||
| -rw-r--r-- | src/tangara/database/env_esp.cpp | 18 | ||||
| -rw-r--r-- | src/tangara/database/file_gatherer.cpp | 12 | ||||
| -rw-r--r-- | src/tangara/database/tag_parser.cpp | 20 |
4 files changed, 10 insertions, 48 deletions
diff --git a/src/tangara/database/database.cpp b/src/tangara/database/database.cpp index 00dda5ec..3258405b 100644 --- a/src/tangara/database/database.cpp +++ b/src/tangara/database/database.cpp @@ -206,8 +206,6 @@ auto Database::schemaVersion() -> std::string { } auto Database::sizeOnDiskBytes() -> size_t { - auto lock = drivers::acquire_spi(); - FF_DIR dir; FRESULT res = f_opendir(&dir, kDbPath); if (res != FR_OK) { @@ -328,12 +326,8 @@ auto Database::updateIndexes() -> void { continue; } - FRESULT res; FILINFO info; - { - auto lock = drivers::acquire_spi(); - res = f_stat(track->filepath.c_str(), &info); - } + FRESULT res = f_stat(track->filepath.c_str(), &info); std::pair<uint16_t, uint16_t> modified_at{0, 0}; if (res == FR_OK) { diff --git a/src/tangara/database/env_esp.cpp b/src/tangara/database/env_esp.cpp index 86a30613..843be91d 100644 --- a/src/tangara/database/env_esp.cpp +++ b/src/tangara/database/env_esp.cpp @@ -103,12 +103,10 @@ class EspSequentialFile final : public SequentialFile { EspSequentialFile(const std::string& filename, FIL file) : file_(file), filename_(filename) {} ~EspSequentialFile() override { - auto lock = drivers::acquire_spi(); f_close(&file_); } Status Read(size_t n, Slice* result, char* scratch) override { - auto lock = drivers::acquire_spi(); UINT read_size = 0; FRESULT res = f_read(&file_, scratch, n, &read_size); if (res != FR_OK) { // Read error. @@ -119,7 +117,6 @@ class EspSequentialFile final : public SequentialFile { } Status Skip(uint64_t n) override { - auto lock = drivers::acquire_spi(); DWORD current_pos = f_tell(&file_); FRESULT res = f_lseek(&file_, current_pos + n); if (res != FR_OK) { @@ -151,7 +148,6 @@ class EspRandomAccessFile final : public RandomAccessFile { size_t n, Slice* result, char* scratch) const override { - auto lock = drivers::acquire_spi(); FIL file; FRESULT res = f_open(&file, filename_.c_str(), FA_READ); if (res != FR_OK) { @@ -200,7 +196,6 @@ class EspWritableFile final : public WritableFile { return EspError(filename_, FR_NOT_ENABLED); } - auto lock = drivers::acquire_spi(); size_t write_size = data.size(); const char* write_data = data.data(); @@ -214,7 +209,6 @@ class EspWritableFile final : public WritableFile { } Status Close() override { - auto lock = drivers::acquire_spi(); is_open_ = false; FRESULT res = f_close(&file_); if (res != FR_OK) { @@ -229,7 +223,6 @@ class EspWritableFile final : public WritableFile { if (!is_open_) { return EspError(filename_, FR_NOT_ENABLED); } - auto lock = drivers::acquire_spi(); FRESULT res = f_sync(&file_); if (res != FR_OK) { return EspError(filename_, res); @@ -285,7 +278,6 @@ EspEnv::~EspEnv() { Status EspEnv::NewSequentialFile(const std::string& filename, SequentialFile** result) { - auto lock = drivers::acquire_spi(); FIL file; FRESULT res = f_open(&file, filename.c_str(), FA_READ); if (res != FR_OK) { @@ -299,7 +291,6 @@ Status EspEnv::NewSequentialFile(const std::string& filename, Status EspEnv::NewRandomAccessFile(const std::string& filename, RandomAccessFile** result) { - auto lock = drivers::acquire_spi(); // EspRandomAccessFile doesn't try to open the file until it's needed, so // we need to first ensure the file exists to handle the NotFound case // correctly. @@ -316,7 +307,6 @@ Status EspEnv::NewRandomAccessFile(const std::string& filename, Status EspEnv::NewWritableFile(const std::string& filename, WritableFile** result) { - auto lock = drivers::acquire_spi(); FIL file; FRESULT res = f_open(&file, filename.c_str(), FA_WRITE | FA_CREATE_ALWAYS); if (res != FR_OK) { @@ -330,7 +320,6 @@ Status EspEnv::NewWritableFile(const std::string& filename, Status EspEnv::NewAppendableFile(const std::string& filename, WritableFile** result) { - auto lock = drivers::acquire_spi(); FIL file; FRESULT res = f_open(&file, filename.c_str(), FA_WRITE | FA_OPEN_APPEND); if (res != FR_OK) { @@ -343,7 +332,6 @@ Status EspEnv::NewAppendableFile(const std::string& filename, } bool EspEnv::FileExists(const std::string& filename) { - auto lock = drivers::acquire_spi(); FILINFO info; return f_stat(filename.c_str(), &info) == FR_OK; } @@ -352,7 +340,6 @@ Status EspEnv::GetChildren(const std::string& directory_path, std::vector<std::string>* result) { result->clear(); - auto lock = drivers::acquire_spi(); FF_DIR dir; FRESULT res = f_opendir(&dir, directory_path.c_str()); if (res != FR_OK) { @@ -380,7 +367,6 @@ Status EspEnv::GetChildren(const std::string& directory_path, } Status EspEnv::RemoveFile(const std::string& filename) { - auto lock = drivers::acquire_spi(); FRESULT res = f_unlink(filename.c_str()); if (res != FR_OK) { return EspError(filename, res); @@ -389,7 +375,6 @@ Status EspEnv::RemoveFile(const std::string& filename) { } Status EspEnv::CreateDir(const std::string& dirname) { - auto lock = drivers::acquire_spi(); FRESULT res = f_mkdir(dirname.c_str()); if (res != FR_OK) { return EspError(dirname, res); @@ -402,7 +387,6 @@ Status EspEnv::RemoveDir(const std::string& dirname) { } Status EspEnv::GetFileSize(const std::string& filename, uint64_t* size) { - auto lock = drivers::acquire_spi(); FILINFO info; FRESULT res = f_stat(filename.c_str(), &info); if (res != FR_OK) { @@ -421,7 +405,6 @@ Status EspEnv::RenameFile(const std::string& from, const std::string& to) { return s; } } - auto lock = drivers::acquire_spi(); FRESULT res = f_rename(from.c_str(), to.c_str()); if (res != FR_OK) { return EspError(from, res); @@ -460,7 +443,6 @@ Status EspEnv::GetTestDirectory(std::string* result) { } Status EspEnv::NewLogger(const std::string& filename, Logger** result) { - auto lock = drivers::acquire_spi(); FIL file; FRESULT res = f_open(&file, filename.c_str(), FA_WRITE | FA_OPEN_APPEND); if (res != FR_OK) { diff --git a/src/tangara/database/file_gatherer.cpp b/src/tangara/database/file_gatherer.cpp index 75a1af27..dd4b1138 100644 --- a/src/tangara/database/file_gatherer.cpp +++ b/src/tangara/database/file_gatherer.cpp @@ -33,11 +33,7 @@ auto FileGathererImpl::FindFiles( const TCHAR* next_path = static_cast<const TCHAR*>(next_path_str.c_str()); FF_DIR dir; - FRESULT res; - { - auto lock = drivers::acquire_spi(); - res = f_opendir(&dir, next_path); - } + FRESULT res = f_opendir(&dir, next_path); if (res != FR_OK) { // TODO: log. continue; @@ -45,10 +41,7 @@ auto FileGathererImpl::FindFiles( for (;;) { FILINFO info; - { - auto lock = drivers::acquire_spi(); - res = f_readdir(&dir, &info); - } + res = f_readdir(&dir, &info); if (res != FR_OK || info.fname[0] == 0) { // No more files in the directory. break; @@ -72,7 +65,6 @@ auto FileGathererImpl::FindFiles( } } - auto lock = drivers::acquire_spi(); f_closedir(&dir); } } diff --git a/src/tangara/database/tag_parser.cpp b/src/tangara/database/tag_parser.cpp index 2df2d90f..d377adb1 100644 --- a/src/tangara/database/tag_parser.cpp +++ b/src/tangara/database/tag_parser.cpp @@ -148,15 +148,13 @@ auto TagParserImpl::parseNew(std::string_view p) -> std::shared_ptr<TrackTags> { libtags::Aux aux; auto out = TrackTags::create(); aux.tags = out.get(); - { - auto lock = drivers::acquire_spi(); - if (f_stat(path.c_str(), &aux.info) != FR_OK || - f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) { - ESP_LOGW(kTag, "failed to open file %s", path.c_str()); - return {}; - } + if (f_stat(path.c_str(), &aux.info) != FR_OK || + f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) { + ESP_LOGW(kTag, "failed to open file %s", path.c_str()); + return {}; } + // Fine to have this on the stack; this is only called on tasks with large // stacks anyway, due to all the string handling. char buf[kBufSize]; @@ -169,12 +167,8 @@ auto TagParserImpl::parseNew(std::string_view p) -> std::shared_ptr<TrackTags> { ctx.buf = buf; ctx.bufsz = kBufSize; - int res; - { - auto lock = drivers::acquire_spi(); - res = tagsget(&ctx); - f_close(&aux.file); - } + int res = tagsget(&ctx); + f_close(&aux.file); if (res != 0) { // Parsing failed. |
