mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-29 21:32:41 +00:00
Fixed macOS / clang3.7 compile.
This commit is contained in:
parent
4068f9a0f2
commit
45811b90a0
@ -106,7 +106,7 @@ static ssize_t fileReadCallback(void *cls, uint64_t pos, char *buf, size_t max)
|
||||
Range* range = static_cast<Range*>(cls);
|
||||
|
||||
size_t offset = (size_t) pos + range->from;
|
||||
offset = std::min(range->to ? range->to : SIZE_MAX, offset);
|
||||
offset = std::min(range->to ? range->to : (size_t) SIZE_MAX, offset);
|
||||
|
||||
size_t avail = range->total ? (range->total - offset) : SIZE_MAX;
|
||||
size_t count = std::min(avail, max);
|
||||
|
@ -484,10 +484,25 @@ void IndexerTrack::ProcessNonStandardMetadata(db::Connection& connection) {
|
||||
}
|
||||
}
|
||||
|
||||
/* http://stackoverflow.com/a/2351171 */
|
||||
static size_t hash32(const char* str) {
|
||||
unsigned int h;
|
||||
unsigned char *p;
|
||||
h = 0;
|
||||
for (p = (unsigned char*)str; *p != '\0'; p++) {
|
||||
h = 37 * h + *p;
|
||||
}
|
||||
h += (h >> 5);
|
||||
return h;
|
||||
}
|
||||
|
||||
uint64_t IndexerTrack::SaveAlbum(db::Connection& dbConnection) {
|
||||
std::string album = this->GetValue("album");
|
||||
std::string value = album + "-" + this->GetValue("album_artist");
|
||||
uint64_t id = std::hash<std::string>()(value);
|
||||
|
||||
/* ideally we'd use std::hash<>, but on some platforms this returns a 64-bit
|
||||
unsigned number, which cannot be easily used with sqlite3. */
|
||||
size_t id = hash32(value.c_str());
|
||||
|
||||
std::string cacheKey = "album-" + value;
|
||||
if (metadataIdCache.find(cacheKey) != metadataIdCache.end()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user