[asterisk-commits] russell: trunk r125332 - in /trunk: include/asterisk/ main/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 26 10:37:02 CDT 2008
Author: russell
Date: Thu Jun 26 10:37:01 2008
New Revision: 125332
URL: http://svn.digium.com/view/asterisk?view=rev&rev=125332
Log:
- 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)
Modified:
trunk/include/asterisk/timing.h
trunk/main/channel.c
trunk/main/timing.c
trunk/res/res_timing_dahdi.c
trunk/res/res_timing_pthread.c
Modified: trunk/include/asterisk/timing.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/timing.h?view=diff&rev=125332&r1=125331&r2=125332
==============================================================================
--- trunk/include/asterisk/timing.h (original)
+++ trunk/include/asterisk/timing.h Thu Jun 26 10:37:01 2008
@@ -72,6 +72,7 @@
int (*timer_enable_continuous)(int handle);
int (*timer_disable_continuous)(int handle);
enum ast_timing_event (*timer_get_event)(int handle);
+ unsigned int (*timer_get_max_rate)(int handle);
};
/*!
@@ -175,6 +176,15 @@
*/
enum ast_timing_event ast_timer_get_event(int handle);
+/*!
+ * \brief Get maximum rate supported for a timing handle
+ *
+ * \arg handle timing fd returned by timer_open()
+ *
+ * \return maximum rate supported for timing handle
+ */
+unsigned int ast_timer_get_max_rate(int handle);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=125332&r1=125331&r2=125332
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Thu Jun 26 10:37:01 2008
@@ -2174,6 +2174,7 @@
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 @@
data = NULL;
}
- ast_debug(1, "Scheduling timer at %u timer ticks per second\n", rate);
-
- res = ast_timer_set_rate(c->timingfd, 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, real_rate);
c->timingfunc = func;
c->timingdata = data;
Modified: trunk/main/timing.c
URL: http://svn.digium.com/view/asterisk/trunk/main/timing.c?view=diff&rev=125332&r1=125331&r2=125332
==============================================================================
--- trunk/main/timing.c (original)
+++ trunk/main/timing.c Thu Jun 26 10:37:01 2008
@@ -46,6 +46,7 @@
!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;
@@ -196,6 +197,19 @@
ast_rwlock_unlock(&lock);
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)
Modified: trunk/res/res_timing_dahdi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_timing_dahdi.c?view=diff&rev=125332&r1=125331&r2=125332
==============================================================================
--- trunk/res/res_timing_dahdi.c (original)
+++ trunk/res/res_timing_dahdi.c Thu Jun 26 10:37:01 2008
@@ -51,6 +51,7 @@
static int dahdi_timer_enable_continuous(int handle);
static int dahdi_timer_disable_continuous(int handle);
static enum ast_timing_event dahdi_timer_get_event(int handle);
+static unsigned int dahdi_timer_get_max_rate(int handle);
static struct ast_timing_functions dahdi_timing_functions = {
.timer_open = dahdi_timer_open,
@@ -60,6 +61,7 @@
.timer_enable_continuous = dahdi_timer_enable_continuous,
.timer_disable_continuous = dahdi_timer_disable_continuous,
.timer_get_event = dahdi_timer_get_event,
+ .timer_get_max_rate = dahdi_timer_get_max_rate,
};
static int dahdi_timer_open(void)
@@ -128,6 +130,11 @@
}
}
+static unsigned int dahdi_timer_get_max_rate(int handle)
+{
+ return 1000;
+}
+
static int dahdi_test_timer(void)
{
int fd;
Modified: trunk/res/res_timing_pthread.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_timing_pthread.c?view=diff&rev=125332&r1=125331&r2=125332
==============================================================================
--- trunk/res/res_timing_pthread.c (original)
+++ trunk/res/res_timing_pthread.c Thu Jun 26 10:37:01 2008
@@ -46,6 +46,7 @@
static int pthread_timer_enable_continuous(int handle);
static int pthread_timer_disable_continuous(int handle);
static enum ast_timing_event pthread_timer_get_event(int handle);
+static unsigned int pthread_timer_get_max_rate(int handle);
static struct ast_timing_functions pthread_timing_functions = {
.timer_open = pthread_timer_open,
@@ -55,6 +56,7 @@
.timer_enable_continuous = pthread_timer_enable_continuous,
.timer_disable_continuous = pthread_timer_disable_continuous,
.timer_get_event = pthread_timer_get_event,
+ .timer_get_max_rate = pthread_timer_get_max_rate,
};
/* 1 tick / 10 ms */
@@ -249,6 +251,11 @@
return res;
}
+static unsigned int pthread_timer_get_max_rate(int handle)
+{
+ return MAX_RATE;
+}
+
static struct pthread_timer *find_timer(int handle, int unlink)
{
struct pthread_timer *timer;
More information about the asterisk-commits
mailing list