summaryrefslogtreecommitdiff
path: root/src/zeroconf
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-08 16:11:14 +0200
committerMax Kellermann <max@musicpd.org>2019-05-08 16:11:14 +0200
commitaf3ea97a429a0d910329dfda5b1b1a4107e5bb90 (patch)
tree9ddc06be648cdb24be4562ae10aba486f7f90993 /src/zeroconf
parent8beac03dc43199eb2120c3435db0c8e8ae993db3 (diff)
zeroconf/AvahiPoll: move TimevalToChrono() to time/Convert.cxx
Diffstat (limited to 'src/zeroconf')
-rw-r--r--src/zeroconf/AvahiPoll.cxx11
-rw-r--r--src/zeroconf/meson.build1
2 files changed, 4 insertions, 8 deletions
diff --git a/src/zeroconf/AvahiPoll.cxx b/src/zeroconf/AvahiPoll.cxx
index eeb669b23..cc62e67e4 100644
--- a/src/zeroconf/AvahiPoll.cxx
+++ b/src/zeroconf/AvahiPoll.cxx
@@ -20,6 +20,7 @@
#include "AvahiPoll.hxx"
#include "event/SocketMonitor.hxx"
#include "event/TimerEvent.hxx"
+#include "time/Convert.hxx"
static unsigned
FromAvahiWatchEvent(AvahiWatchEvent e)
@@ -78,12 +79,6 @@ private:
}
};
-static constexpr std::chrono::steady_clock::duration
-TimevalToChrono(const timeval &tv)
-{
- return std::chrono::seconds(tv.tv_sec) + std::chrono::microseconds(tv.tv_usec);
-}
-
struct AvahiTimeout final {
TimerEvent timer;
@@ -97,12 +92,12 @@ public:
:timer(_loop, BIND_THIS_METHOD(OnTimeout)),
callback(_callback), userdata(_userdata) {
if (tv != nullptr)
- timer.Schedule(TimevalToChrono(*tv));
+ timer.Schedule(ToSteadyClockDuration(*tv));
}
static void TimeoutUpdate(AvahiTimeout *t, const struct timeval *tv) {
if (tv != nullptr)
- t->timer.Schedule(TimevalToChrono(*tv));
+ t->timer.Schedule(ToSteadyClockDuration(*tv));
else
t->timer.Cancel();
}
diff --git a/src/zeroconf/meson.build b/src/zeroconf/meson.build
index 2858079cb..c2853b344 100644
--- a/src/zeroconf/meson.build
+++ b/src/zeroconf/meson.build
@@ -67,6 +67,7 @@ else
dependencies: [
libavahi_client_dep,
dbus_dep,
+ time_dep,
],
)