diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-06-15 10:42:28 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-06-15 10:42:28 +1000 |
| commit | c6bb42cdd21b63accd20012373a8a0e41d8566f5 (patch) | |
| tree | 7fdbab3c5f1e285b54ea4949a31db41602b93b83 /src/database/song.cpp | |
| parent | 0024bb1dbe0df319bc7bf022f0c4614cc9c8e0ed (diff) | |
| download | tangara-fw-c6bb42cdd21b63accd20012373a8a0e41d8566f5.tar.gz | |
song -> track
Diffstat (limited to 'src/database/song.cpp')
| -rw-r--r-- | src/database/song.cpp | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/database/song.cpp b/src/database/song.cpp deleted file mode 100644 index c717e55e..00000000 --- a/src/database/song.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2023 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#include "song.hpp" - -#include <komihash.h> - -namespace database { - -/* Helper function to update a komihash stream with a std::string. */ -auto HashString(komihash_stream_t* stream, std::string str) -> void { - komihash_stream_update(stream, str.c_str(), str.length()); -} - -/* - * Uses a komihash stream to incrementally hash tags. This lowers the function's - * memory footprint a little so that it's safe to call from any stack. - */ -auto SongTags::Hash() const -> uint64_t { - // TODO(jacqueline): this function doesn't work very well for songs with no - // tags at all. - komihash_stream_t stream; - komihash_stream_init(&stream, 0); - HashString(&stream, title.value_or("")); - HashString(&stream, artist.value_or("")); - HashString(&stream, album.value_or("")); - return komihash_stream_final(&stream); -} - -auto SongData::UpdateHash(uint64_t new_hash) const -> SongData { - return SongData(id_, filepath_, new_hash, play_count_, is_tombstoned_); -} - -auto SongData::Entomb() const -> SongData { - return SongData(id_, filepath_, tags_hash_, play_count_, true); -} - -auto SongData::Exhume(const std::string& new_path) const -> SongData { - return SongData(id_, new_path, tags_hash_, play_count_, false); -} - -void swap(Song& first, Song& second) { - Song temp = first; - first = second; - second = temp; -} - -} // namespace database |
