aboutsummaryrefslogtreecommitdiffstats
path: root/src/Stats.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Stats.cxx27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/Stats.cxx b/src/Stats.cxx
index f224bdf49..e22f1a995 100644
--- a/src/Stats.cxx
+++ b/src/Stats.cxx
@@ -26,21 +26,24 @@
#include "DatabasePlugin.hxx"
#include "DatabaseSimple.hxx"
#include "util/Error.hxx"
+#include "system/Clock.hxx"
#include "Log.hxx"
-#include <glib.h>
+#ifndef WIN32
+/**
+ * The monotonic time stamp when MPD was started. It is used to
+ * calculate the uptime.
+ */
+static unsigned start_time;
+#endif
-static GTimer *uptime;
static DatabaseStats stats;
void stats_global_init(void)
{
- uptime = g_timer_new();
-}
-
-void stats_global_finish(void)
-{
- g_timer_destroy(uptime);
+#ifndef WIN32
+ start_time = MonotonicClockS();
+#endif
}
void stats_update(void)
@@ -94,9 +97,13 @@ void
stats_print(Client &client)
{
client_printf(client,
- "uptime: %lu\n"
+ "uptime: %u\n"
"playtime: %lu\n",
- (unsigned long)g_timer_elapsed(uptime, NULL),
+#ifdef WIN32
+ GetProcessUptimeS(),
+#else
+ MonotonicClockS() - start_time,
+#endif
(unsigned long)(client.player_control.GetTotalPlayTime() + 0.5));
if (GetDatabase() != nullptr)