From a70a45d92562df13631f200c5409db06e58b8e01 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Thu, 28 Apr 2011 18:25:14 +0200 Subject: [PATCH] Fix DAAP songlist generation after code move to dmap_common Handling of the sort tags was left into httpd_daap.c where the code runs after the song is added to the songlist - effectively adding the sort tags to the *next* song, leading to incorrect sort tags on the current song. --- src/dmap_common.c | 13 ++++++++++++- src/dmap_common.h | 2 +- src/httpd_daap.c | 11 +---------- src/raop.c | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/dmap_common.c b/src/dmap_common.c index ac64632a..7dfc7db2 100644 --- a/src/dmap_common.c +++ b/src/dmap_common.c @@ -369,7 +369,7 @@ dmap_send_error(struct evhttp_request *req, char *container, char *errmsg) int -dmap_encode_file_metadata(struct evbuffer *songlist, struct evbuffer *song, struct db_media_file_info *dbmfi, const struct dmap_field **meta, int nmeta, int force_wav) +dmap_encode_file_metadata(struct evbuffer *songlist, struct evbuffer *song, struct db_media_file_info *dbmfi, const struct dmap_field **meta, int nmeta, int sort_tags, int force_wav) { const struct dmap_field_map *dfm; const struct dmap_field *df; @@ -479,6 +479,17 @@ dmap_encode_file_metadata(struct evbuffer *songlist, struct evbuffer *song, stru DPRINTF(E_DBG, L_DAAP, "Done with meta tag %s (%s)\n", df->desc, *strval); } + if (sort_tags) + { + dmap_add_string(song, "assn", dbmfi->title_sort); + dmap_add_string(song, "assa", dbmfi->artist_sort); + dmap_add_string(song, "assu", dbmfi->album_sort); + dmap_add_string(song, "assl", dbmfi->album_artist_sort); + + if (dbmfi->composer_sort) + dmap_add_string(song, "assc", dbmfi->composer_sort); + } + val = 0; if (want_mikd) val += 9; diff --git a/src/dmap_common.h b/src/dmap_common.h index 62f6000d..67ab2649 100644 --- a/src/dmap_common.h +++ b/src/dmap_common.h @@ -79,6 +79,6 @@ dmap_send_error(struct evhttp_request *req, char *container, char *errmsg); int -dmap_encode_file_metadata(struct evbuffer *songlist, struct evbuffer *song, struct db_media_file_info *dbmfi, const struct dmap_field **meta, int nmeta, int force_wav); +dmap_encode_file_metadata(struct evbuffer *songlist, struct evbuffer *song, struct db_media_file_info *dbmfi, const struct dmap_field **meta, int nmeta, int sort_tags, int force_wav); #endif /* !__DMAP_HELPERS_H__ */ diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 24a3571a..3017b3bf 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -1046,7 +1046,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf, transcode = transcode_needed(req->input_headers, dbmfi.codectype); - ret = dmap_encode_file_metadata(songlist, song, &dbmfi, meta, nmeta, transcode); + ret = dmap_encode_file_metadata(songlist, song, &dbmfi, meta, nmeta, 1, transcode); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Failed to encode song metadata\n"); @@ -1055,15 +1055,6 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf, break; } - /* Always include sort tags */ - dmap_add_string(song, "assn", dbmfi.title_sort); - dmap_add_string(song, "assa", dbmfi.artist_sort); - dmap_add_string(song, "assu", dbmfi.album_sort); - dmap_add_string(song, "assl", dbmfi.album_artist_sort); - - if (dbmfi.composer_sort) - dmap_add_string(song, "assc", dbmfi.composer_sort); - if (sort_headers) { ret = daap_sort_build(sctx, dbmfi.title_sort); diff --git a/src/raop.c b/src/raop.c index abd57d27..f0d39bd8 100644 --- a/src/raop.c +++ b/src/raop.c @@ -818,7 +818,7 @@ raop_metadata_prepare(int id, uint64_t rtptime) goto out_query; } - ret = dmap_encode_file_metadata(rmd->metadata, tmp, &dbmfi, NULL, 0, 1); + ret = dmap_encode_file_metadata(rmd->metadata, tmp, &dbmfi, NULL, 0, 0, 1); evbuffer_free(tmp); if (ret < 0) {