mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-19 02:15:18 -04:00
Move daap_songalbumid() to its now-unique callsite
This commit is contained in:
parent
748cca63be
commit
facb9957d8
@ -27,27 +27,4 @@ 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__ */
|
||||||
|
16
src/db.c
16
src/db.c
@ -32,7 +32,7 @@
|
|||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "daap_query.h"
|
#include "misc.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
|
|
||||||
@ -3040,6 +3040,7 @@ db_daap_songalbumid_xfunc(sqlite3_context *pv, int n, sqlite3_value **ppv)
|
|||||||
{
|
{
|
||||||
const char *album_artist;
|
const char *album_artist;
|
||||||
const char *album;
|
const char *album;
|
||||||
|
char *hashbuf;
|
||||||
sqlite3_int64 result;
|
sqlite3_int64 result;
|
||||||
|
|
||||||
if (n != 2)
|
if (n != 2)
|
||||||
@ -3058,7 +3059,18 @@ db_daap_songalbumid_xfunc(sqlite3_context *pv, int n, sqlite3_value **ppv)
|
|||||||
album_artist = (const char *)sqlite3_value_text(ppv[0]);
|
album_artist = (const char *)sqlite3_value_text(ppv[0]);
|
||||||
album = (const char *)sqlite3_value_text(ppv[1]);
|
album = (const char *)sqlite3_value_text(ppv[1]);
|
||||||
|
|
||||||
result = daap_songalbumid(album_artist, album);
|
hashbuf = sqlite3_mprintf("%s==%s", (album_artist) ? album_artist : "", (album) ? album : "");
|
||||||
|
if (!hashbuf)
|
||||||
|
{
|
||||||
|
sqlite3_result_error(pv, "daap_songalbumid() out of memory for hashbuf", -1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Limit hash length to 63 bits, due to signed type in sqlite */
|
||||||
|
result = murmur_hash64(hashbuf, strlen(hashbuf), 0) >> 1;
|
||||||
|
|
||||||
|
sqlite3_free(hashbuf);
|
||||||
|
|
||||||
sqlite3_result_int64(pv, result);
|
sqlite3_result_int64(pv, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user