CFLAGS+=-pthread
endif
+CFLAGS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
+
LIBEDIT=editline/libedit.a
ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; fi)
for (x=0;x<fmtcnt;x++) {
if (!others[x])
break;
+ ast_stream_rewind(others[x], 1000);
+ ast_truncstream(others[x]);
ast_closestream(others[x]);
}
if (outmsg) {
FILE *txt;
int res = 0;
int msgnum;
- int maxmessage=0;
char date[256];
char dir[256];
char fn[256];
fclose(txt);
} else
ast_log(LOG_WARNING, "Error opening text file for output\n");
- res = play_and_record(chan, NULL, fn, maxmessage, fmt);
+ res = play_and_record(chan, NULL, fn, vmmaxmessage, fmt);
if (res > 0)
res = 0;
txt = fopen(txtfile, "a");
#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;
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 */
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;
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;
struct iax2_peer *peer;
int processed = 0;
int totalcalls = 0;
- int x = -1;
+ int x = 1;
if (iaxtrunkdebug)
ast_verbose("Beginning trunk processing\n");
if (events & AST_IO_PRI) {
#ifdef ZT_TIMERACK
/* Great, this is a timing interface, just call the ioctl */
- if (ioctl(fd, ZT_TIMERACK, x))
+ if (ioctl(fd, ZT_TIMERACK, &x))
ast_log(LOG_WARNING, "Unable to acknowledge zap timer\n");
res = 0;
#endif
ast_closestream(c->stream);
break;
}
+ /* Setup timeout if supported */
+ ast_settimeout(c, res);
res = ast_waitfor(c, res);
if (res < 0) {
ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno));
return res;
- } else
- if (res > 0) {
+ } else if (res > 0) {
fr = ast_read(c);
if (!fr) {
#if 0
}
/* Ignore */
ast_frfree(fr);
- } else
- ast_sched_runq(c->sched);
+ }
+ ast_sched_runq(c->sched);
}
ast_closestream(c->stream);
break;
}
+ ast_settimeout(c, res);
res = ast_waitfor(c, res);
if (res < 0) {
ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno));
ast_closestream(c->stream);
break;
}
+ ast_settimeout(c, ms);
rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
if (!rchan && (outfd < 0) && (ms)) {
ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
}
/* Ignore */
ast_frfree(fr);
- } else
- ast_sched_runq(c->sched);
+ }
+ ast_sched_runq(c->sched);
}
struct ast_filestream *stream;
/*! Original writer format */
int oldwriteformat;
+
+ /*! Timing fd */
+ int timingfd;
/*! State of line -- Don't write directly, use ast_setstate */
/*! Stop servicing a channel for us... Returns -1 on error or if channel has been hungup */
int ast_autoservice_stop(struct ast_channel *chan);
+/* If built with zaptel optimizations, force a scheduled expiration on the
+ timer fd */
+int ast_settimeout(struct ast_channel *c, int ms);
+
/* Misc. functions below */
//! Waits for activity on a group of channels