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.
This commit is contained in:
Julien BLACHE 2011-04-28 18:25:14 +02:00
parent 49a9ff64dc
commit a70a45d925
4 changed files with 15 additions and 13 deletions

View File

@ -369,7 +369,7 @@ dmap_send_error(struct evhttp_request *req, char *container, char *errmsg)
int 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_map *dfm;
const struct dmap_field *df; 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); 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; val = 0;
if (want_mikd) if (want_mikd)
val += 9; val += 9;

View File

@ -79,6 +79,6 @@ dmap_send_error(struct evhttp_request *req, char *container, char *errmsg);
int 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__ */ #endif /* !__DMAP_HELPERS_H__ */

View File

@ -1046,7 +1046,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
transcode = transcode_needed(req->input_headers, dbmfi.codectype); 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) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DAAP, "Failed to encode song metadata\n"); 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; 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) if (sort_headers)
{ {
ret = daap_sort_build(sctx, dbmfi.title_sort); ret = daap_sort_build(sctx, dbmfi.title_sort);

View File

@ -818,7 +818,7 @@ raop_metadata_prepare(int id, uint64_t rtptime)
goto out_query; 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); evbuffer_free(tmp);
if (ret < 0) if (ret < 0)
{ {