]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Make delay for echo training configurable
authorMark Spencer <markster@digium.com>
Wed, 23 Jun 2004 22:00:04 +0000 (22:00 +0000)
committerMark Spencer <markster@digium.com>
Wed, 23 Jun 2004 22:00:04 +0000 (22:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3291 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_zap.c
configs/zapata.conf.sample

index bad2960967f598596593d0dcb6a8c4d8e517d3d6..69eb4268570d7ead36ba8ffe388591c07fdb4d94 100755 (executable)
@@ -478,7 +478,7 @@ static struct zt_pvt {
        int echocanbridged;
        int echocanon;
        int echobreak;
-       char echorest[10];
+       char echorest[20];
        int permcallwaiting;
        int callwaitingcallerid;
        int threewaycalling;
@@ -1200,7 +1200,7 @@ static void zt_train_ec(struct zt_pvt *p)
        int x;
        int res;
        if (p && p->echocancel && p->echotraining) {
-               x = 400;
+               x = p->echotraining;
                res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
                if (res) 
                        ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
@@ -1646,8 +1646,9 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                } else 
                        snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T%sw", c + p->stripmsd);
                if (strlen(p->dop.dialstr) > 4) {
-                       strcpy(p->echorest, "w");
-                       strcpy(p->echorest + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
+                       memset(p->echorest, 'w', sizeof(p->echorest) - 1);
+                       p->echorest[sizeof(p->echorest) - 1] = '\0';
+                       strcpy(p->echorest + (p->echotraining / 400) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
                        p->echobreak = 1;
                        p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
                } else
@@ -3193,8 +3194,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                if (*c) snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*0%s#", c);
                                else strcpy(p->dop.dialstr,"M*2#");
                                if (strlen(p->dop.dialstr) > 4) {
-                                       strcpy(p->echorest, "w");
-                                       strcpy(p->echorest + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
+                                       memset(p->echorest, 'w', sizeof(p->echorest) - 1);
+                                       p->echorest[sizeof(p->echorest) - 1] = '\0';
+                                       strcpy(p->echorest + (p->echotraining / 400) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
                                        p->echobreak = 1;
                                        p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
                                } else
@@ -8603,7 +8605,16 @@ static int setup_zap(void)
                                        echocancel=128;
                        }
                } else if (!strcasecmp(v->name, "echotraining")) {
-                       echotraining = ast_true(v->value);
+                       if (sscanf(v->value, "%i", &y) == 1) {
+                               if ((y < 10) || (y > 4000)) {
+                                       ast_log(LOG_WARNING, "Echo training time must be within the range of 10 to 2000 ms at line %d\n", v->lineno);                                   
+                               } else {
+                                       echotraining = y;
+                               }
+                       } else if (ast_true(v->value)) {
+                               echotraining = 400;
+                       } else
+                               echotraining = 0;
                } else if (!strcasecmp(v->name, "hidecallerid")) {
                        hidecallerid = ast_true(v->value);
                } else if (!strcasecmp(v->name, "callreturn")) {
index f6a9d43bff08352f1463255c625520e2ebb48b9d..41ee93e1dbc28fa0635e28f0de7dd3323787cbf4 100755 (executable)
@@ -194,9 +194,11 @@ echocancelwhenbridged=yes
 ; is echo at the beginning of the call.  Enabling echo training will cause
 ; asterisk to briefly mute the channel, send an impulse, and use the impulse
 ; response to pre-train the echo canceller so it can start out with a much
-; closer idea of the actual echo.
+; closer idea of the actual echo.  Value may be "yes", "no", or a number of
+; milliseconds to delay before training (default = 400)
 ;
 ;echotraining=yes
+;echotraining=800
 ;
 ; If you are having trouble with DTMF detection, you can relax the
 ; DTMF detection parameters.  Relaxing them may make the DTMF detector