diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-11 21:24:37 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-11 21:24:37 +0000 |
commit | 0fac84cc8e70e493d86d06b92b848d4c9d754216 (patch) | |
tree | 648341598d816e8598679f59891854eb0e97a78f /res/res_timing_pthread.c | |
parent | 60d445110dfa5ca7c0fbae68454e5f65e1f07239 (diff) |
Merged revisions 163241 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r163241 | russell | 2008-12-11 15:21:31 -0600 (Thu, 11 Dec 2008) | 8 lines
Fix a problem where continuous mode will get inadvertently get turned off if set_rate()
is used while continuous mode was already turned on.
(closes issue #13738)
Reported by: smurfix
Patches:
res.patch.fixed uploaded by smurfix (license 547)
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@163252 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_timing_pthread.c')
-rw-r--r-- | res/res_timing_pthread.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/res/res_timing_pthread.c b/res/res_timing_pthread.c index 6e57246a6..c8e50e7f1 100644 --- a/res/res_timing_pthread.c +++ b/res/res_timing_pthread.c @@ -146,6 +146,23 @@ static void pthread_timer_close(int handle) ao2_ref(timer, -1); } +static void set_state(struct pthread_timer *timer) +{ + unsigned int rate = timer->rate; + + if (rate) { + timer->state = TIMER_STATE_TICKING; + timer->interval = roundf(1000.0 / ((float) rate)); + timer->start = ast_tvnow(); + } else { + timer->state = TIMER_STATE_IDLE; + timer->interval = 0; + timer->start = ast_tv(0, 0); + } + + timer->tick_count = 0; +} + static int pthread_timer_set_rate(int handle, unsigned int rate) { struct pthread_timer *timer; @@ -164,10 +181,10 @@ static int pthread_timer_set_rate(int handle, unsigned int rate) ao2_lock(timer); timer->rate = rate; - timer->state = rate ? TIMER_STATE_TICKING : TIMER_STATE_IDLE; - timer->interval = rate ? roundf(1000.0 / ((float) rate)) : 0; - timer->start = rate ? ast_tvnow() : ast_tv(0, 0); - timer->tick_count = 0; + if (timer->state != TIMER_STATE_CONTINUOUS) { + set_state(timer); + } + ao2_unlock(timer); ao2_ref(timer, -1); @@ -224,7 +241,7 @@ static int pthread_timer_disable_continuous(int handle) } ao2_lock(timer); - timer->state = timer->rate ? TIMER_STATE_TICKING : TIMER_STATE_IDLE; + set_state(timer); read_pipe(timer->pipe[PIPE_READ], 0, 1); ao2_unlock(timer); |