diff options
Diffstat (limited to 'main/utils.c')
-rw-r--r-- | main/utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/main/utils.c b/main/utils.c index 0ff33cba2..3476729ce 100644 --- a/main/utils.c +++ b/main/utils.c @@ -1470,6 +1470,23 @@ struct timeval ast_tvsub(struct timeval a, struct timeval b) } return a; } + +int ast_remaining_ms(struct timeval start, int max_ms) +{ + int ms; + + if (max_ms < 0) { + ms = max_ms; + } else { + ms = max_ms - ast_tvdiff_ms(ast_tvnow(), start); + if (ms < 0) { + ms = 0; + } + } + + return ms; +} + #undef ONE_MILLION /*! \brief glibc puts a lock inside random(3), so that the results are thread-safe. |