summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-04-28 13:54:46 +1000
committerjacqueline <me@jacqueline.id.au>2023-04-28 13:54:46 +1000
commit09ad66136d11909c0e6e258a8dc953f2d2b46c41 (patch)
tree1e4e573d1a3ba69cc11e787699b4c638ac9f3ff6 /src
parentbdadc159c7538e88eab5efcfeb2ecf971a510c60 (diff)
downloadtangara-fw-09ad66136d11909c0e6e258a8dc953f2d2b46c41.tar.gz
clang-format
Diffstat (limited to 'src')
-rw-r--r--src/database/tag_processor.cpp81
1 files changed, 43 insertions, 38 deletions
diff --git a/src/database/tag_processor.cpp b/src/database/tag_processor.cpp
index 5752d61b..13a284f6 100644
--- a/src/database/tag_processor.cpp
+++ b/src/database/tag_processor.cpp
@@ -1,8 +1,8 @@
#include "tag_processor.hpp"
+#include <esp_log.h>
#include <ff.h>
#include <tags.h>
-#include <esp_log.h>
namespace database {
@@ -16,36 +16,41 @@ struct Aux {
std::string title;
};
-static int read(Tagctx *ctx, void *buf, int cnt) {
- Aux *aux = reinterpret_cast<Aux*>(ctx->aux);
- UINT bytes_read;
- if (f_read(&aux->file, buf, cnt, &bytes_read) != FR_OK) {
- return -1;
- }
- return bytes_read;
+static int read(Tagctx* ctx, void* buf, int cnt) {
+ Aux* aux = reinterpret_cast<Aux*>(ctx->aux);
+ UINT bytes_read;
+ if (f_read(&aux->file, buf, cnt, &bytes_read) != FR_OK) {
+ return -1;
+ }
+ return bytes_read;
}
-static int seek(Tagctx *ctx, int offset, int whence) {
- Aux *aux = reinterpret_cast<Aux*>(ctx->aux);
- FRESULT res;
- if (whence == 0) {
- // Seek from the start of the file. This is f_lseek's behaviour.
- res = f_lseek(&aux->file, offset);
- } else if (whence == 1) {
- // Seek from current offset.
- res = f_lseek(&aux->file, aux->file.fptr + offset);
- } else if (whence == 2) {
- // Seek from the end of the file
- res = f_lseek(&aux->file, aux->info.fsize + offset);
- } else {
- return -1;
- }
- return res;
+static int seek(Tagctx* ctx, int offset, int whence) {
+ Aux* aux = reinterpret_cast<Aux*>(ctx->aux);
+ FRESULT res;
+ if (whence == 0) {
+ // Seek from the start of the file. This is f_lseek's behaviour.
+ res = f_lseek(&aux->file, offset);
+ } else if (whence == 1) {
+ // Seek from current offset.
+ res = f_lseek(&aux->file, aux->file.fptr + offset);
+ } else if (whence == 2) {
+ // Seek from the end of the file
+ res = f_lseek(&aux->file, aux->info.fsize + offset);
+ } else {
+ return -1;
+ }
+ return res;
}
-static void
-tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagread f) {
- Aux *aux = reinterpret_cast<Aux*>(ctx->aux);
+static void tag(Tagctx* ctx,
+ int t,
+ const char* k,
+ const char* v,
+ int offset,
+ int size,
+ Tagread f) {
+ Aux* aux = reinterpret_cast<Aux*>(ctx->aux);
if (t == Ttitle) {
aux->title = v;
} else if (t == Tartist) {
@@ -55,30 +60,30 @@ tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagr
}
}
-static void
-toc(Tagctx *ctx, int ms, int offset) {}
+static void toc(Tagctx* ctx, int ms, int offset) {}
-} // namespace libtags
+} // namespace libtags
static const std::size_t kBufSize = 1024;
static const char* kTag = "TAGS";
auto GetInfo(const std::string& path, FileInfo* out) -> bool {
libtags::Aux aux;
- if (f_stat(path.c_str(), &aux.info) != FR_OK || f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) {
+ if (f_stat(path.c_str(), &aux.info) != FR_OK ||
+ f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) {
ESP_LOGI(kTag, "failed to open file");
return false;
}
// Fine to have this on the stack; this is only called on the leveldb task.
char buf[kBufSize];
Tagctx ctx;
- ctx.read = libtags::read;
- ctx.seek = libtags::seek;
- ctx.tag = libtags::tag;
- ctx.toc = libtags::toc;
- ctx.aux = &aux;
- ctx.buf = buf;
- ctx.bufsz = kBufSize;
+ ctx.read = libtags::read;
+ ctx.seek = libtags::seek;
+ ctx.tag = libtags::tag;
+ ctx.toc = libtags::toc;
+ ctx.aux = &aux;
+ ctx.buf = buf;
+ ctx.bufsz = kBufSize;
int res = tagsget(&ctx);
f_close(&aux.file);