output/Timer: add `noexcept`
This commit is contained in:
parent
7dd65f3028
commit
4b3dcf831b
|
@ -22,24 +22,26 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -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<Time>(std::chrono::steady_clock::now().time_since_epoch());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue