From 28a60db5aa4c368e221595444b76c66ba1fe6960 Mon Sep 17 00:00:00 2001 From: Hagen Fritsch Date: Wed, 27 Feb 2013 19:42:32 +0100 Subject: clock: add missing include --- src/clock.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 4100fa2d8..dcdf685ab 100644 --- a/src/clock.c +++ b/src/clock.c @@ -25,6 +25,9 @@ #include #else #include +#ifndef CLOCK_MONOTONIC +#include +#endif #endif unsigned -- cgit v1.2.3 From 2cf31e905b445fe4dbcea5fc194b69dcb46c3210 Mon Sep 17 00:00:00 2001 From: Hagen Fritsch Date: Wed, 27 Feb 2013 19:41:30 +0100 Subject: clock: fix usec-to-usec factor --- src/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index dcdf685ab..d987aed48 100644 --- a/src/clock.c +++ b/src/clock.c @@ -92,7 +92,7 @@ monotonic_clock_us(void) /* we have no monotonic clock, fall back to gettimeofday() */ struct timeval tv; gettimeofday(&tv, 0); - return (uint64_t)tv.tv_sec * 1000 + (uint64_t)(tv.tv_usec) / 1000(; + return (uint64_t)tv.tv_sec * 1000 + (uint64_t)tv.tv_usec; #endif } -- cgit v1.2.3 From 6f4bb6cd2c43b1be330d24867158e4334f69ab3f Mon Sep 17 00:00:00 2001 From: Hagen Fritsch Date: Sun, 24 Feb 2013 18:19:55 +0100 Subject: Add some comments to keep track of timer units. --- src/timer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3