Index: channels/chan_zap.c =================================================================== --- channels/chan_zap.c (revision 69052) +++ channels/chan_zap.c (working copy) @@ -976,8 +976,7 @@ int tinthreeway; struct ast_channel *towner; - if (option_debug) - ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b); + ast_debug(1, "Swapping %d and %d\n", a, b); tchan = p->subs[a].chan; towner = p->subs[a].owner; @@ -1080,8 +1079,7 @@ p->subs[x].zfd = -1; return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan); + ast_debug(1, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan); return 0; } else ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno)); @@ -1097,8 +1095,7 @@ ast_log(LOG_WARNING, "Trying to unalloc the real channel %d?!?\n", p->channel); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel); + ast_debug(1, "Released sub %d of channel %d\n", x, p->channel); if (p->subs[x].zfd > -1) { zt_close(p->subs[x].zfd); } @@ -1153,8 +1150,7 @@ ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->span); } else if (strlen(pvt->dialdest) < sizeof(pvt->dialdest) - 1) { int res; - if (option_debug) - ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit); + ast_debug(1, "Queueing digit '%c' since setup_ack not yet received\n", digit); res = strlen(pvt->dialdest); pvt->dialdest[res++] = digit; pvt->dialdest[res] = '\0'; @@ -1179,8 +1175,7 @@ else pvt->dialing = 1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit); + ast_debug(1, "Started VLDTMF digit '%c'\n", digit); pvt->dialing = 1; pvt->begindigit = digit; } @@ -1215,8 +1210,7 @@ if (pvt->begindigit) { x = -1; - if (option_debug) - ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit); + ast_debug(1, "Ending VLDTMF digit '%c'\n", digit); res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &x); pvt->dialing = 0; pvt->begindigit = 0; @@ -1390,8 +1384,7 @@ p->confno = zi.confno; } memcpy(&c->curconf, &zi, sizeof(c->curconf)); - if (option_debug) - ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno); + ast_debug(1, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno); return 0; } @@ -1423,8 +1416,7 @@ ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno); + ast_debug(1, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno); memcpy(&c->curconf, &zi, sizeof(c->curconf)); return 0; } @@ -1538,8 +1530,7 @@ Kill it. */ p->confno = -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf); + ast_debug(1, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf); return 0; } @@ -1550,13 +1541,11 @@ if (!p) return; if (p->echocanon) { - if (option_debug) - ast_log(LOG_DEBUG, "Echo cancellation already on\n"); + ast_debug(1, "Echo cancellation already on\n"); return; } if (p->digital) { - if (option_debug) - ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n"); + ast_debug(1, "Echo cancellation isn't required on digital connection\n"); return; } if (p->echocancel) { @@ -1572,11 +1561,10 @@ ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d\n", p->channel); else { p->echocanon = 1; - if (option_debug) - ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel); + ast_debug(1, "Enabled echo cancellation on channel %d\n", p->channel); } - } else if (option_debug) - ast_log(LOG_DEBUG, "No echo cancellation requested\n"); + } else + ast_debug(1, "No echo cancellation requested\n"); } static void zt_train_ec(struct zt_pvt *p) @@ -1588,14 +1576,10 @@ 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); - else { - if (option_debug) - ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel); - } - } else { - if (option_debug) - ast_log(LOG_DEBUG, "No echo training requested\n"); - } + else + ast_debug(1, "Engaged echo training on channel %d\n", p->channel); + } else + ast_debug(1, "No echo training requested\n"); } static void zt_disable_ec(struct zt_pvt *p) @@ -1607,8 +1591,8 @@ res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x); if (res) ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel); - else if (option_debug) - ast_log(LOG_DEBUG, "disabled echo cancellation on channel %d\n", p->channel); + else + ast_debug(1, "disabled echo cancellation on channel %d\n", p->channel); } p->echocanon = 0; } @@ -1690,8 +1674,7 @@ g.chan = chan; res = ioctl(fd, ZT_GETGAINS, &g); if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno)); + ast_debug(1, "Failed to read gains: %s\n", strerror(errno)); return res; } @@ -1709,8 +1692,7 @@ g.chan = chan; res = ioctl(fd, ZT_GETGAINS, &g); if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno)); + ast_debug(1, "Failed to read gains: %s\n", strerror(errno)); return res; } @@ -1803,8 +1785,7 @@ ast_log(LOG_WARNING, "Unable to set conference info: %s\n", strerror(errno)); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Disabled conferencing\n"); + ast_debug(1, "Disabled conferencing\n"); return 0; } @@ -1819,8 +1800,7 @@ return -1; } } - if (option_debug) - ast_log(LOG_DEBUG, "Restored conferencing\n"); + ast_debug(1, "Restored conferencing\n"); return 0; } @@ -2008,8 +1988,7 @@ if (c) { p->dop.op = ZT_DIAL_OP_REPLACE; snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c); - if (option_debug) - ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c); + ast_debug(1, "FXO: setup deferred dialstring: %s\n", c); } else { p->dop.dialstr[0] = '\0'; } @@ -2101,8 +2080,7 @@ #ifdef HAVE_PRI } #endif - if (option_debug) - ast_log(LOG_DEBUG, "Dialing '%s'\n", c); + ast_debug(1, "Dialing '%s'\n", c); p->dop.op = ZT_DIAL_OP_REPLACE; c += p->stripmsd; @@ -2177,10 +2155,9 @@ ast_mutex_unlock(&p->lock); return -1; } - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Deferring dialing...\n"); - } + } else + ast_debug(1, "Deferring dialing...\n"); + p->dialing = 1; if (ast_strlen_zero(c)) p->dialednone = 1; @@ -2196,8 +2173,7 @@ p->dialdest[0] = '\0'; break; default: - if (option_debug) - ast_log(LOG_DEBUG, "not yet implemented\n"); + ast_debug(1, "not yet implemented\n"); ast_mutex_unlock(&p->lock); return -1; } @@ -2298,13 +2274,11 @@ } if (p->bearer || (mysig == SIG_FXSKS)) { if (p->bearer) { - if (option_debug) - ast_log(LOG_DEBUG, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel); + ast_debug(1, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel); p->bearer->call = p->call; - } else { - if (option_debug) - ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n"); - } + } else + ast_debug(1, "I'm being setup with no bearer right now...\n"); + pri_set_crv(p->pri->pri, p->call, p->channel, 0); } p->digital = IS_DIGITAL(ast->transfercapability); @@ -2495,24 +2469,21 @@ char *digits = (char *) data; if (ast_strlen_zero(digits)) { - if (option_debug) - ast_log(LOG_DEBUG, "No digit string sent to application!\n"); + ast_debug(1, "No digit string sent to application!\n"); return -1; } p = (struct zt_pvt *)chan->tech_pvt; if (!p) { - if (option_debug) - ast_log(LOG_DEBUG, "Unable to find technology private\n"); + ast_debug(1, "Unable to find technology private\n"); return -1; } ast_mutex_lock(&p->lock); if (!p->pri || !p->call) { - if (option_debug) - ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n"); + ast_debug(1, "Unable to find pri or call on channel!\n"); ast_mutex_unlock(&p->lock); return -1; } @@ -2521,8 +2492,7 @@ pri_keypad_facility(p->pri->pri, p->call, digits); pri_rel(p->pri); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n"); + ast_debug(1, "Unable to grab pri to send keypad facility!\n"); ast_mutex_unlock(&p->lock); return -1; } @@ -2621,8 +2591,7 @@ struct zt_pvt *prev = NULL; ZT_PARAMS par; - if (option_debug) - ast_log(LOG_DEBUG, "zt_hangup(%s)\n", ast->name); + ast_debug(1, "zt_hangup(%s)\n", ast->name); if (!ast->tech_pvt) { ast_log(LOG_WARNING, "Asked to hangup channel not connected\n"); return 0; @@ -2655,9 +2624,8 @@ if (p->exten) p->exten[0] = '\0'; - if (option_debug) - ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n", - p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd); + ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n", + p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd); p->ignoredtmf = 0; if (index > -1) { @@ -2674,32 +2642,27 @@ zt_setlinear(p->subs[index].zfd, 0); if (index == SUB_REAL) { if ((p->subs[SUB_CALLWAIT].zfd > -1) && (p->subs[SUB_THREEWAY].zfd > -1)) { - if (option_debug) - ast_log(LOG_DEBUG, "Normal call hung up with both three way call and a call waiting call in place?\n"); + ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n"); if (p->subs[SUB_CALLWAIT].inthreeway) { /* We had flipped over to answer a callwait and now it's gone */ - if (option_debug) - ast_log(LOG_DEBUG, "We were flipped over to the callwait, moving back and unowning.\n"); + ast_debug(1, "We were flipped over to the callwait, moving back and unowning.\n"); /* Move to the call-wait, but un-own us until they flip back. */ swap_subs(p, SUB_CALLWAIT, SUB_REAL); unalloc_sub(p, SUB_CALLWAIT); p->owner = NULL; } else { /* The three way hung up, but we still have a call wait */ - if (option_debug) - ast_log(LOG_DEBUG, "We were in the threeway and have a callwait still. Ditching the threeway.\n"); + ast_debug(1, "We were in the threeway and have a callwait still. Ditching the threeway.\n"); swap_subs(p, SUB_THREEWAY, SUB_REAL); unalloc_sub(p, SUB_THREEWAY); if (p->subs[SUB_REAL].inthreeway) { /* This was part of a three way call. Immediately make way for another call */ - if (option_debug) - ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n"); + ast_debug(1, "Call was complete, setting owner to former third call\n"); p->owner = p->subs[SUB_REAL].owner; } else { /* This call hasn't been completed yet... Set owner to NULL */ - if (option_debug) - ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n"); + ast_debug(1, "Call was incomplete, setting owner to NULL\n"); p->owner = NULL; } p->subs[SUB_REAL].inthreeway = 0; @@ -2719,13 +2682,11 @@ if (p->subs[SUB_REAL].inthreeway) { /* This was part of a three way call. Immediately make way for another call */ - if (option_debug) - ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n"); + ast_debug(1, "Call was complete, setting owner to former third call\n"); p->owner = p->subs[SUB_REAL].owner; } else { /* This call hasn't been completed yet... Set owner to NULL */ - if (option_debug) - ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n"); + ast_debug(1, "Call was incomplete, setting owner to NULL\n"); p->owner = NULL; } p->subs[SUB_REAL].inthreeway = 0; @@ -2828,8 +2789,7 @@ if (p->call && (!p->bearer || (p->bearer->call == p->call))) { if (!pri_grab(p, p->pri)) { if (p->alreadyhungup) { - if (option_debug) - ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n"); + ast_debug(1, "Already hungup... Calling hangup once, and clearing call\n"); #ifdef SUPPORT_USERUSER pri_call_set_useruser(p->call, useruser); @@ -2842,8 +2802,7 @@ } else { const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE"); int icause = ast->hangupcause ? ast->hangupcause : -1; - if (option_debug) - ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n"); + ast_debug(1, "Not yet hungup... Calling hangup once with icause, and clearing call\n"); #ifdef SUPPORT_USERUSER pri_call_set_useruser(p->call, useruser); @@ -2867,8 +2826,7 @@ } } else { if (p->bearer) - if (option_debug) - ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call); + ast_debug(1, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call); p->call = NULL; res = 0; } @@ -2886,8 +2844,7 @@ res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &par); if (!res) { #if 0 - if (option_debug) - ast_log(LOG_DEBUG, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook); + ast_debug(1, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook); #endif /* If they're off hook, try playing congestion */ if ((par.rxisoffhook) && (!(p->radio || (p->oprmode < 0)))) @@ -2932,8 +2889,7 @@ } #ifdef HAVE_PRI if (p->bearer) { - if (option_debug) - ast_log(LOG_DEBUG, "Freeing up bearer channel %d\n", p->bearer->channel); + ast_debug(1, "Freeing up bearer channel %d\n", p->bearer->channel); /* Free up the bearer channel as well, and don't use its file descriptor anymore */ update_conf(p->bearer); @@ -3016,8 +2972,7 @@ case SIG_FXOGS: case SIG_FXOKS: /* Pick up the line */ - if (option_debug) - ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name); + ast_debug(1, "Took %s off hook\n", ast->name); if (p->hanguponpolarityswitch) { gettimeofday(&p->polaritydelaytv, NULL); } @@ -3026,8 +2981,7 @@ p->dialing = 0; if ((index == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) { if (oldstate == AST_STATE_RINGING) { - if (option_debug) - ast_log(LOG_DEBUG, "Finally swapping real and threeway\n"); + ast_debug(1, "Finally swapping real and threeway\n"); tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, -1); swap_subs(p, SUB_THREEWAY, SUB_REAL); p->owner = p->subs[SUB_REAL].owner; @@ -3098,8 +3052,7 @@ ast_log(LOG_WARNING, "No index in TXGAIN?\n"); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp); + ast_debug(1, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp); return set_actual_txgain(p->subs[index].zfd, 0, p->txgain + (float) *scp, p->law); case AST_OPTION_RXGAIN: scp = (signed char *) data; @@ -3108,8 +3061,7 @@ ast_log(LOG_WARNING, "No index in RXGAIN?\n"); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp); + ast_debug(1, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp); return set_actual_rxgain(p->subs[index].zfd, 0, p->rxgain + (float) *scp, p->law); case AST_OPTION_TONE_VERIFY: if (!p->dsp) @@ -3117,18 +3069,15 @@ cp = (char *) data; switch (*cp) { case 1: - if (option_debug) - ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name); + ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name); ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | p->dtmfrelax); /* set mute mode if desired */ break; case 2: - if (option_debug) - ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name); + ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name); ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX | p->dtmfrelax); /* set mute mode if desired */ break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name); + ast_debug(1, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name); ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); /* set mute mode if desired */ break; } @@ -3138,16 +3087,14 @@ cp = (char *) data; p->mate = 0; if (!*cp) { /* turn it off */ - if (option_debug) - ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name); + ast_debug(1, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name); if (p->tdd) tdd_free(p->tdd); p->tdd = 0; break; } - if (option_debug) - ast_log(LOG_DEBUG, "Set option TDD MODE, value: %s(%d) on %s\n", - (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name); + ast_debug(1, "Set option TDD MODE, value: %s(%d) on %s\n", + (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name); zt_disable_ec(p); /* otherwise, turn it on */ if (!p->didtdd) { /* if havent done it yet */ @@ -3176,23 +3123,20 @@ fds[0].revents = 0; res = poll(fds, 1, -1); if (!res) { - if (option_debug) - ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel); + ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel); continue; } /* if got exception */ if (fds[0].revents & POLLPRI) return -1; if (!(fds[0].revents & POLLOUT)) { - if (option_debug) - ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel); + ast_debug(1, "write fd not ready on channel %d\n", p->channel); continue; } res = write(fd, buf, size); if (res != size) { if (res == -1) return -1; - if (option_debug) - ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); + ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); break; } len -= size; @@ -3215,21 +3159,18 @@ if (!p->dsp) break; cp = (char *) data; - if (option_debug) - ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: %s(%d) on %s\n", - *cp ? "ON" : "OFF", (int) *cp, chan->name); + ast_debug(1, "Set option RELAX DTMF, value: %s(%d) on %s\n", + *cp ? "ON" : "OFF", (int) *cp, chan->name); ast_dsp_digitmode(p->dsp, ((*cp) ? DSP_DIGITMODE_RELAXDTMF : DSP_DIGITMODE_DTMF) | p->dtmfrelax); break; case AST_OPTION_AUDIO_MODE: /* Set AUDIO mode (or not) */ cp = (char *) data; if (!*cp) { - if (option_debug) - ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name); + ast_debug(1, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name); x = 0; zt_disable_ec(p); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name); + ast_debug(1, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name); x = 1; } if (ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x) == -1) @@ -3248,19 +3189,16 @@ pp->oprmode = oprmode->mode; p->oprmode = -oprmode->mode; } - if (option_debug) - ast_log(LOG_DEBUG, "Set Operator Services mode, value: %d on %s/%s\n", - oprmode->mode, chan->name,oprmode->peer->name); + ast_debug(1, "Set Operator Services mode, value: %d on %s/%s\n", + oprmode->mode, chan->name,oprmode->peer->name); break; case AST_OPTION_ECHOCAN: cp = (char *) data; if (*cp) { - if (option_debug) - ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name); + ast_debug(1, "Enabling echo cancelation on %s\n", chan->name); zt_enable_ec(p); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name); + ast_debug(1, "Disabling echo cancelation on %s\n", chan->name); zt_disable_ec(p); } break; @@ -3311,8 +3249,7 @@ if (master->slaves[x]) { if (!slave || (master->slaves[x] == slave)) { /* Take slave out of the conference */ - if (option_debug) - ast_log(LOG_DEBUG, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel); + ast_debug(1, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel); conf_del(master, &master->slaves[x]->subs[SUB_REAL], SUB_REAL); conf_del(master->slaves[x], &master->subs[SUB_REAL], SUB_REAL); master->slaves[x]->master = NULL; @@ -3368,8 +3305,7 @@ ast_log(LOG_WARNING, "Replacing master %d with new master, %d\n", slave->master->channel, master->channel); slave->master = master; - if (option_debug) - ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x); + ast_debug(1, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x); } static void disable_dtmf_detect(struct zt_pvt *p) @@ -3532,9 +3468,8 @@ nothingok = 0; } } - if (option_debug) - ast_log(LOG_DEBUG, "master: %d, slave: %d, nothingok: %d\n", - master ? master->channel : 0, slave ? slave->channel : 0, nothingok); + ast_debug(1, "master: %d, slave: %d, nothingok: %d\n", + master ? master->channel : 0, slave ? slave->channel : 0, nothingok); if (master && slave) { /* Stop any tones, or play ringtone as appropriate. If they're bridged in an active threeway call with a channel that is ringing, we should @@ -3544,13 +3479,11 @@ p1->subs[SUB_REAL].owner && p1->subs[SUB_REAL].inthreeway && (p1->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) { - if (option_debug) - ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name); + ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name); tone_zone_play_tone(p0->subs[oi0].zfd, ZT_TONE_RINGTONE); os1 = p1->subs[SUB_REAL].owner->_state; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1); + ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1); tone_zone_play_tone(p0->subs[oi0].zfd, -1); } if ((oi0 == SUB_THREEWAY) && @@ -3558,13 +3491,11 @@ p0->subs[SUB_REAL].owner && p0->subs[SUB_REAL].inthreeway && (p0->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) { - if (option_debug) - ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name); + ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name); tone_zone_play_tone(p1->subs[oi1].zfd, ZT_TONE_RINGTONE); os0 = p0->subs[SUB_REAL].owner->_state; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0); + ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0); tone_zone_play_tone(p1->subs[oi0].zfd, -1); } if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) { @@ -3637,9 +3568,8 @@ (t1 != p1->subs[SUB_REAL].inthreeway) || (oi0 != i0) || (oi1 != i1)) { - if (option_debug) - ast_log(LOG_DEBUG, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n", - op0->channel, oi0, op1->channel, oi1); + ast_debug(1, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n", + op0->channel, oi0, op1->channel, oi1); res = AST_BRIDGE_RETRY; goto return_from_bridge; } @@ -3657,8 +3587,7 @@ who = ast_waitfor_n(priority ? c0_priority : c1_priority, 2, &timeoutms); if (!who) { - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, empty read...\n"); + ast_debug(1, "Ooh, empty read...\n"); continue; } f = ast_read(who); @@ -3709,8 +3638,7 @@ struct zt_pvt *p = newchan->tech_pvt; int x; ast_mutex_lock(&p->lock); - if (option_debug) - ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name); + ast_debug(1, "New owner for channel %d is %s\n", p->channel, newchan->name); if (p->owner == oldchan) { p->owner = newchan; } @@ -3829,9 +3757,8 @@ /* Tell the caller not to hangup */ return 1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n", - p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name); + ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n", + p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name); p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; return -1; } @@ -3879,12 +3806,10 @@ struct zt_pvt *p = ast->tech_pvt; struct ast_frame *f = *dest; - if (option_debug) - ast_log(LOG_DEBUG, "DTMF digit: %c on %s\n", f->subclass, ast->name); + ast_debug(1, "DTMF digit: %c on %s\n", f->subclass, ast->name); if (p->confirmanswer) { - if (option_debug) - ast_log(LOG_DEBUG, "Confirm answer on %s!\n", ast->name); + ast_debug(1, "Confirm answer on %s!\n", ast->name); /* Upon receiving a DTMF digit, consider this an answer confirmation instead of a DTMF digit */ p->subs[index].f.frametype = AST_FRAME_CONTROL; @@ -3894,8 +3819,7 @@ p->confirmanswer = 0; } else if (p->callwaitcas) { if ((f->subclass == 'A') || (f->subclass == 'D')) { - if (option_debug) - ast_log(LOG_DEBUG, "Got some DTMF, but it's for the CAS\n"); + ast_debug(1, "Got some DTMF, but it's for the CAS\n"); if (p->cidspill) ast_free(p->cidspill); send_cwcidspill(p); @@ -3921,10 +3845,10 @@ ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context); } else ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n"); - } else if (option_debug) - ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n"); - } else if (option_debug) - ast_log(LOG_DEBUG, "Fax already handled\n"); + } else + ast_debug(1, "Already in a fax extension, not redirecting\n"); + } else + ast_debug(1, "Fax already handled\n"); zt_confmute(p, 0); p->subs[index].f.frametype = AST_FRAME_NULL; p->subs[index].f.subclass = 0; @@ -3977,13 +3901,11 @@ } else res = zt_get_event(p->subs[index].zfd); - if (option_debug) - ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index); + ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index); if (res & (ZT_EVENT_PULSEDIGIT | ZT_EVENT_DTMFUP)) { p->pulsedial = (res & ZT_EVENT_PULSEDIGIT) ? 1 : 0; - if (option_debug) - ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff); + ast_debug(1, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff); #ifdef HAVE_PRI if (!p->proceeding && p->sig == SIG_PRI && p->pri && (p->pri->overlapdial & ZAP_OVERLAPDIAL_INCOMING)) { /* absorb event */ @@ -3999,8 +3921,7 @@ } if (res & ZT_EVENT_DTMFDOWN) { - if (option_debug) - ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff); + ast_debug(1, "DTMF Down '%c'\n", res & 0xff); /* Mute conference */ zt_confmute(p, 1); p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN; @@ -4027,8 +3948,7 @@ if (p->inalarm) break; if ((p->radio || (p->oprmode < 0))) break; if (ioctl(p->subs[index].zfd,ZT_DIALING,&x) == -1) { - if (option_debug) - ast_log(LOG_DEBUG, "ZT_DIALING ioctl failed on %s\n",ast->name); + ast_debug(1, "ZT_DIALING ioctl failed on %s\n",ast->name); return NULL; } if (!x) { /* if not still dialing in driver */ @@ -4055,8 +3975,7 @@ } if (ast->_state == AST_STATE_DIALING) { if ((p->callprogress & 1) && CANPROGRESSDETECT(p) && p->dsp && p->outgoing) { - if (option_debug) - ast_log(LOG_DEBUG, "Done dialing, but waiting for progress detection before doing more...\n"); + ast_debug(1, "Done dialing, but waiting for progress detection before doing more...\n"); } else if (p->confirmanswer || (!p->dialednone && ((mysig == SIG_EM) || (mysig == SIG_EM_E1) || (mysig == SIG_EMWINK) || (mysig == SIG_FEATD) || (mysig == SIG_FEATDMF_TA) || (mysig == SIG_FEATDMF) || (mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF) || (mysig == SIG_FEATB) || (mysig == SIG_SF) || (mysig == SIG_SFWINK) || (mysig == SIG_SF_FEATD) || (mysig == SIG_SF_FEATDMF) || (mysig == SIG_SF_FEATB)))) { ast_setstate(ast, AST_STATE_RINGING); } else if (!p->answeronpolarityswitch) { @@ -4174,16 +4093,14 @@ return NULL; } mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime); - if (option_debug) - ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash); + ast_debug(1, "Last flash was %d ms ago\n", mssinceflash); if (mssinceflash < MIN_MS_SINCE_FLASH) { /* It hasn't been long enough since the last flashook. This is probably a bounce on hanging up. Hangup both channels now */ if (p->subs[SUB_THREEWAY].owner) ast_queue_hangup(p->subs[SUB_THREEWAY].owner); p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; - if (option_debug) - ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel); + ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel); ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); } else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) { if (p->transfer) { @@ -4291,8 +4208,7 @@ p->subs[index].f.subclass = AST_CONTROL_ANSWER; /* Make sure it stops ringing */ zt_set_hook(p->subs[index].zfd, ZT_OFFHOOK); - if (option_debug) - ast_log(LOG_DEBUG, "channel %d answered\n", p->channel); + ast_debug(1, "channel %d answered\n", p->channel); if (p->cidspill) { /* Cancel any running CallerID spill */ ast_free(p->cidspill); @@ -4312,8 +4228,7 @@ p->dop.dialstr[0] = '\0'; return NULL; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Sent FXO deferred digit string: %s\n", p->dop.dialstr); + ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr); p->subs[index].f.frametype = AST_FRAME_NULL; p->subs[index].f.subclass = 0; p->dialing = 1; @@ -4328,8 +4243,7 @@ ast->rings = 1; p->subs[index].f.frametype = AST_FRAME_CONTROL; p->subs[index].f.subclass = AST_CONTROL_OFFHOOK; - if (option_debug) - ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel); + ast_debug(1, "channel %d picked up\n", p->channel); return &p->subs[index].f; case AST_STATE_UP: /* Make sure it stops ringing */ @@ -4359,10 +4273,9 @@ /* If we get a ring then we cannot be in * reversed polarity. So we reset to idle */ - if (option_debug) - ast_log(LOG_DEBUG, "Setting IDLE polarity due " - "to ring. Old polarity was %d\n", - p->polarity); + ast_debug(1, "Setting IDLE polarity due " + "to ring. Old polarity was %d\n", + p->polarity); p->polarity = POLARITY_IDLE; /* Fall through */ @@ -4384,13 +4297,11 @@ if (ast->_state == AST_STATE_PRERING) ast_setstate(ast, AST_STATE_RING); if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) { - if (option_debug) - ast_log(LOG_DEBUG, "Ring detected\n"); + ast_debug(1, "Ring detected\n"); p->subs[index].f.frametype = AST_FRAME_CONTROL; p->subs[index].f.subclass = AST_CONTROL_RING; } else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) { - if (option_debug) - ast_log(LOG_DEBUG, "Line answered\n"); + lst_debug(1, "Line answered\n"); if (p->confirmanswer) { p->subs[index].f.frametype = AST_FRAME_NULL; p->subs[index].f.subclass = 0; @@ -4472,9 +4383,8 @@ case SIG_FXOLS: case SIG_FXOGS: case SIG_FXOKS: - if (option_debug) - ast_log(LOG_DEBUG, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n", - index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd); + ast_debug(1, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n", + index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd); p->callwaitcas = 0; if (index != SUB_REAL) { @@ -4487,8 +4397,7 @@ swap_subs(p, SUB_REAL, SUB_CALLWAIT); tone_zone_play_tone(p->subs[SUB_REAL].zfd, -1); p->owner = p->subs[SUB_REAL].owner; - if (option_debug) - ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name); + ast_debug(1, "Making %s the new owner\n", p->owner->name); if (p->owner->_state == AST_STATE_RINGING) { ast_setstate(p->owner, AST_STATE_UP); p->subs[SUB_REAL].needanswer = 1; @@ -4528,8 +4437,7 @@ if (!((ast->pbx) || (ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING))) { - if (option_debug) - ast_log(LOG_DEBUG, "Flash when call not up or ringing\n"); + ast_debug(1, "Flash when call not up or ringing\n"); goto winkflashdone; } if (alloc_sub(p, SUB_THREEWAY)) { @@ -4577,8 +4485,7 @@ /* Already have a 3 way call */ if (p->subs[SUB_THREEWAY].inthreeway) { /* Call is already up, drop the last person */ - if (option_debug) - ast_log(LOG_DEBUG, "Got flash with three way call up, dropping last call on %d\n", p->channel); + ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel); /* If the primary call isn't answered yet, use it */ if ((p->subs[SUB_REAL].owner->_state != AST_STATE_UP) && (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_UP)) { /* Swap back -- we're dropping the real 3-way that isn't finished yet*/ @@ -4611,8 +4518,7 @@ p->subs[otherindex].needunhold = 1; p->owner = p->subs[SUB_REAL].owner; if (ast->_state == AST_STATE_RINGING) { - if (option_debug) - ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n"); + ast_debug(1, "Enabling ringtone on real and threeway\n"); res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE); res = tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, ZT_TONE_RINGTONE); } @@ -4644,16 +4550,15 @@ case SIG_FXSGS: if (option_debug) { if (p->dialing) - ast_log(LOG_DEBUG, "Ignoring wink on channel %d\n", p->channel); + ast_debug(1, "Ignoring wink on channel %d\n", p->channel); else - ast_log(LOG_DEBUG, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel); + ast_debug(1, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel); } break; case SIG_FEATDMF_TA: switch (p->whichwink) { case 0: - if (option_debug) - ast_log(LOG_DEBUG, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani); + ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani); snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani); break; case 1: @@ -4679,10 +4584,9 @@ ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel); p->dop.dialstr[0] = '\0'; return NULL; - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr); - } + } else + ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr); + p->dop.dialstr[0] = '\0'; break; default: @@ -4709,10 +4613,9 @@ ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel); p->dop.dialstr[0] = '\0'; return NULL; - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr); - } + } else + ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr); + p->dop.dialstr[0] = '\0'; p->dop.op = ZT_DIAL_OP_REPLACE; break; @@ -4724,8 +4627,7 @@ case SIG_FEATB: case SIG_SF_FEATDMF: case SIG_SF_FEATB: - if (option_debug) - ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel); + ast_debug(1, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel); break; default: break; @@ -4743,16 +4645,14 @@ if (p->answeronpolarityswitch && ((ast->_state == AST_STATE_DIALING) || (ast->_state == AST_STATE_RINGING))) { - if (option_debug) - ast_log(LOG_DEBUG, "Answering on polarity switch!\n"); + ast_debug(1, "Answering on polarity switch!\n"); ast_setstate(p->owner, AST_STATE_UP); if (p->hanguponpolarityswitch) { gettimeofday(&p->polaritydelaytv, NULL); } - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state); - } + } else + ast_debug(1, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state); + } /* Removed else statement from here as it was preventing hangups from ever happening*/ /* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */ @@ -4761,30 +4661,24 @@ (p->polarity == POLARITY_REV) && ((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) { /* Added log_debug information below to provide a better indication of what is going on */ - if (option_debug) - ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) ); + ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) ); if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) { - if (option_debug) - ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel); + ast_debug(1, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel); ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT); p->polarity = POLARITY_IDLE; - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state); - } + } else + ast_debug(1, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state); + } else { p->polarity = POLARITY_IDLE; - if (option_debug) - ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state); + ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state); } /* Added more log_debug information below to provide a better indication of what is going on */ - if (option_debug) - ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) ); + ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) ); break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel); + ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel); } return &p->subs[index].f; } @@ -4825,8 +4719,7 @@ /* Switch to real if there is one and this isn't something really silly... */ if ((res != ZT_EVENT_RINGEROFF) && (res != ZT_EVENT_RINGERON) && (res != ZT_EVENT_HOOKCOMPLETE)) { - if (option_debug) - ast_log(LOG_DEBUG, "Restoring owner of channel %d on event %d\n", p->channel, res); + ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res); p->owner = p->subs[SUB_REAL].owner; if (p->owner && ast_bridged_channel(p->owner)) ast_queue_control(p->owner, AST_CONTROL_UNHOLD); @@ -4885,8 +4778,8 @@ f = &p->subs[index].f; return f; } - if (!(p->radio || (p->oprmode < 0)) && option_debug) - ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel); + if (!(p->radio || (p->oprmode < 0))) + ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel); /* If it's not us, return NULL immediately */ if (ast != p->owner) { ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name); @@ -5029,8 +4922,7 @@ p->subs[index].f.frametype = AST_FRAME_CONTROL; p->subs[index].f.subclass = AST_CONTROL_HOLD; ast_mutex_unlock(&p->lock); - if (option_debug) - ast_log(LOG_DEBUG, "Sending hold on '%s'\n", ast->name); + ast_debug(1, "Sending hold on '%s'\n", ast->name); return &p->subs[index].f; } @@ -5040,8 +4932,7 @@ p->subs[index].f.frametype = AST_FRAME_CONTROL; p->subs[index].f.subclass = AST_CONTROL_UNHOLD; ast_mutex_unlock(&p->lock); - if (option_debug) - ast_log(LOG_DEBUG, "Sending unhold on '%s'\n", ast->name); + ast_debug(1, "Sending unhold on '%s'\n", ast->name); return &p->subs[index].f; } @@ -5086,8 +4977,7 @@ return f; } if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) { - if (option_debug) - ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE); + ast_debug(1, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE); f = __zt_exception(ast); ast_mutex_unlock(&p->lock); return f; @@ -5097,8 +4987,7 @@ c = tdd_feed(p->tdd,readbuf,READ_SIZE); if (c < 0) { - if (option_debug) - ast_log(LOG_DEBUG,"tdd_feed failed\n"); + ast_debug(1,"tdd_feed failed\n"); ast_mutex_unlock(&p->lock); return NULL; } @@ -5146,8 +5035,7 @@ p->subs[index].f.offset = AST_FRIENDLY_OFFSET; p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]); #if 0 - if (option_debug) - ast_log(LOG_DEBUG, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name); + ast_debug(1, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name); #endif if (p->dialing || /* Transmitting something */ (index && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */ @@ -5214,8 +5102,7 @@ size = (linear ? READ_SIZE * 2 : READ_SIZE); res = write(fd, buf, size); if (res != size) { - if (option_debug) - ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); + ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); return sent; } len -= size; @@ -5265,18 +5152,15 @@ return -1; } if (p->dialing) { - if (option_debug) - ast_log(LOG_DEBUG, "Dropping frame since I'm still dialing on %s...\n",ast->name); + ast_debug(1, "Dropping frame since I'm still dialing on %s...\n",ast->name); return 0; } if (!p->owner) { - if (option_debug) - ast_log(LOG_DEBUG, "Dropping frame since there is no active owner on %s...\n",ast->name); + ast_debug(1, "Dropping frame since there is no active owner on %s...\n",ast->name); return 0; } if (p->cidspill) { - if (option_debug) - ast_log(LOG_DEBUG, "Dropping frame since I've still got a callerid spill\n"); + ast_debug(1, "Dropping frame since I've still got a callerid spill\n"); return 0; } /* Return if it's not valid data */ @@ -5320,8 +5204,7 @@ int func = ZT_FLASH; ast_mutex_lock(&p->lock); index = zt_get_index(chan, p, 0); - if (option_debug) - ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name); + ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name); if (index == SUB_REAL) { switch (condition) { case AST_CONTROL_BUSY: @@ -5381,8 +5264,7 @@ } break; case AST_CONTROL_PROCEEDING: - if (option_debug) - ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name); + ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name); #ifdef HAVE_PRI if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing) { if (p->pri->pri) { @@ -5411,8 +5293,7 @@ res = 0; break; case AST_CONTROL_PROGRESS: - if (option_debug) - ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name); + ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name); #ifdef HAVE_PRI p->digital = 0; /* Digital-only calls isn't allows any inband progress messages */ if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) { @@ -5604,8 +5485,7 @@ } if (features) { if (i->dsp) { - if (option_debug) - ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name); + ast_debug(1, "Already have a dsp on %s?\n", tmp->name); } else { if (i->channel != CHAN_PSEUDO) i->dsp = ast_dsp_new(); @@ -5808,8 +5688,7 @@ timeout = gendigittimeout; res = ast_waitfordigit(chan, timeout); if (res < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); + ast_debug(1, "waitfordigit returned < 0...\n"); ast_hangup(chan); return NULL; } else if (res) { @@ -5837,8 +5716,7 @@ ast_log(LOG_WARNING, "PBX exited non-zero!\n"); } } else { - if (option_debug) - ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context); + ast_debug(1, "No such possible extension '%s' in context '%s'\n", exten, chan->context); chan->hangupcause = AST_CAUSE_UNALLOCATED; ast_hangup(chan); p->exten[0] = '\0'; @@ -5957,8 +5835,7 @@ } res = ast_waitfordigit(chan, timeout); if (res < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); + ast_debug(1, "waitfordigit returned < 0...\n"); ast_hangup(chan); return NULL; } else if (res) { @@ -5976,8 +5853,7 @@ ast_hangup(chan); return NULL; } else if (res < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "Got hung up before digits finished\n"); + ast_debug(1, "Got hung up before digits finished\n"); ast_hangup(chan); return NULL; } @@ -6134,8 +6010,7 @@ res = ast_waitfordigit(chan, timeout); timeout = 0; if (res < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); + ast_debug(1, "waitfordigit returned < 0...\n"); res = tone_zone_play_tone(p->subs[index].zfd, -1); ast_hangup(chan); return NULL; @@ -6192,8 +6067,7 @@ timeout = matchdigittimeout; } } else if (res == 0) { - if (option_debug) - ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n"); + ast_debug(1, "not enough digits (and no ambiguous match)...\n"); res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION); zt_wait_event(p->subs[index].zfd); ast_hangup(chan); @@ -6229,8 +6103,7 @@ } zt_enable_ec(p); if (ast_pickup_call(chan)) { - if (option_debug) - ast_log(LOG_DEBUG, "No call pickup possible...\n"); + ast_debug(1, "No call pickup possible...\n"); res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION); zt_wait_event(p->subs[index].zfd); } @@ -6382,8 +6255,7 @@ } } else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) && ((exten[0] != '*') || (strlen(exten) > 2))) { - if (option_debug) - ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "", chan->context); + ast_debug(1, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "", chan->context); break; } if (!timeout) @@ -6418,8 +6290,7 @@ res = 0; ast_frfree(f); if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "Got ring!\n"); + ast_debug(1, "Got ring!\n"); res = 0; break; } @@ -6439,8 +6310,7 @@ else if (smdi_msg->type == 'N') pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "u"); - if (option_debug) - ast_log(LOG_DEBUG, "Recieved SMDI message on %s\n", chan->name); + ast_debug(1, "Recieved SMDI message on %s\n", chan->name); } else { ast_log(LOG_WARNING, "SMDI enabled but no SMDI message present\n"); } @@ -6457,9 +6327,8 @@ if (p->cid_signalling == CID_SIG_DTMF) { int i = 0; cs = NULL; - if (option_debug) - ast_log(LOG_DEBUG, "Receiving DTMF cid on " - "channel %s\n", chan->name); + ast_debug(1, "Receiving DTMF cid on " + "channel %s\n", chan->name); zt_setlinear(p->subs[index].zfd, 0); res = 2000; for (;;) { @@ -6474,8 +6343,7 @@ f = ast_read(chan); if (f->frametype == AST_FRAME_DTMF) { dtmfbuf[i++] = f->subclass; - if (option_debug) - ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass); + ast_debug(1, "CID got digit '%c'\n", f->subclass); res = 2000; } ast_frfree(f); @@ -6486,12 +6354,10 @@ dtmfbuf[i] = '\0'; zt_setlinear(p->subs[index].zfd, p->subs[index].linear); /* Got cid and ring. */ - if (option_debug) - ast_log(LOG_DEBUG, "CID got string '%s'\n", dtmfbuf); + ast_debug(1, "CID got string '%s'\n", dtmfbuf); callerid_get_dtmf(dtmfbuf, dtmfcid, &flags); - if (option_debug) - ast_log(LOG_DEBUG, "CID is '%s', flags %d\n", - dtmfcid, flags); + ast_debug(1, "CID is '%s', flags %d\n", + dtmfcid, flags); /* If first byte is NULL, we have no cid */ if (!ast_strlen_zero(dtmfcid)) number = dtmfcid; @@ -6777,8 +6643,7 @@ } if (res == 1) { callerid_get(cs, &name, &number, &flags); - if (option_debug) - ast_log(LOG_DEBUG, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags); + ast_debug(1, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags); } if (distinctiveringaftercid == 1) { /* Clear the current ring data array so we dont have old data in it. */ @@ -7151,8 +7016,7 @@ ast_log(LOG_WARNING, "Unable to set cancel type to asynchronous\n"); return NULL; } - if (option_debug) - ast_log(LOG_DEBUG, "Monitor starting...\n"); + ast_debug(1, "Monitor starting...\n"); #endif for (;;) { /* Lock the interface list */ @@ -7218,8 +7082,7 @@ res = has_voicemail(last); if (last->msgstate != res) { int x; - if (option_debug) - ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel); + ast_debug(1, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel); x = ZT_FLUSH_BOTH; res2 = ioctl(last->subs[SUB_REAL].zfd, ZT_FLUSH, &x); if (res2) @@ -7246,8 +7109,7 @@ res = zt_get_event(i->subs[SUB_REAL].zfd); if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel); + ast_debug(1, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel); /* Don't hold iflock while handling init events */ ast_mutex_unlock(&iflock); handle_init_event(i, res); @@ -7292,8 +7154,7 @@ } else { ast_log(LOG_WARNING, "Read failed with %d: %s\n", res, strerror(errno)); } - if (option_debug) - ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel); + ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel); /* Don't hold iflock while handling init events -- race with chlock */ ast_mutex_unlock(&iflock); handle_init_event(i, res); @@ -7309,8 +7170,7 @@ continue; } res = zt_get_event(i->subs[SUB_REAL].zfd); - if (option_debug) - ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel); + ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel); /* Don't hold iflock while handling init events */ ast_mutex_unlock(&iflock); handle_init_event(i, res); @@ -8073,8 +7933,7 @@ return 1; #endif } else if (par.rxisoffhook) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel %d off hook, can't use\n", p->channel); + ast_debug(1, "Channel %d off hook, can't use\n", p->channel); /* Not available when the other end is off hook */ return 0; } @@ -8158,9 +8017,8 @@ if (!backwards && (x >= pri->numchans)) break; if (pri->pvts[x] && !pri->pvts[x]->inalarm && !pri->pvts[x]->owner) { - if (option_debug) - ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n", - pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset); + ast_debug(1, "Found empty available channel %d/%d\n", + pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset); return x; } if (backwards) @@ -8289,10 +8147,9 @@ #endif if (p && available(p, channelmatch, groupmatch, &busy, &channelmatched, &groupmatched)) { - if (option_debug) - ast_log(LOG_DEBUG, "Using channel %d\n", p->channel); - if (p->inalarm) - goto next; + ast_debug(1, "Using channel %d\n", p->channel); + if (p->inalarm) + goto next; callwait = (p->owner != NULL); #ifdef HAVE_PRI @@ -8312,10 +8169,9 @@ ast_log(LOG_NOTICE, "Failed to allocate place holder pseudo channel!\n"); p = NULL; break; - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Allocated placeholder pseudo channel\n"); - } + } else + ast_debug(1, "Allocated placeholder pseudo channel\n"); + p->pri = pri; } } @@ -8563,13 +8419,13 @@ } switch (x) { case ZT_EVENT_OVERRUN: - ast_log(LOG_DEBUG, "Overrun detected!\n"); + ast_debug(1, "Overrun detected!\n"); break; case ZT_EVENT_BADFCS: - ast_log(LOG_DEBUG, "Bad FCS\n"); + ast_debug(1, "Bad FCS\n"); break; case ZT_EVENT_ABORT: - ast_log(LOG_DEBUG, "HDLC Abort\n"); + ast_debug(1, "HDLC Abort\n"); break; case ZT_EVENT_ALARM: ast_log(LOG_ERROR, "Alarm on link!\n"); @@ -8623,7 +8479,7 @@ } break; case MTP2_LINK_UP: - ast_log(LOG_DEBUG, "MTP2 link up\n"); + ast_debug(1, "MTP2 link up\n"); break; case ISUP_EVENT_CPG: chanpos = ss7_find_cic(linkset, e->cpg.cic); @@ -8642,13 +8498,13 @@ case CPG_EVENT_INBANDINFO: { struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, }; - ast_log(LOG_DEBUG, "Queuing frame PROGRESS on CIC %d\n", p->cic); + ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->cic); zap_queue_frame(p, &f, ss7); p->progress = 1; } break; default: - ast_log(LOG_DEBUG, "Do not handle CPG with event type 0x%x\n", e->cpg.event); + ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event); } ast_mutex_unlock(&p->lock); @@ -8670,7 +8526,7 @@ isup_rlc(ss7, e->rsc.call); break; case ISUP_EVENT_GRS: - ast_log(LOG_DEBUG, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic); + ast_debug(1, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic); chanpos = ss7_find_cic(linkset, e->grs.startcic); if (chanpos < 0) { ast_log(LOG_WARNING, "GRS on unconfigured CIC %d\n", e->grs.startcic); @@ -8686,7 +8542,7 @@ ss7_block_cics(linkset, e->gra.startcic, e->gra.endcic, e->gra.status, 1); break; case ISUP_EVENT_IAM: - ast_log(LOG_DEBUG, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num); + ast_debug(1, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num); chanpos = ss7_find_cic(linkset, e->iam.cic); if (chanpos < 0) { ast_log(LOG_WARNING, "IAM on unconfigured CIC %d\n", e->iam.cic); @@ -8743,7 +8599,7 @@ } else ss7_start_call(p, linkset); } else { - ast_log(LOG_DEBUG, "Call on CIC for unconfigured extension %s\n", p->exten); + ast_debug(1, "Call on CIC for unconfigured extension %s\n", p->exten); isup_rel(ss7, e->iam.call, -1); } ast_mutex_unlock(&p->lock); @@ -8791,7 +8647,7 @@ p = linkset->pvts[chanpos]; - ast_log(LOG_DEBUG, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic); + ast_debug(1, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic); ast_mutex_lock(&p->lock); zap_queue_frame(p, &f, linkset); @@ -8827,7 +8683,7 @@ break; } p = linkset->pvts[chanpos]; - ast_log(LOG_DEBUG, "Blocking CIC %d\n", e->blo.cic); + ast_debug(1, "Blocking CIC %d\n", e->blo.cic); ast_mutex_lock(&p->lock); p->remotelyblocked = 1; ast_mutex_unlock(&p->lock); @@ -8840,7 +8696,7 @@ break; } p = linkset->pvts[chanpos]; - ast_log(LOG_DEBUG, "Unblocking CIC %d\n", e->ubl.cic); + ast_debug(1, "Unblocking CIC %d\n", e->ubl.cic); ast_mutex_lock(&p->lock); p->remotelyblocked = 0; ast_mutex_unlock(&p->lock); @@ -8879,7 +8735,7 @@ } break; default: - ast_log(LOG_DEBUG, "Unknown event %s\n", ss7_event2str(e->e)); + ast_debug(1, "Unknown event %s\n", ss7_event2str(e->e)); break; } } @@ -9017,10 +8873,9 @@ zt_close(crv->subs[SUB_REAL].zfd); pri->pvts[principle]->call = crv->call; pri_assign_bearer(crv, pri, pri->pvts[principle]); - if (option_debug) - ast_log(LOG_DEBUG, "Assigning bearer %d/%d to CRV %d:%d\n", - pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset, - pri->trunkgroup, crv->channel); + ast_debug(1, "Assigning bearer %d/%d to CRV %d:%d\n", + pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset, + pri->trunkgroup, crv->channel); wakeup_sub(crv, SUB_REAL, pri); } return principle; @@ -9449,8 +9304,7 @@ pri_restart(pri->dchans[which]); } - if (option_debug) - ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span); + ast_debug(1, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span); } else if (fds[which].revents & POLLIN) { e = pri_check_event(pri->dchans[which]); } @@ -9637,7 +9491,7 @@ break; } else { /* This is where we handle initial glare */ - ast_log(LOG_DEBUG, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n", + ast_debug(1, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n", PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span); ast_mutex_unlock(&pri->pvts[chanpos]->lock); chanpos = -1; @@ -9760,8 +9614,7 @@ pri_assign_bearer(crv, pri, pri->pvts[chanpos]); c = zt_new(crv, AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype); pri->pvts[chanpos]->owner = &inuse; - if (option_debug) - ast_log(LOG_DEBUG, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel); + ast_debug(1, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel); } else { c = zt_new(pri->pvts[chanpos], AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype); } @@ -9870,10 +9723,9 @@ zt_enable_ec(pri->pvts[chanpos]); pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1; pri->pvts[chanpos]->alerting = 1; - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n"); - } + } else + ast_debug(1, "Deferring ringing notification because of extra digits to dial...\n"); + #ifdef PRI_PROGRESS_MASK if (e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) { #else @@ -9925,9 +9777,8 @@ } ast_mutex_lock(&pri->pvts[chanpos]->lock); - if (option_debug) - ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n", - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); + ast_debug(1, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n", + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); zap_queue_frame(pri->pvts[chanpos], &f, pri); #ifdef PRI_PROGRESS_MASK if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) { @@ -9952,9 +9803,8 @@ struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, }; ast_mutex_lock(&pri->pvts[chanpos]->lock); - if (option_debug) - ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n", - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); + ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n", + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); zap_queue_frame(pri->pvts[chanpos], &f, pri); #ifdef PRI_PROGRESS_MASK if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) { @@ -10018,8 +9868,7 @@ pri->pvts[chanpos]->dsp_features = 0; } if (pri->pvts[chanpos]->realcall && (pri->pvts[chanpos]->realcall->sig == SIG_FXSKS)) { - if (option_debug) - ast_log(LOG_DEBUG, "Starting up GR-303 trunk now that we got CONNECT...\n"); + ast_debug(1, "Starting up GR-303 trunk now that we got CONNECT...\n"); x = ZT_START; res = ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_HOOK, &x); if (res < 0) { @@ -10034,14 +9883,12 @@ if (res < 0) { ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", pri->pvts[chanpos]->channel); pri->pvts[chanpos]->dop.dialstr[0] = '\0'; - } else { - if (option_debug) - ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr); - } + } else + ast_debug(1, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr); + pri->pvts[chanpos]->dop.dialstr[0] = '\0'; } else if (pri->pvts[chanpos]->confirmanswer) { - if (option_debug) - ast_log(LOG_DEBUG, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel); + ast_debug(1, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel); } else { pri->pvts[chanpos]->subs[SUB_REAL].needanswer =1; /* Enable echo cancellation if it's not on already */ @@ -10223,9 +10070,8 @@ if (pri->pvts[x] && pri->pvts[x]->resetting) { chanpos = x; ast_mutex_lock(&pri->pvts[chanpos]->lock); - if (option_debug) - ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan, - pri->pvts[chanpos]->prioffset, pri->span); + ast_debug(1, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan, + pri->pvts[chanpos]->prioffset, pri->span); if (pri->pvts[chanpos]->realcall) pri_hangup_all(pri->pvts[chanpos]->realcall, pri); else if (pri->pvts[chanpos]->owner) { @@ -10280,8 +10126,7 @@ pri->pvts[chanpos]->setup_ack = 1; /* Send any queued digits */ for (x = 0;x < strlen(pri->pvts[chanpos]->dialdest); x++) { - if (option_debug) - ast_log(LOG_DEBUG, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]); + ast_debug(1, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]); pri_information(pri->pri, pri->pvts[chanpos]->call, pri->pvts[chanpos]->dialdest[x]); } @@ -10312,8 +10157,7 @@ } break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Event: %d\n", e->e); + ast_debug(1, "Event: %d\n", e->e); } } ast_mutex_unlock(&pri->lock); @@ -10737,13 +10581,11 @@ if (option_verbose > 0) ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading zaptel configuration.\n"); while (iflist) { - if (option_debug) - ast_log(LOG_DEBUG, "Destroying zaptel channel no. %d\n", iflist->channel); + ast_debug(1, "Destroying zaptel channel no. %d\n", iflist->channel); /* Also updates iflist: */ destroy_channel(NULL, iflist, 1); } - if (option_debug) - ast_log(LOG_DEBUG, "Channels destroyed. Now re-reading config.\n"); + ast_debug(1, "Channels destroyed. Now re-reading config.\n"); if (setup_zap(1) != 0) { ast_log(LOG_WARNING, "Reload channels from zap config failed!\n"); return 1; @@ -12909,16 +12751,14 @@ fds[0].revents = 0; res = poll(fds, 1, -1); if (!res) { - if (option_debug) - ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel); + ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel); continue; } /* if got exception */ if (fds[0].revents & POLLPRI) return -1; if (!(fds[0].revents & POLLOUT)) { - if (option_debug) - ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel); + ast_debug(1, "write fd not ready on channel %d\n", p->channel); continue; } res = write(fd, buf, size); @@ -12927,8 +12767,7 @@ ast_free(mybuf); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); + ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); break; } len -= size; Index: channels/chan_vpb.cc =================================================================== --- channels/chan_vpb.cc (revision 69052) +++ channels/chan_vpb.cc (working copy) @@ -536,7 +536,7 @@ res = AST_BRIDGE_RETRY; break; } - ast_log(LOG_DEBUG, "%s: vpb_bridge: Empty frame read...\n",p0->dev); + ast_debug(1, "%s: vpb_bridge: Empty frame read...\n",p0->dev); /* check for hangup / whentohangup */ if (ast_check_hangup(c0) || ast_check_hangup(c1)) break; @@ -548,7 +548,7 @@ ((who == c1) && (flags & AST_BRIDGE_DTMF_CHANNEL_1))))) { *fo = f; *rc = who; - ast_log(LOG_DEBUG, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup"); + ast_debug(1, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup"); /* if ((c0->tech_pvt == pvt0) && (!c0->_softhangup)) { if (pr0->set_rtp_peer(c0, NULL, NULL, 0)) @@ -930,9 +930,9 @@ } else ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n"); } else - ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n"); + ast_debug(1, "Already in a fax extension, not redirecting\n"); } else - ast_log(LOG_DEBUG, "Fax already handled\n"); + ast_debug(1, "Fax already handled\n"); } else if (e->data == VPB_GRUNT) { @@ -1799,7 +1799,7 @@ if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner); */ ast_mutex_lock(&p->lock); - ast_log(LOG_DEBUG, "New owner for channel %s is %s\n", p->dev, newchan->name); + ast_debug(1, "New owner for channel %s is %s\n", p->dev, newchan->name); if (p->owner == oldchan) { p->owner = newchan; @@ -1957,7 +1957,7 @@ #endif if (res != VPB_OK) { - ast_log(LOG_DEBUG, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res)); + ast_debug(1, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res)); res = -1; } else res = 0; @@ -2278,7 +2278,7 @@ /* ast_mutex_unlock(&p->lock); */ return 0; } -/* ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame type..\n", p->dev); */ +/* ast_debug(1, "%s: vpb_write: Checked frame type..\n", p->dev); */ fmt = ast2vpbformat(frame->subclass); @@ -2288,20 +2288,20 @@ } tdiff = ast_tvdiff_ms(ast_tvnow(), p->lastplay); - ast_log(LOG_DEBUG, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff); + ast_debug(1, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff); if (tdiff < (VPB_SAMPLES/8 - 1)){ - ast_log(LOG_DEBUG, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen); + ast_debug(1, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen); // return 0; } p->lastplay = ast_tvnow(); /* - ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame format..\n", p->dev); + ast_debug(1, "%s: vpb_write: Checked frame format..\n", p->dev); */ ast_mutex_lock(&p->play_lock); /* - ast_log(LOG_DEBUG, "%s: vpb_write: Got play lock..\n", p->dev); + ast_debug(1, "%s: vpb_write: Got play lock..\n", p->dev); */ /* Check if we have set up the play_buf */ @@ -2329,8 +2329,8 @@ if( p->txswgain > MAX_VPB_GAIN ) a_gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data, frame->datalen/sizeof(short)); -/* ast_log(LOG_DEBUG, "%s: vpb_write: Applied gain..\n", p->dev); */ -/* ast_log(LOG_DEBUG, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */ +/* ast_debug(1, "%s: vpb_write: Applied gain..\n", p->dev); */ +/* ast_debug(1, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */ if ((p->read_state == 1)&&(p->play_buf_time<5)){ play_buf_time_start = ast_tvnow(); @@ -2344,7 +2344,7 @@ } else { p->chuck_count++; - ast_log(LOG_DEBUG, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count); + ast_debug(1, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count); p->play_buf_time=0; } @@ -2473,11 +2473,11 @@ /* afmt = (p->owner) ? p->owner->rawreadformat : AST_FORMAT_SLINEAR; */ if (p->owner){ afmt = p->owner->rawreadformat; -/* ast_log(LOG_DEBUG,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */ +/* ast_debug(1,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */ } else { afmt = AST_FORMAT_SLINEAR; -/* ast_log(LOG_DEBUG,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */ +/* ast_debug(1,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */ } fmt = ast2vpbformat(afmt); if (fmt < 0) { @@ -2525,7 +2525,7 @@ if ((use_ast_dtmfdet)&&(p->vad)){ fr = ast_dsp_process(p->owner,p->vad,fr); if (fr && (fr->frametype == AST_FRAME_DTMF)) - ast_log(LOG_DEBUG, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass); + ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass); if (fr->subclass == 'm'){ /* conf mute request */ fr->frametype = AST_FRAME_NULL;