diff options
author | Russell Bryant <russell@russellbryant.com> | 2008-06-26 15:37:01 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2008-06-26 15:37:01 +0000 |
commit | 02b1317d0f8b6ab4b68993554ba5e7802b8a50a6 (patch) | |
tree | 118582e660d2690096ebef4c51e0bd240a6507e0 /main | |
parent | b71f8ac66a9f3559bbd7372229713860c950f4eb (diff) |
- add get_max_rate timing API call
- change ast_settimeout() to honor max rate in edge cases of file playback
(this will make some warning messages go away at the end of playing back
a file)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125332 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/channel.c | 9 | ||||
-rw-r--r-- | main/timing.c | 14 |
2 files changed, 21 insertions, 2 deletions
diff --git a/main/channel.c b/main/channel.c index 361d1fb78..a83c3c94d 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2174,6 +2174,7 @@ int ast_waitfordigit(struct ast_channel *c, int ms) int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data) { int res; + unsigned int real_rate = rate, max_rate; if (c->timingfd == -1) { return -1; @@ -2184,9 +2185,13 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v data = NULL; } - ast_debug(1, "Scheduling timer at %u timer ticks per second\n", rate); + if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timingfd))) { + real_rate = max_rate; + } + + ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate); - res = ast_timer_set_rate(c->timingfd, rate); + res = ast_timer_set_rate(c->timingfd, real_rate); c->timingfunc = func; c->timingdata = data; diff --git a/main/timing.c b/main/timing.c index 5f6023203..982186706 100644 --- a/main/timing.c +++ b/main/timing.c @@ -46,6 +46,7 @@ void *ast_install_timing_functions(struct ast_timing_functions *funcs) !funcs->timer_set_rate || !funcs->timer_ack || !funcs->timer_get_event || + !funcs->timer_get_max_rate || !funcs->timer_enable_continuous || !funcs->timer_disable_continuous) { return NULL; @@ -198,6 +199,19 @@ enum ast_timing_event ast_timer_get_event(int handle) return result; } +unsigned int ast_timer_get_max_rate(int handle) +{ + unsigned int res; + + ast_rwlock_rdlock(&lock); + + res = timer_funcs.timer_get_max_rate(handle); + + ast_rwlock_unlock(&lock); + + return res; +} + static char *timing_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { int fd, count = 0; |