output/Timer: no "time" initialization if !started

This commit is contained in:
Max Kellermann 2016-12-28 10:16:11 +01:00
parent e786207cc2
commit bd8d8eef3e

View File

@ -27,8 +27,7 @@
#include <assert.h> #include <assert.h>
Timer::Timer(const AudioFormat af) Timer::Timer(const AudioFormat af)
: time(0), :started(false),
started(false),
rate(af.sample_rate * af.GetFrameSize()) rate(af.sample_rate * af.GetFrameSize())
{ {
} }
@ -41,7 +40,6 @@ void Timer::Start()
void Timer::Reset() void Timer::Reset()
{ {
time = 0;
started = false; started = false;
} }
@ -56,6 +54,8 @@ void Timer::Add(int size)
unsigned Timer::GetDelay() const unsigned Timer::GetDelay() const
{ {
assert(started);
int64_t delay = (int64_t)(time - MonotonicClockUS()) / 1000; int64_t delay = (int64_t)(time - MonotonicClockUS()) / 1000;
if (delay < 0) if (delay < 0)
return 0; return 0;