From 4b3dcf831b8002193f461404b8c4efee75208f6b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 8 Jul 2022 22:57:27 +0200 Subject: [PATCH] output/Timer: add `noexcept` --- src/output/Timer.cxx | 12 +++++++----- src/output/Timer.hxx | 16 +++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/output/Timer.cxx b/src/output/Timer.cxx index 4d31074ef..c2c25e235 100644 --- a/src/output/Timer.cxx +++ b/src/output/Timer.cxx @@ -22,24 +22,26 @@ #include -Timer::Timer(const AudioFormat af) +Timer::Timer(const AudioFormat af) noexcept :rate(af.sample_rate * af.GetFrameSize()) { } -void Timer::Start() +void +Timer::Start() noexcept { time = Now(); started = true; } -void Timer::Reset() +void +Timer::Reset() noexcept { started = false; } void -Timer::Add(size_t size) +Timer::Add(size_t size) noexcept { assert(started); @@ -49,7 +51,7 @@ Timer::Add(size_t size) } std::chrono::steady_clock::duration -Timer::GetDelay() const +Timer::GetDelay() const noexcept { assert(started); diff --git a/src/output/Timer.hxx b/src/output/Timer.hxx index 735edd04b..0ceef1354 100644 --- a/src/output/Timer.hxx +++ b/src/output/Timer.hxx @@ -31,22 +31,24 @@ class Timer { bool started = false; const int rate; public: - explicit Timer(AudioFormat af); + explicit Timer(AudioFormat af) noexcept; - bool IsStarted() const { return started; } + bool IsStarted() const noexcept { return started; } - void Start(); - void Reset(); + void Start() noexcept; + void Reset() noexcept; - void Add(size_t size); + void Add(size_t size) noexcept; /** * Returns the duration to sleep to get back to sync. */ - std::chrono::steady_clock::duration GetDelay() const; + [[gnu::pure]] + std::chrono::steady_clock::duration GetDelay() const noexcept; private: - static Time Now() { + [[gnu::pure]] + static Time Now() noexcept { return std::chrono::duration_cast