From a0a6b7d473892ef484328ff544233dd7d6dc6bf9 Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 19 Nov 2017 08:05:26 +0100 Subject: [PATCH] [mpd] Send correct value for uptime in 'stats' command --- src/mpd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index f4fed6bc..245350f4 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -813,6 +813,9 @@ mpd_command_stats(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, struct filecount_info fci; int artists; int albums; + time_t start_time; + double uptime; + time_t db_update; int ret; memset(&qp, 0, sizeof(struct query_params)); @@ -828,21 +831,25 @@ mpd_command_stats(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, artists = db_files_get_artist_count(); albums = db_files_get_album_count(); - //TODO [mpd] Implement missing stats attributes (uptime, playtime) + start_time = (time_t) db_admin_getint64(ADMIN_START_TIME); + uptime = difftime(time(NULL), start_time); + db_update = (time_t) db_admin_getint64(ADMIN_DB_UPDATE); + + //TODO [mpd] Implement missing stats attributes (playtime) evbuffer_add_printf(evbuf, "artists: %d\n" "albums: %d\n" "songs: %d\n" - "uptime: %d\n" //in seceonds + "uptime: %.f\n" //in seceonds "db_playtime: %" PRIi64 "\n" "db_update: %" PRIi64 "\n" "playtime: %d\n", artists, albums, fci.count, - 4, + uptime, (fci.length / 1000), - (time_t) db_admin_getint64(ADMIN_DB_UPDATE), + db_update, 7); return 0;