From: Doug Bailey Date: Wed, 2 Sep 2009 19:49:43 +0000 (+0000) Subject: Fix issue where DTMF CID detect was placing channels into signed linear mode X-Git-Tag: 11.0.0-beta1~4267 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eff8dd9a2fb6f0ccad5a0928cc106824194f0425;p=thirdparty%2Fasterisk.git Fix issue where DTMF CID detect was placing channels into signed linear mode made analog_set_linear_mode return back the mode that was being overwritten so it could be restored later. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@215608 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 504a5f671e..57715cc39a 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -1992,12 +1992,20 @@ static void my_unlock_private(void *pvt) ast_mutex_unlock(&p->lock); } +/* linear_mode = 0 - turn linear mode off, >0 - turn linear mode on +* returns the last value of the linear setting +*/ static int my_set_linear_mode(void *pvt, int idx, int linear_mode) { struct dahdi_pvt *p = pvt; - if (!linear_mode) - linear_mode = p->subs[idx].linear; - return dahdi_setlinear(p->subs[idx].dfd, linear_mode); + int oldval; + + if (0 > linear_mode || !dahdi_setlinear(p->subs[idx].dfd, linear_mode)) { + return -1; + } + oldval = p->subs[idx].linear; + p->subs[idx].linear = linear_mode; + return oldval; } static int get_alarms(struct dahdi_pvt *p); @@ -3494,11 +3502,7 @@ static void dahdi_close_ss7_fd(struct dahdi_ss7 *ss7, int fd_num) static int dahdi_setlinear(int dfd, int linear) { - int res; - res = ioctl(dfd, DAHDI_SETLINEAR, &linear); - if (res) - return res; - return 0; + return ioctl(dfd, DAHDI_SETLINEAR, &linear); } diff --git a/channels/sig_analog.c b/channels/sig_analog.c index 1f28f049f3..ae6620f49d 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -770,6 +770,7 @@ static int analog_check_confirmanswer(struct analog_pvt *p) static int analog_set_linear_mode(struct analog_pvt *p, int index, int linear_mode) { if (p->calls->set_linear_mode) { + /* Return provides old linear_mode setting or error indication */ return p->calls->set_linear_mode(p->chan_pvt, index, linear_mode); } return -1; @@ -2035,11 +2036,12 @@ static void *__analog_ss_thread(void *data) /* If set to use DTMF CID signalling, listen for DTMF */ if (p->cid_signalling == CID_SIG_DTMF) { int i = 0; + int oldlinearity; cs = NULL; ast_debug(1, "Receiving DTMF cid on " "channel %s\n", chan->name); - analog_set_linear_mode(p, index, 0); + oldlinearity = analog_set_linear_mode(p, index, 0); res = 2000; for (;;) { @@ -2066,7 +2068,7 @@ static void *__analog_ss_thread(void *data) } dtmfbuf[i] = '\0'; - analog_set_linear_mode(p, index, 1); + analog_set_linear_mode(p, index, oldlinearity); /* Got cid and ring. */ ast_debug(1, "CID got string '%s'\n", dtmfbuf);