Add daap_songalbumid() to generate the songalbumid hash
Make it an inline function as it's a short function and has only got 2 call sites.
This commit is contained in:
parent
8ef57bbb41
commit
19a244095a
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
struct dmap_query_field_map {
|
struct dmap_query_field_map {
|
||||||
uint32_t hash;
|
uint32_t hash;
|
||||||
int as_int;
|
int as_int;
|
||||||
|
@ -24,4 +27,27 @@ daap_query_init(void);
|
||||||
void
|
void
|
||||||
daap_query_deinit(void);
|
daap_query_deinit(void);
|
||||||
|
|
||||||
|
|
||||||
|
static inline int64_t
|
||||||
|
daap_songalbumid(const char *album_artist, const char *album)
|
||||||
|
{
|
||||||
|
/* album_artist & album are both VARCHAR(1024) + 2 chars + NUL */
|
||||||
|
char hashbuf[2052];
|
||||||
|
uint64_t hash;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = snprintf(hashbuf, sizeof(hashbuf), "%s==%s", (album_artist) ? album_artist : "", (album) ? album : "");
|
||||||
|
if ((ret < 0) || (ret >= sizeof(hashbuf)))
|
||||||
|
{
|
||||||
|
DPRINTF(E_WARN, L_DAAP, "Not enough room for album_artist==album concatenation\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Limit hash length to 63 bits, due to signed type in sqlite */
|
||||||
|
hash = murmur_hash64(hashbuf, ret, 0);
|
||||||
|
|
||||||
|
return hash >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* !__DAAP_QUERY_H__ */
|
#endif /* !__DAAP_QUERY_H__ */
|
||||||
|
|
Loading…
Reference in New Issue