From fe19478e0f286191c3bf1b9946b89ed26d5c4bae Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 2 May 2023 16:10:21 +1000 Subject: [PATCH] Output hash of song triple --- src/database/CMakeLists.txt | 2 +- src/database/tag_processor.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/database/CMakeLists.txt b/src/database/CMakeLists.txt index 47f8fe31..27cc7071 100644 --- a/src/database/CMakeLists.txt +++ b/src/database/CMakeLists.txt @@ -1,7 +1,7 @@ idf_component_register( SRCS "env_esp.cpp" "database.cpp" "tag_processor.cpp" "db_task.cpp" INCLUDE_DIRS "include" - REQUIRES "result" "span" "esp_psram" "fatfs" "libtags") + REQUIRES "result" "span" "esp_psram" "fatfs" "libtags" "komihash") target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS}) diff --git a/src/database/tag_processor.cpp b/src/database/tag_processor.cpp index 13a284f6..c1795686 100644 --- a/src/database/tag_processor.cpp +++ b/src/database/tag_processor.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include namespace database { @@ -97,6 +99,13 @@ auto GetInfo(const std::string& path, FileInfo* out) -> bool { ESP_LOGI(kTag, "artist: %s", aux.artist.c_str()); ESP_LOGI(kTag, "album: %s", aux.album.c_str()); ESP_LOGI(kTag, "title: %s", aux.title.c_str()); + komihash_stream_t hash; + komihash_stream_init(&hash, 0); + komihash_stream_update(&hash, aux.artist.c_str(), aux.artist.length()); + komihash_stream_update(&hash, aux.album.c_str(), aux.album.length()); + komihash_stream_update(&hash, aux.title.c_str(), aux.title.length()); + uint64_t final_hash = komihash_stream_final(&hash); + ESP_LOGI(kTag, "hash: %#llx", final_hash); out->is_playable = true; out->title = aux.title; return true;