summaryrefslogtreecommitdiff
path: root/channel.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-06-29 20:32:26 +0000
committerMark Spencer <markster@digium.com>2003-06-29 20:32:26 +0000
commit40e4cfe458087e09eae984eb4da9c1d0d1cc0463 (patch)
tree860e56e0ecfd14cc8e477185e8c7f1d9ba86efd2 /channel.c
parent97fc11c24420ec233600d1c1d74ec7096f2539f4 (diff)
Properly implement using zaptel for timing of file playback
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1137 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/channel.c b/channel.c
index 2127a46bd..f66d6174f 100755
--- a/channel.c
+++ b/channel.c
@@ -938,13 +938,19 @@ char ast_waitfordigit(struct ast_channel *c, int ms)
return result;
}
-int ast_settimeout(struct ast_channel *c, int ms)
+int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data), void *data)
{
int res = -1;
#ifdef ZAPTEL_OPTIMIZATIONS
if (c->timingfd > -1) {
- ms *= 8;
- res = ioctl(c->timingfd, ZT_TIMERCONFIG, &ms);
+ if (!func) {
+ samples = 0;
+ data = 0;
+ }
+ ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples);
+ res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples);
+ c->timingfunc = func;
+ c->timingdata = data;
}
#endif
return res;
@@ -983,6 +989,10 @@ struct ast_frame *ast_read(struct ast_channel *chan)
{
struct ast_frame *f = NULL;
int blah;
+#ifdef ZAPTEL_OPTIMIZATIONS
+ int (*func)(void *);
+ void *data;
+#endif
static struct ast_frame null_frame =
{
AST_FRAME_NULL,
@@ -1027,10 +1037,18 @@ struct ast_frame *ast_read(struct ast_channel *chan)
chan->exception = 0;
blah = -1;
ioctl(chan->timingfd, ZT_TIMERACK, &blah);
- blah = 0;
- ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah);
- f = &null_frame;
+ func = chan->timingfunc;
+ data = chan->timingdata;
pthread_mutex_unlock(&chan->lock);
+ if (func) {
+ func(data);
+ } else {
+ blah = 0;
+ pthread_mutex_lock(&chan->lock);
+ ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah);
+ pthread_mutex_unlock(&chan->lock);
+ }
+ f = &null_frame;
return f;
}
#endif