diff options
-rw-r--r-- | src/timer.c | 8 | ||||
-rw-r--r-- | src/timer.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/timer.c b/src/timer.c index 0406a945e..f808fb02f 100644 --- a/src/timer.c +++ b/src/timer.c @@ -51,7 +51,7 @@ void timer_free(Timer *timer) void timer_start(Timer *timer) { - timer->time = now(); + timer->start_time = timer->time = now(); timer->started = 1; } @@ -59,6 +59,7 @@ void timer_reset(Timer *timer) { timer->time = 0; timer->started = 0; + timer->start_time = 0; } void timer_add(Timer *timer, int size) @@ -78,3 +79,8 @@ void timer_sync(Timer *timer) if (sleep > 0) my_usleep(sleep); } + +int timer_get_runtime_ms(Timer *timer) +{ + return (now() - timer->start_time)/1000; +} diff --git a/src/timer.h b/src/timer.h index c8018e260..61eaeb56f 100644 --- a/src/timer.h +++ b/src/timer.h @@ -23,6 +23,7 @@ #include "mpd_types.h" typedef struct _Timer { + uint64_t start_time; uint64_t time; int started; int rate; @@ -40,4 +41,6 @@ void timer_add(Timer *timer, int size); void timer_sync(Timer *timer); +int timer_get_runtime_ms(Timer *timer); + #endif |