aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-05-12 04:23:55 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-05-12 04:23:55 +0000
commit57f1c73396a098a4ae9b93db577f7f13d4bf3a74 (patch)
treeea489daf4f7d64dce260b9e4c59e413de180437a /channel.c
parent11dc83355e514517f8a7e5bb6b5a9de05a41dca0 (diff)
Use zaptel timers to wake up processes
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1002 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/channel.c b/channel.c
index 3640dd11c..0a9363a8f 100755
--- a/channel.c
+++ b/channel.c
@@ -34,6 +34,10 @@
#include <asterisk/linkedlists.h>
#include <asterisk/indications.h>
#include <asterisk/monitor.h>
+#ifdef ZAPTEL_OPTIMIZATIONS
+#include <sys/ioctl.h>
+#include <linux/zaptel.h>
+#endif
static int shutting_down = 0;
@@ -296,8 +300,15 @@ struct ast_channel *ast_channel_alloc(int needqueue)
fcntl(pvt->alertpipe[1], F_SETFL, flags | O_NONBLOCK);
} else
pvt->alertpipe[0] = pvt->alertpipe[1] = -1;
+#ifdef ZAPTEL_OPTIMIZATIONS
+ tmp->timingfd = open("/dev/zap/timer", O_RDWR);
+#else
+ tmp->timingfd = -1;
+#endif
/* Always watch the alertpipe */
tmp->fds[AST_MAX_FDS-1] = pvt->alertpipe[0];
+ /* And timing pipe */
+ tmp->fds[AST_MAX_FDS-2] = tmp->timingfd;
strncpy(tmp->name, "**Unknown**", sizeof(tmp->name)-1);
tmp->pvt = pvt;
/* Initial state */
@@ -921,6 +932,17 @@ char ast_waitfordigit(struct ast_channel *c, int ms)
return result;
}
+int ast_settimeout(struct ast_channel *c, int ms)
+{
+ int res = -1;
+#ifdef ZAPTEL_OPTIMIZATIONS
+ if (c->timingfd > -1) {
+ ms *= 8;
+ res = ioctl(c->timingfd, ZT_TIMERCONFIG, &ms);
+ }
+#endif
+ return res;
+}
char ast_waitfordigit_full(struct ast_channel *c, int ms, int audio, int ctrl)
{
struct ast_frame *f;
@@ -994,7 +1016,18 @@ struct ast_frame *ast_read(struct ast_channel *chan)
if (chan->pvt->alertpipe[0] > -1) {
read(chan->pvt->alertpipe[0], &blah, sizeof(blah));
}
-
+#ifdef ZAPTEL_OPTIMIZATIONS
+ if ((chan->timingfd > -1) && (chan->fdno == AST_MAX_FDS - 2) && chan->exception) {
+ chan->exception = 0;
+ blah = -1;
+ ioctl(chan->timingfd, ZT_TIMERACK, &blah);
+ blah = 0;
+ ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah);
+ f = &null_frame;
+ pthread_mutex_unlock(&chan->lock);
+ return f;
+ }
+#endif
/* Check for pending read queue */
if (chan->pvt->readq) {
f = chan->pvt->readq;