[Asterisk-cvs] asterisk/channels chan_zap.c,1.477,1.478
mattf at lists.digium.com
mattf at lists.digium.com
Tue Jul 19 09:23:13 CDT 2005
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv16554/channels
Modified Files:
chan_zap.c
Log Message:
Fix for DSP code on 411/406. (Bug 4712). Also a settable tone length
option.
Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.477
retrieving revision 1.478
diff -u -d -r1.477 -r1.478
--- chan_zap.c 15 Jul 2005 23:00:46 -0000 1.477
+++ chan_zap.c 19 Jul 2005 13:30:37 -0000 1.478
@@ -106,6 +106,9 @@
#define AST_LAW(p) (((p)->law == ZT_LAW_ALAW) ? AST_FORMAT_ALAW : AST_FORMAT_ULAW)
+/* Signaling types that need to use MF detection should be placed in this macro */
+#define NEED_MFDETECT(p) (((p)->sig == SIG_FEATDMF) || ((p)->sig == SIG_FEATDMF_TA) || ((p)->sig == SIG_E911) || ((p)->sig == SIG_FEATB))
+
static const char desc[] = "Zapata Telephony"
#ifdef ZAPATA_PRI
" w/PRI"
@@ -164,6 +167,7 @@
#define DCHAN_AVAILABLE (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP)
static int cur_emdigitwait = 250; /* Wait time in ms for digits on EM channel */
+static int cur_toneduration = -1; /* Tone duration */
static char context[AST_MAX_CONTEXT] = "default";
static char cid_num[256] = "";
@@ -2652,6 +2656,8 @@
}
break;
case AST_OPTION_RELAXDTMF: /* Relax DTMF decoding (or not) */
+ if (!p->dsp)
+ break;
if (!*cp)
{
ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: OFF(0) on %s\n",chan->name);
@@ -4787,9 +4793,10 @@
}
#ifdef ZT_TONEDETECT
x = ZT_TONEDETECT_ON | ZT_TONEDETECT_MUTE;
- if (ioctl(i->subs[index].zfd, ZT_TONEDETECT, &x))
+ if (ioctl(i->subs[index].zfd, ZT_TONEDETECT, &x) || NEED_MFDETECT(i))
#endif
features |= DSP_FEATURE_DTMF_DETECT;
+
if (features) {
if (i->dsp) {
ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name);
@@ -4811,7 +4818,7 @@
ast_dsp_set_call_progress_zone(i->dsp, progzone);
if (i->busydetect && CANBUSYDETECT(i)) {
ast_dsp_set_busy_count(i->dsp, i->busycount);
- }
+ }
}
}
}
@@ -5019,7 +5026,7 @@
if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) {
/* Start the real PBX */
ast_copy_string(chan->exten, exten, sizeof(chan->exten));
- ast_dsp_digitreset(p->dsp);
+ if (p->dsp) ast_dsp_digitreset(p->dsp);
ast_setstate(chan, AST_STATE_RING);
res = ast_pbx_run(chan);
if (res) {
@@ -5053,7 +5060,7 @@
ast_dsp_digitreset(p->dsp);
/* set digit mode appropriately */
if (p->dsp) {
- if ((p->sig == SIG_FEATDMF) || (p->sig == SIG_FEATDMF_TA) || (p->sig == SIG_E911) || (p->sig == SIG_FEATB))
+ if (NEED_MFDETECT(p))
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MF | p->dtmfrelax);
else
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax);
@@ -5074,7 +5081,7 @@
res = my_getsigstr(chan,dtmfbuf + 1,'*',3000);
if (res > 0)
res = my_getsigstr(chan,dtmfbuf + strlen(dtmfbuf),'*',3000);
- if (res < 1) ast_dsp_digitreset(p->dsp);
+ if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp);
break;
case SIG_FEATDMF:
case SIG_E911:
@@ -5087,12 +5094,12 @@
}
res = my_getsigstr(chan,dtmfbuf + strlen(dtmfbuf),'#',3000);
}
- if (res < 1) ast_dsp_digitreset(p->dsp);
+ if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp);
break;
case SIG_FEATB:
case SIG_SF_FEATB:
res = my_getsigstr(chan,dtmfbuf + 1,'#',3000);
- if (res < 1) ast_dsp_digitreset(p->dsp);
+ if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp);
break;
default:
/* If we got it, get the rest */
@@ -5186,10 +5193,10 @@
}
zt_enable_ec(p);
if ((p->sig == SIG_FEATDMF) || (p->sig == SIG_E911) || (p->sig == SIG_FEATB))
- ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax);
+ if (p->dsp) ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax);
if (ast_exists_extension(chan, chan->context, exten, 1, chan->cid.cid_num)) {
ast_copy_string(chan->exten, exten, sizeof(chan->exten));
- ast_dsp_digitreset(p->dsp);
+ if (p->dsp) ast_dsp_digitreset(p->dsp);
res = ast_pbx_run(chan);
if (res) {
ast_log(LOG_WARNING, "PBX exited non-zero\n");
@@ -6527,6 +6534,7 @@
struct zt_bufferinfo bi;
#endif
struct zt_spaninfo si;
+ struct zt_dialparams dps;
int res;
int span=0;
int here = 0;
@@ -6798,7 +6806,16 @@
if (cur_debounce >= 0)
p.debouncetime = cur_debounce;
}
-
+
+ if (cur_toneduration > -1) {
+ dps.dtmf_tonelen = dps.mfv1_tonelen = cur_toneduration;
+ res = ioctl(tmp->subs[SUB_REAL].zfd, ZT_SET_DIALPARAMS, &dps);
+ if (res < 0) {
+ ast_log(LOG_ERROR, "Invalid tone duration: %d ms\n", cur_toneduration);
+ destroy_zt_pvt(&tmp);
+ return NULL;
+ }
+ }
/* dont set parms on a pseudo-channel (or CRV) */
if (tmp->subs[SUB_REAL].zfd >= 0)
{
@@ -10488,6 +10505,8 @@
cur_debounce = atoi(v->value);
} else if (!strcasecmp(v->name, "emdigitwait")) {
cur_emdigitwait = atoi(v->value);
+ } else if (!strcasecmp(v->name, "toneduration")) {
+ cur_toneduration = atoi(v->value);
} else if (!strcasecmp(v->name, "polarityonanswerdelay")) {
polarityonanswerdelay = atoi(v->value);
} else if (!strcasecmp(v->name, "answeronpolarityswitch")) {
More information about the svn-commits
mailing list