From d3350713d1c80779279a689c7e464343347b1305 Mon Sep 17 00:00:00 2001 From: Ace Jones Date: Mon, 4 Jan 2010 18:00:05 +0100 Subject: [PATCH] Return daap.songalbumid as a hash of the album_artist + album iPhone remote will later want to query by album. Instead of doing a fulltext query, it uses a 64-bit hash of the album + album_artist. It is not necessary to use the same hash algorithm that iTunes uses. The important thing is that we can later respond to a query=('daap.songalbumid:xxx') with this value. --- src/httpd_daap.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/httpd_daap.c b/src/httpd_daap.c index da84ce56..72f36cbb 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "evhttp/evhttp.h" @@ -175,6 +176,8 @@ static struct dmap_field_map dmap_fields[] = -1, -1 }, { 0, DMAP_TYPE_STRING, "asal", "daap.songalbum", dbmfi_offsetof(album), -1 }, + { 0, DMAP_TYPE_LONG, "asai", "daap.songalbumid", /* special case; will be transformed to LONG (hash) */ + dbmfi_offsetof(album), -1 }, { 0, DMAP_TYPE_STRING, "asar", "daap.songartist", dbmfi_offsetof(artist), -1 }, { 0, DMAP_TYPE_SHORT, "asbt", "daap.songbeatsperminute", @@ -960,6 +963,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf, char **strval; char *ptr; uint32_t *meta; + int64_t songalbumid; int nmeta; int nsongs; int transcode; @@ -1153,6 +1157,19 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf, continue; } + /* Special handling for songalbumid (asai) + * Return an int64_t hash of the album_artist & album + */ + if (strcmp(dfm->tag, "asai") == 0) + { + songalbumid = daap_songalbumid(dbmfi.album_artist, dbmfi.album); + + dmap_add_long(song, dfm->tag, songalbumid); + + DPRINTF(E_DBG, L_DAAP, "Generated meta tag %s (%" PRIi64 ") based on (%s,%s)\n", dfm->desc, songalbumid, dbmfi.album_artist, dbmfi.album); + continue; + } + if (transcode) { switch (dfm->mfi_offset)