aboutsummaryrefslogtreecommitdiffstats
path: root/src/timer.c
diff options
context:
space:
mode:
authorHagen Fritsch <fritsch+git@in.tum.de>2013-02-24 18:19:55 +0100
committerMax Kellermann <max@duempel.org>2013-02-27 19:47:28 +0100
commit6f4bb6cd2c43b1be330d24867158e4334f69ab3f (patch)
treefb80c875052b1e926bbed18146c7c79b7fed5347 /src/timer.c
parent2cf31e905b445fe4dbcea5fc194b69dcb46c3210 (diff)
downloadmpd-6f4bb6cd2c43b1be330d24867158e4334f69ab3f.tar.gz
mpd-6f4bb6cd2c43b1be330d24867158e4334f69ab3f.tar.xz
mpd-6f4bb6cd2c43b1be330d24867158e4334f69ab3f.zip
Add some comments to keep track of timer units.
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/timer.c b/src/timer.c
index 2d9550706..9a3228465 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -31,9 +31,9 @@
struct timer *timer_new(const struct audio_format *af)
{
struct timer *timer = g_new(struct timer, 1);
- timer->time = 0;
- timer->started = 0;
- timer->rate = af->sample_rate * audio_format_frame_size(af);
+ timer->time = 0; // us
+ timer->started = 0; // false
+ timer->rate = af->sample_rate * audio_format_frame_size(af); // samples per second
return timer;
}
@@ -59,6 +59,8 @@ void timer_add(struct timer *timer, int size)
{
assert(timer->started);
+ // (size samples) / (rate samples per second) = duration seconds
+ // duration seconds * 1000000 = duration us
timer->time += ((uint64_t)size * 1000000) / timer->rate;
}