From eddcd8676d15997f81861c2b6d9b65cf4ba7cb42 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 08:44:50 +0200 Subject: [PATCH 01/17] [mpd] ignore requests for "notcommands" --- src/mpd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 24ffa5e2..20c24950 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -3309,11 +3309,11 @@ static struct command mpd_handlers[] = .mpdcommand = "commands", .handler = mpd_command_commands }, - /* { .mpdcommand = "notcommands", - .handler = mpd_command_notcommands + .handler = mpd_command_ignore }, + /* { .mpdcommand = "tagtypes", .handler = mpd_command_tagtypes From 670187387feca3ba3143d0ff7787c5e83e2d0756 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 08:55:10 +0200 Subject: [PATCH 02/17] [mpd] ignore requests for "urlhandlers" --- src/mpd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mpd.c b/src/mpd.c index 20c24950..95f9efef 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -3318,10 +3318,12 @@ static struct command mpd_handlers[] = .mpdcommand = "tagtypes", .handler = mpd_command_tagtypes }, + */ { .mpdcommand = "urlhandlers", - .handler = mpd_command_urlhandlers + .handler = mpd_command_ignore }, + /* { .mpdcommand = "decoders", .handler = mpd_command_decoders From b728db8470794d2ba6604bcfe4657386868fa083 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 09:02:52 +0200 Subject: [PATCH 03/17] [mpd] implement command "tagtypes" to return the list of supported tags --- src/mpd.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 95f9efef..900e39ae 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -2867,6 +2867,28 @@ mpd_command_ignore(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) static int mpd_command_commands(struct evbuffer *evbuf, int argc, char **argv, char **errmsg); +/* + * Command handler function for 'tagtypes' + * Returns a lists with supported tags in the form: + * tagtype: Artist + */ +static int +mpd_command_tagtypes(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) +{ + evbuffer_add_printf(evbuf, + "tagtype: Artist\n" + "tagtype: AlbumArtist\n" + "tagtype: ArtistSort\n" + "tagtype: AlbumArtistSort\n" + "tagtype: Album\n" + "tagtype: Title\n" + "tagtype: Track\n" + "tagtype: Genre\n" + "tagtype: Disc\n"); + + return 0; +} + struct command { @@ -3313,12 +3335,10 @@ static struct command mpd_handlers[] = .mpdcommand = "notcommands", .handler = mpd_command_ignore }, - /* { .mpdcommand = "tagtypes", .handler = mpd_command_tagtypes }, - */ { .mpdcommand = "urlhandlers", .handler = mpd_command_ignore From 3a495a3d48b134a9ecb42807724f79a0cbf0fed5 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 10:42:09 +0200 Subject: [PATCH 04/17] move setting query_params.idx_type out of generic queue make function --- src/player.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/player.c b/src/player.c index 4bbd659a..88ee6eec 100644 --- a/src/player.c +++ b/src/player.c @@ -770,8 +770,6 @@ player_queue_make(struct query_params *qp, const char *sort) uint32_t song_length; int ret; - qp->idx_type = I_NONE; - if (sort) { if (strcmp(sort, "name") == 0) @@ -960,6 +958,7 @@ player_queue_make_daap(struct player_source **head, const char *query, const cha qp.offset = 0; qp.limit = 0; qp.sort = S_NONE; + qp.idx_type = I_NONE; if (quirk) { @@ -1092,6 +1091,8 @@ player_queue_make_pl(int plid, uint32_t *id) else return NULL; + qp.idx_type = I_NONE; + ps = player_queue_make(&qp, NULL); if (qp.filter) From 3832692929b694c47013672081bd59ac59499467 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 10:47:48 +0200 Subject: [PATCH 05/17] move setting query_params.sort out of generic queue make function --- src/player.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/player.c b/src/player.c index 88ee6eec..1842222b 100644 --- a/src/player.c +++ b/src/player.c @@ -760,7 +760,7 @@ metadata_check_icy(void) /* Audio sources */ /* Thread: httpd (DACP) */ static struct player_source * -player_queue_make(struct query_params *qp, const char *sort) +player_queue_make(struct query_params *qp) { struct db_media_file_info dbmfi; struct player_source *q_head; @@ -770,16 +770,6 @@ player_queue_make(struct query_params *qp, const char *sort) uint32_t song_length; int ret; - if (sort) - { - if (strcmp(sort, "name") == 0) - qp->sort = S_NAME; - else if (strcmp(sort, "album") == 0) - qp->sort = S_ALBUM; - else if (strcmp(sort, "artist") == 0) - qp->sort = S_ARTIST; - } - ret = db_query_start(qp); if (ret < 0) { @@ -1039,7 +1029,17 @@ player_queue_make_daap(struct player_source **head, const char *query, const cha qp.filter = daap_query_parse_sql(query); } - ps = player_queue_make(&qp, sort); + if (sort) + { + if (strcmp(sort, "name") == 0) + qp.sort = S_NAME; + else if (strcmp(sort, "album") == 0) + qp.sort = S_ALBUM; + else if (strcmp(sort, "artist") == 0) + qp.sort = S_ARTIST; + } + + ps = player_queue_make(&qp); if (qp.filter) free(qp.filter); @@ -1093,7 +1093,7 @@ player_queue_make_pl(int plid, uint32_t *id) qp.idx_type = I_NONE; - ps = player_queue_make(&qp, NULL); + ps = player_queue_make(&qp); if (qp.filter) free(qp.filter); @@ -1145,7 +1145,7 @@ player_queue_make_mpd(char *path, int recursive) DPRINTF(E_DBG, L_PLAYER, "Out of memory\n"); } - ps = player_queue_make(&qp, NULL); + ps = player_queue_make(&qp); sqlite3_free(qp.filter); return ps; From fb92040d4b05fb72399428fe1a6abbf029a3ab0c Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 10:54:58 +0200 Subject: [PATCH 06/17] expose generic player_queue_make function --- src/player.c | 2 +- src/player.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/player.c b/src/player.c index 1842222b..e4f64f40 100644 --- a/src/player.c +++ b/src/player.c @@ -759,7 +759,7 @@ metadata_check_icy(void) /* Audio sources */ /* Thread: httpd (DACP) */ -static struct player_source * +struct player_source * player_queue_make(struct query_params *qp) { struct db_media_file_info dbmfi; diff --git a/src/player.h b/src/player.h index a0a591e1..0f14f6b0 100644 --- a/src/player.h +++ b/src/player.h @@ -4,6 +4,8 @@ #include +#include "db.h" + /* AirTunes v2 packet interval in ns */ /* (352 samples/packet * 1e9 ns/s) / 44100 samples/s = 7981859 ns/packet */ # define AIRTUNES_V2_STREAM_PERIOD 7981859 @@ -182,6 +184,9 @@ player_repeat_set(enum repeat_mode mode); int player_shuffle_set(int enable); +struct player_source * +player_queue_make(struct query_params *qp); + int player_queue_make_daap(struct player_source **head, const char *query, const char *queuefilter, const char *sort, int quirk); From 76011c927cb1cd9e32eeb3c6c5e73ef92c75a156 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 11:07:03 +0200 Subject: [PATCH 07/17] [mpd] implement command "findadd" --- src/mpd.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/mpd.c b/src/mpd.c index 900e39ae..23a8e23e 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -2113,6 +2113,44 @@ mpd_command_find(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) static int mpd_command_findadd(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) { + struct query_params qp; + struct player_source *ps; + int ret; + + if (argc < 3 || ((argc - 1) % 2) != 0) + { + ret = asprintf(errmsg, "Missing argument(s) for command 'findadd'"); + if (ret < 0) + DPRINTF(E_LOG, L_MPD, "Out of memory\n"); + return ACK_ERROR_ARG; + } + + memset(&qp, 0, sizeof(struct query_params)); + + qp.type = Q_ITEMS; + qp.sort = S_NAME; + qp.idx_type = I_NONE; + + mpd_get_query_params_find(argc - 1, argv + 1, &qp); + + ps = player_queue_make(&qp); + + if (!ps) + { + ret = asprintf(errmsg, "Failed to add songs to playlist"); + if (ret < 0) + DPRINTF(E_LOG, L_MPD, "Out of memory\n"); + return ACK_ERROR_UNKNOWN; + } + + player_queue_add(ps); + + ret = player_playback_start(NULL); + if (ret < 0) + { + DPRINTF(E_LOG, L_MPD, "Could not start playback\n"); + } + return 0; } From 0921675efa088c09aafa594e22934aa1b81096c3 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 1 May 2015 11:37:05 +0200 Subject: [PATCH 08/17] [mpd] implement command "searchadd" --- src/mpd.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/mpd.c b/src/mpd.c index 23a8e23e..48579d1b 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -2499,6 +2499,50 @@ mpd_command_search(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) return 0; } +static int +mpd_command_searchadd(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) +{ + struct query_params qp; + struct player_source *ps; + int ret; + + if (argc < 3 || ((argc - 1) % 2) != 0) + { + ret = asprintf(errmsg, "Missing argument(s) for command 'search'"); + if (ret < 0) + DPRINTF(E_LOG, L_MPD, "Out of memory\n"); + return ACK_ERROR_ARG; + } + + memset(&qp, 0, sizeof(struct query_params)); + + qp.type = Q_ITEMS; + qp.sort = S_NAME; + qp.idx_type = I_NONE; + + mpd_get_query_params_search(argc - 1, argv + 1, &qp); + + ps = player_queue_make(&qp); + + if (!ps) + { + ret = asprintf(errmsg, "Failed to add songs to playlist"); + if (ret < 0) + DPRINTF(E_LOG, L_MPD, "Out of memory\n"); + return ACK_ERROR_UNKNOWN; + } + + player_queue_add(ps); + + ret = player_playback_start(NULL); + if (ret < 0) + { + DPRINTF(E_LOG, L_MPD, "Could not start playback\n"); + } + + return 0; +} + /* * Command handler function for 'update' * Initiates an init-rescan (scans for new files) @@ -3261,11 +3305,11 @@ static struct command mpd_handlers[] = .mpdcommand = "search", .handler = mpd_command_search }, - /* { .mpdcommand = "searchadd", .handler = mpd_command_searchadd }, + /* { .mpdcommand = "searchaddpl", .handler = mpd_command_searchaddpl From a03a9d1e7c32ed83c8f2f883bbaf72c9eff6112a Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 2 May 2015 07:12:06 +0200 Subject: [PATCH 09/17] [mpd] support "genre" in commands "find" and "search" --- src/mpd.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mpd.c b/src/mpd.c index 48579d1b..bb926fb3 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1978,6 +1978,10 @@ mpd_get_query_params_find(int argc, char **argv, struct query_params *qp) { c1 = sqlite3_mprintf("(f.title = '%q')", argv[i + 1]); } + else if (0 == strcasecmp(argv[i], "genre")) + { + c1 = sqlite3_mprintf("(f.genre = '%q')", argv[i + 1]); + } else if (i == 0 && argc == 1) { // Special case: a single token is allowed if listing albums for an artist @@ -2201,6 +2205,12 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) qp.sort = S_YEAR; type = "Date: "; } + else if (0 == strcasecmp(argv[1], "genre")) + { + qp.type = Q_BROWSE_GENRES; + qp.sort = S_NONE; + type = "Genre: "; + } else { DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]); @@ -2225,7 +2235,7 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) return ACK_ERROR_UNKNOWN; } - if (qp.type == Q_BROWSE_YEARS) + if (qp.type & Q_F_BROWSE) { while (((ret = db_query_fetch_string_sort(&qp, &browse_item, &sort_item)) == 0) && (browse_item)) { @@ -2412,6 +2422,10 @@ mpd_get_query_params_search(int argc, char **argv, struct query_params *qp) { c1 = sqlite3_mprintf("(f.title LIKE '%%%q%%')", argv[i + 1]); } + else if (0 == strcasecmp(argv[i], "genre")) + { + c1 = sqlite3_mprintf("(f.genre LIKE '%%%q%%')", argv[i + 1]); + } else { DPRINTF(E_WARN, L_MPD, "Parameter '%s' is not supported by forked-daapd and will be ignored\n", argv[i]); From 1300b2f018062cabe8acdc59d3a5b56ac2cb0f72 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 2 May 2015 07:26:13 +0200 Subject: [PATCH 10/17] [mpd] support "disc" parameter in commands "list", "find", "search" --- src/db.c | 4 ++++ src/db.h | 1 + src/mpd.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/db.c b/src/db.c index d4eb2494..abcca76a 100644 --- a/src/db.c +++ b/src/db.c @@ -1535,6 +1535,10 @@ db_query_start(struct query_params *qp) ret = db_build_query_browse(qp, "year", "year", &query); break; + case Q_BROWSE_DISCS: + ret = db_build_query_browse(qp, "disc", "disc", &query); + break; + case Q_COUNT_ITEMS: ret = db_build_query_count_items(qp, &query); break; diff --git a/src/db.h b/src/db.h index dc2a77b3..d5f6ef6e 100644 --- a/src/db.h +++ b/src/db.h @@ -41,6 +41,7 @@ enum query_type { Q_GROUP_DIRS = Q_F_BROWSE | (1 << 10), Q_BROWSE_YEARS = Q_F_BROWSE | (1 << 11), Q_COUNT_ITEMS = (1 << 12), + Q_BROWSE_DISCS = Q_F_BROWSE | (1 << 13), }; #define ARTWORK_UNKNOWN 0 diff --git a/src/mpd.c b/src/mpd.c index bb926fb3..d2febfd0 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1925,6 +1925,7 @@ mpd_get_query_params_find(int argc, char **argv, struct query_params *qp) int start_pos; int end_pos; int i; + uint32_t num; int ret; c1 = NULL; @@ -1982,6 +1983,14 @@ mpd_get_query_params_find(int argc, char **argv, struct query_params *qp) { c1 = sqlite3_mprintf("(f.genre = '%q')", argv[i + 1]); } + else if (0 == strcasecmp(argv[i], "disc")) + { + ret = safe_atou32(argv[i + 1], &num); + if (ret < 0) + DPRINTF(E_WARN, L_MPD, "Disc parameter '%s' is not an integer and will be ignored\n", argv[i + 1]); + else + c1 = sqlite3_mprintf("(f.disc = %d)", num); + } else if (i == 0 && argc == 1) { // Special case: a single token is allowed if listing albums for an artist @@ -2211,6 +2220,12 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) qp.sort = S_NONE; type = "Genre: "; } + else if (0 == strcasecmp(argv[1], "disc")) + { + qp.type = Q_BROWSE_DISCS; + qp.sort = S_NONE; + type = "Disc: "; + } else { DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]); @@ -2369,6 +2384,7 @@ mpd_get_query_params_search(int argc, char **argv, struct query_params *qp) int start_pos; int end_pos; int i; + uint32_t num; int ret; c1 = NULL; @@ -2426,6 +2442,14 @@ mpd_get_query_params_search(int argc, char **argv, struct query_params *qp) { c1 = sqlite3_mprintf("(f.genre LIKE '%%%q%%')", argv[i + 1]); } + else if (0 == strcasecmp(argv[i], "disc")) + { + ret = safe_atou32(argv[i + 1], &num); + if (ret < 0) + DPRINTF(E_WARN, L_MPD, "Disc parameter '%s' is not an integer and will be ignored\n", argv[i + 1]); + else + c1 = sqlite3_mprintf("(f.disc = %d)", num); + } else { DPRINTF(E_WARN, L_MPD, "Parameter '%s' is not supported by forked-daapd and will be ignored\n", argv[i]); From ed8b69c118e5a9dd69de6648b46bd94a96df864f Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 2 May 2015 07:31:54 +0200 Subject: [PATCH 11/17] [mpd] return proper error type if playlist does not exist --- src/mpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mpd.c b/src/mpd.c index d2febfd0..30cafdb2 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1760,7 +1760,7 @@ mpd_command_listplaylistinfo(struct evbuffer *evbuf, int argc, char **argv, char ret = asprintf(errmsg, "Playlist not found for path '%s'", argv[1]); if (ret < 0) DPRINTF(E_LOG, L_MPD, "Out of memory\n"); - return ACK_ERROR_ARG; + return ACK_ERROR_NO_EXIST; } memset(&qp, 0, sizeof(struct query_params)); From fefd91fabcc16519a74807cf6d42c1222d634972 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 2 May 2015 09:18:18 +0200 Subject: [PATCH 12/17] [mpd] support "track" parameter in commands "list", "find", "search" --- src/db.c | 4 ++++ src/db.h | 1 + src/mpd.c | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/db.c b/src/db.c index abcca76a..6163b1ae 100644 --- a/src/db.c +++ b/src/db.c @@ -1539,6 +1539,10 @@ db_query_start(struct query_params *qp) ret = db_build_query_browse(qp, "disc", "disc", &query); break; + case Q_BROWSE_TRACKS: + ret = db_build_query_browse(qp, "track", "track", &query); + break; + case Q_COUNT_ITEMS: ret = db_build_query_count_items(qp, &query); break; diff --git a/src/db.h b/src/db.h index d5f6ef6e..aa87b84e 100644 --- a/src/db.h +++ b/src/db.h @@ -42,6 +42,7 @@ enum query_type { Q_BROWSE_YEARS = Q_F_BROWSE | (1 << 11), Q_COUNT_ITEMS = (1 << 12), Q_BROWSE_DISCS = Q_F_BROWSE | (1 << 13), + Q_BROWSE_TRACKS = Q_F_BROWSE | (1 << 14), }; #define ARTWORK_UNKNOWN 0 diff --git a/src/mpd.c b/src/mpd.c index 30cafdb2..945bd461 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1991,6 +1991,14 @@ mpd_get_query_params_find(int argc, char **argv, struct query_params *qp) else c1 = sqlite3_mprintf("(f.disc = %d)", num); } + else if (0 == strcasecmp(argv[i], "track")) + { + ret = safe_atou32(argv[i + 1], &num); + if (ret < 0) + DPRINTF(E_WARN, L_MPD, "Track parameter '%s' is not an integer and will be ignored\n", argv[i + 1]); + else + c1 = sqlite3_mprintf("(f.track = %d)", num); + } else if (i == 0 && argc == 1) { // Special case: a single token is allowed if listing albums for an artist @@ -2226,6 +2234,12 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) qp.sort = S_NONE; type = "Disc: "; } + else if (0 == strcasecmp(argv[1], "track")) + { + qp.type = Q_BROWSE_TRACKS; + qp.sort = S_NONE; + type = "Track: "; + } else { DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]); @@ -2450,6 +2464,14 @@ mpd_get_query_params_search(int argc, char **argv, struct query_params *qp) else c1 = sqlite3_mprintf("(f.disc = %d)", num); } + else if (0 == strcasecmp(argv[i], "track")) + { + ret = safe_atou32(argv[i + 1], &num); + if (ret < 0) + DPRINTF(E_WARN, L_MPD, "Track parameter '%s' is not an integer and will be ignored\n", argv[i + 1]); + else + c1 = sqlite3_mprintf("(f.track = %d)", num); + } else { DPRINTF(E_WARN, L_MPD, "Parameter '%s' is not supported by forked-daapd and will be ignored\n", argv[i]); From 91338c8548f4e374ccc25d2b04006b10454d6c92 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 9 May 2015 05:52:03 +0200 Subject: [PATCH 13/17] [mpd] ignore requests for "channels" --- src/mpd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mpd.c b/src/mpd.c index 945bd461..53579615 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -3504,10 +3504,12 @@ static struct command mpd_handlers[] = .mpdcommand = "unsubscribe", .handler = mpd_command_unsubscribe }, + */ { .mpdcommand = "channels", - .handler = mpd_command_channels + .handler = mpd_command_ignore }, + /* { .mpdcommand = "readmessages", .handler = mpd_command_readmessages From 5d22d74dbad4b53914a0edac28f8065c7e0f11d7 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 9 May 2015 06:03:26 +0200 Subject: [PATCH 14/17] [mpd] ignore requests for "sticker" --- src/mpd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 53579615..0986c27b 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -3411,12 +3411,10 @@ static struct command mpd_handlers[] = /* * Stickers */ - /* { .mpdcommand = "sticker", - .handler = mpd_command_sticker + .handler = mpd_command_ignore }, - */ /* * Connection settings From decc482e2cd52b1ca099f1d1bd7453b4a8d7e390 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 9 May 2015 06:31:59 +0200 Subject: [PATCH 15/17] [mpd] only return "id" attribute if song information is requested for the current playlist mpd does not expose a persistent song id, instead the id returned in playlistinfo is a unique id for the song in the queue. The same song has different ids if it occurs more than once in the queue. --- src/mpd.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 0986c27b..b49832ad 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -397,11 +397,13 @@ mpd_add_mediainfo(struct evbuffer *evbuf, struct media_file_info *mfi, int pos_p ret = evbuffer_add_printf(evbuf, "Pos: %d\n", pos_pl); + + //TODO mpd does not return the persistent id of a file but instead a unique id in the current playlist + ret = evbuffer_add_printf(evbuf, + "Id: %d\n", + mfi->id); } - ret = evbuffer_add_printf(evbuf, - "Id: %d\n", - mfi->id); return ret; } @@ -454,7 +456,6 @@ mpd_add_mediainfo_byid(struct evbuffer *evbuf, int id, int pos_pl) * MUSICBRAINZ_ARTISTID: c5c2ea1c-4bde-4f4d-bd0b-47b200bf99d6 * MUSICBRAINZ_ALBUMID: 812f4b87-8ad9-41bd-be79-38151f17a2b4 * MUSICBRAINZ_TRACKID: fde95c39-ee51-48f6-a7f9-b5631c2ed156 - * Id: 1 * * @param evbuf the response event buffer * @param mfi media information @@ -495,8 +496,7 @@ mpd_add_db_media_file_info(struct evbuffer *evbuf, struct db_media_file_info *db "Track: %s\n" "Date: %s\n" "Genre: %s\n" - "Disc: %s\n" - "Id: %s\n", + "Disc: %s\n", (dbmfi->virtual_path + 1), modified, (songlength / 1000), @@ -509,8 +509,7 @@ mpd_add_db_media_file_info(struct evbuffer *evbuf, struct db_media_file_info *db dbmfi->track, dbmfi->year, dbmfi->genre, - dbmfi->disc, - dbmfi->id); + dbmfi->disc); return ret; } From 68c392eb9eb5f7610eae542d07453f57c93133fb Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 9 May 2015 06:36:29 +0200 Subject: [PATCH 16/17] [mpd] ignore requests for client to client commands "subscribe", "unsubscribe", "readmessages", "sendmessages" --- src/mpd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index b49832ad..c04e9d90 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -3492,30 +3492,26 @@ static struct command mpd_handlers[] = /* * Client to client */ - /* { .mpdcommand = "subscribe", - .handler = mpd_command_subscribe + .handler = mpd_command_ignore }, { .mpdcommand = "unsubscribe", - .handler = mpd_command_unsubscribe + .handler = mpd_command_ignore }, - */ { .mpdcommand = "channels", .handler = mpd_command_ignore }, - /* { .mpdcommand = "readmessages", - .handler = mpd_command_readmessages + .handler = mpd_command_ignore }, { .mpdcommand = "sendmessage", - .handler = mpd_command_sendmessage + .handler = mpd_command_ignore }, - */ /* * NULL command to terminate loop From 864315eaef1cf4470d63f159dbb5620b90b92da9 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 9 May 2015 06:40:30 +0200 Subject: [PATCH 17/17] [mpd] fix wrong log message --- src/mpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mpd.c b/src/mpd.c index c04e9d90..4c25a2d1 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -3892,7 +3892,7 @@ int mpd_init(void) } evconnlistener_set_error_cb(listener, mpd_accept_error_cb); - DPRINTF(E_INFO, L_MPD, "cache thread init\n"); + DPRINTF(E_INFO, L_MPD, "mpd thread init\n"); ret = pthread_create(&tid_mpd, NULL, mpd, NULL); if (ret < 0)