[svn-commits] russell: branch 1.6.1 r163252 - in /branches/1.6.1: ./ res/res_timing_pthread.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 11 15:24:37 CST 2008


Author: russell
Date: Thu Dec 11 15:24:37 2008
New Revision: 163252

URL: http://svn.digium.com/view/asterisk?view=rev&rev=163252
Log:
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)

........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/res/res_timing_pthread.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/res/res_timing_pthread.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/res/res_timing_pthread.c?view=diff&rev=163252&r1=163251&r2=163252
==============================================================================
--- branches/1.6.1/res/res_timing_pthread.c (original)
+++ branches/1.6.1/res/res_timing_pthread.c Thu Dec 11 15:24:37 2008
@@ -146,6 +146,23 @@
 	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 @@
 
 	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 @@
 	}
 
 	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);
 




More information about the svn-commits mailing list