aboutsummaryrefslogtreecommitdiffstats
path: root/src/stats.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-10 19:24:30 +0200
committerMax Kellermann <max@duempel.org>2011-09-13 19:37:28 +0200
commit169db88c20dc7601f8589cfa298254c932f0947a (patch)
treeb0cc3af153237379a1dbbb2fa90eb37eed05752f /src/stats.c
parentca419c84b83d017c3e4309e22f92273500197eea (diff)
downloadmpd-169db88c20dc7601f8589cfa298254c932f0947a.tar.gz
mpd-169db88c20dc7601f8589cfa298254c932f0947a.tar.xz
mpd-169db88c20dc7601f8589cfa298254c932f0947a.zip
database: add struct db_visitor
Use this struct for db_walk().
Diffstat (limited to 'src/stats.c')
-rw-r--r--src/stats.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/stats.c b/src/stats.c
index 8f9ef0dbf..fe0c2a476 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "stats.h"
#include "database.h"
+#include "db_visitor.h"
#include "tag.h"
#include "song.h"
#include "client.h"
@@ -68,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;
@@ -78,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;
@@ -92,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(NULL, &collect_stats_visitor, &data, NULL);
stats.artist_count = strset_size(data.artists);
stats.album_count = strset_size(data.albums);