Commit 6f4bb6cd authored by Hagen Fritsch's avatar Hagen Fritsch Committed by Max Kellermann

Add some comments to keep track of timer units.

parent 2cf31e90
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
struct timer *timer_new(const struct audio_format *af) struct timer *timer_new(const struct audio_format *af)
{ {
struct timer *timer = g_new(struct timer, 1); struct timer *timer = g_new(struct timer, 1);
timer->time = 0; timer->time = 0; // us
timer->started = 0; timer->started = 0; // false
timer->rate = af->sample_rate * audio_format_frame_size(af); timer->rate = af->sample_rate * audio_format_frame_size(af); // samples per second
return timer; return timer;
} }
...@@ -59,6 +59,8 @@ void timer_add(struct timer *timer, int size) ...@@ -59,6 +59,8 @@ void timer_add(struct timer *timer, int size)
{ {
assert(timer->started); assert(timer->started);
// (size samples) / (rate samples per second) = duration seconds
// duration seconds * 1000000 = duration us
timer->time += ((uint64_t)size * 1000000) / timer->rate; timer->time += ((uint64_t)size * 1000000) / timer->rate;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment