aboutsummaryrefslogtreecommitdiffstats
path: root/src/stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stats.c')
-rw-r--r--src/stats.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/stats.c b/src/stats.c
index 718d8633a..fe6a064a6 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,11 +20,13 @@
#include "config.h"
#include "stats.h"
#include "database.h"
+#include "db_visitor.h"
#include "tag.h"
#include "song.h"
#include "client.h"
#include "player_control.h"
#include "strset.h"
+#include "client_internal.h"
struct stats stats;
@@ -67,8 +69,9 @@ visit_tag(struct visit_data *data, const struct tag *tag)
}
}
-static int
-stats_collect_song(struct song *song, void *_data)
+static bool
+collect_stats_song(struct song *song, void *_data,
+ G_GNUC_UNUSED GError **error_r)
{
struct visit_data *data = _data;
@@ -77,9 +80,13 @@ stats_collect_song(struct song *song, void *_data)
if (song->tag != NULL)
visit_tag(data, song->tag);
- return 0;
+ return true;
}
+static const struct db_visitor collect_stats_visitor = {
+ .song = collect_stats_song,
+};
+
void stats_update(void)
{
struct visit_data data;
@@ -91,7 +98,7 @@ void stats_update(void)
data.artists = strset_new();
data.albums = strset_new();
- db_walk(NULL, stats_collect_song, NULL, &data);
+ db_walk("", &collect_stats_visitor, &data, NULL);
stats.artist_count = strset_size(data.artists);
stats.album_count = strset_size(data.albums);
@@ -114,7 +121,7 @@ int stats_print(struct client *client)
stats.album_count,
stats.song_count,
(long)g_timer_elapsed(stats.timer, NULL),
- (long)(pc_get_total_play_time() + 0.5),
+ (long)(pc_get_total_play_time(client->player_control) + 0.5),
stats.song_duration,
(long)db_get_mtime());
return 0;