# rename the variable 'i' in zt_new() to 'zap_chan'. # This patch should have no functional effect. Index: trunk/channels/chan_zap.c =================================================================== --- trunk.orig/channels/chan_zap.c 2008-02-27 02:21:38.442026719 +0200 +++ trunk/channels/chan_zap.c 2008-02-27 02:24:07.450518333 +0200 @@ -5823,7 +5823,7 @@ static int zt_indicate(struct ast_channe return res; } -static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int index, int law, int transfercapability) +static struct ast_channel *zt_new(struct zt_pvt *zap_chan, int state, int startpbx, int index, int law, int transfercapability) { struct ast_channel *ast_chan; int deflaw; @@ -5833,34 +5833,34 @@ static struct ast_channel *zt_new(struct struct ast_str *chan_name; struct ast_variable *v; ZT_PARAMS ps; - if (i->subs[index].owner) { - ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[index]); + if (zap_chan->subs[index].owner) { + ast_log(LOG_WARNING, "Channel %d already has a %s call\n", zap_chan->channel,subnames[index]); return NULL; } y = 1; chan_name = ast_str_alloca(32); do { #ifdef HAVE_PRI - if (i->bearer || (i->pri && (i->sig == SIG_FXSKS))) - ast_str_set(&chan_name, 0, "%d:%d-%d", i->pri->trunkgroup, i->channel, y); + if (zap_chan->bearer || (zap_chan->pri && (zap_chan->sig == SIG_FXSKS))) + ast_str_set(&chan_name, 0, "%d:%d-%d", zap_chan->pri->trunkgroup, zap_chan->channel, y); else #endif - if (i->channel == CHAN_PSEUDO) + if (zap_chan->channel == CHAN_PSEUDO) ast_str_set(&chan_name, 0, "pseudo-%ld", ast_random()); else - ast_str_set(&chan_name, 0, "%d-%d", i->channel, y); + ast_str_set(&chan_name, 0, "%d-%d", zap_chan->channel, y); for (x = 0; x < 3; x++) { - if ((index != x) && i->subs[x].owner && !strcasecmp(chan_name->str, i->subs[x].owner->name)) + if ((index != x) && zap_chan->subs[x].owner && !strcasecmp(chan_name->str, zap_chan->subs[x].owner->name)) break; } y++; } while (x < 3); - ast_chan = ast_channel_alloc(0, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "Zap/%s", chan_name->str); + ast_chan = ast_channel_alloc(0, state, zap_chan->cid_num, zap_chan->cid_name, zap_chan->accountcode, zap_chan->exten, zap_chan->context, zap_chan->amaflags, "Zap/%s", chan_name->str); if (!ast_chan) return NULL; ast_chan->tech = &zap_tech; - ps.channo = i->channel; - res = ioctl(i->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &ps); + ps.channo = zap_chan->channel; + res = ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &ps); if (res) { ast_log(LOG_WARNING, "Unable to get parameters, assuming MULAW\n"); ps.curlaw = ZT_LAW_MULAW; @@ -5875,63 +5875,63 @@ static struct ast_channel *zt_new(struct else deflaw = AST_FORMAT_ULAW; } - ast_channel_set_fd(ast_chan, 0, i->subs[index].zfd); + ast_channel_set_fd(ast_chan, 0, zap_chan->subs[index].zfd); ast_chan->nativeformats = AST_FORMAT_SLINEAR | deflaw; /* Start out assuming ulaw since it's smaller :) */ ast_chan->rawreadformat = deflaw; ast_chan->readformat = deflaw; ast_chan->rawwriteformat = deflaw; ast_chan->writeformat = deflaw; - i->subs[index].linear = 0; - zt_setlinear(i->subs[index].zfd, i->subs[index].linear); + zap_chan->subs[index].linear = 0; + zt_setlinear(zap_chan->subs[index].zfd, zap_chan->subs[index].linear); features = 0; if (index == SUB_REAL) { - if (i->busydetect && CANBUSYDETECT(i)) + if (zap_chan->busydetect && CANBUSYDETECT(zap_chan)) features |= DSP_FEATURE_BUSY_DETECT; - if ((i->callprogress & CALLPROGRESS_PROGRESS) && CANPROGRESSDETECT(i)) + if ((zap_chan->callprogress & CALLPROGRESS_PROGRESS) && CANPROGRESSDETECT(zap_chan)) features |= DSP_FEATURE_CALL_PROGRESS; - if ((!i->outgoing && (i->callprogress & CALLPROGRESS_FAX_INCOMING)) || - (i->outgoing && (i->callprogress & CALLPROGRESS_FAX_OUTGOING))) { + if ((!zap_chan->outgoing && (zap_chan->callprogress & CALLPROGRESS_FAX_INCOMING)) || + (zap_chan->outgoing && (zap_chan->callprogress & CALLPROGRESS_FAX_OUTGOING))) { features |= DSP_FEATURE_FAX_DETECT; } #ifdef ZT_TONEDETECT x = ZT_TONEDETECT_ON | ZT_TONEDETECT_MUTE; - if (ioctl(i->subs[index].zfd, ZT_TONEDETECT, &x)) { + if (ioctl(zap_chan->subs[index].zfd, ZT_TONEDETECT, &x)) { #endif - i->hardwaredtmf = 0; + zap_chan->hardwaredtmf = 0; features |= DSP_FEATURE_DTMF_DETECT; #ifdef ZT_TONEDETECT - } else if (NEED_MFDETECT(i)) { - i->hardwaredtmf = 1; + } else if (NEED_MFDETECT(zap_chan)) { + zap_chan->hardwaredtmf = 1; features |= DSP_FEATURE_DTMF_DETECT; } #endif } if (features) { - if (i->dsp) { + if (zap_chan->dsp) { ast_debug(1, "Already have a dsp on %s?\n", ast_chan->name); } else { - if (i->channel != CHAN_PSEUDO) - i->dsp = ast_dsp_new(); + if (zap_chan->channel != CHAN_PSEUDO) + zap_chan->dsp = ast_dsp_new(); else - i->dsp = NULL; - if (i->dsp) { - i->dsp_features = features & ~DSP_PROGRESS_TALK; + zap_chan->dsp = NULL; + if (zap_chan->dsp) { + zap_chan->dsp_features = features & ~DSP_PROGRESS_TALK; #if defined(HAVE_PRI) || defined(HAVE_SS7) /* We cannot do progress detection until receives PROGRESS message */ - if (i->outgoing && ((i->sig == SIG_PRI) || (i->sig == SIG_BRI) || (i->sig == SIG_BRI_PTMP) || (i->sig == SIG_SS7))) { + if (zap_chan->outgoing && ((zap_chan->sig == SIG_PRI) || (zap_chan->sig == SIG_BRI) || (zap_chan->sig == SIG_BRI_PTMP) || (zap_chan->sig == SIG_SS7))) { /* Remember requested DSP features, don't treat talking as ANSWER */ features = 0; } #endif - ast_dsp_set_features(i->dsp, features); - ast_dsp_digitmode(i->dsp, DSP_DIGITMODE_DTMF | i->dtmfrelax); + ast_dsp_set_features(zap_chan->dsp, features); + ast_dsp_digitmode(zap_chan->dsp, DSP_DIGITMODE_DTMF | zap_chan->dtmfrelax); if (!ast_strlen_zero(progzone)) - ast_dsp_set_call_progress_zone(i->dsp, progzone); - if (i->busydetect && CANBUSYDETECT(i)) { - ast_dsp_set_busy_count(i->dsp, i->busycount); - ast_dsp_set_busy_pattern(i->dsp, i->busy_tonelength, i->busy_quietlength); + ast_dsp_set_call_progress_zone(zap_chan->dsp, progzone); + if (zap_chan->busydetect && CANBUSYDETECT(zap_chan)) { + ast_dsp_set_busy_count(zap_chan->dsp, zap_chan->busycount); + ast_dsp_set_busy_pattern(zap_chan->dsp, zap_chan->busy_tonelength, zap_chan->busy_quietlength); } } } @@ -5939,72 +5939,72 @@ static struct ast_channel *zt_new(struct if (state == AST_STATE_RING) ast_chan->rings = 1; - ast_chan->tech_pvt = i; - if ((i->sig == SIG_FXOKS) || (i->sig == SIG_FXOGS) || (i->sig == SIG_FXOLS)) { + ast_chan->tech_pvt = zap_chan; + if ((zap_chan->sig == SIG_FXOKS) || (zap_chan->sig == SIG_FXOGS) || (zap_chan->sig == SIG_FXOLS)) { /* Only FXO signalled stuff can be picked up */ - ast_chan->callgroup = i->callgroup; - ast_chan->pickupgroup = i->pickupgroup; + ast_chan->callgroup = zap_chan->callgroup; + ast_chan->pickupgroup = zap_chan->pickupgroup; } - if (!ast_strlen_zero(i->language)) - ast_string_field_set(ast_chan, language, i->language); - if (!i->owner) - i->owner = ast_chan; - if (!ast_strlen_zero(i->accountcode)) - ast_string_field_set(ast_chan, accountcode, i->accountcode); - if (i->amaflags) - ast_chan->amaflags = i->amaflags; - i->subs[index].owner = ast_chan; - ast_copy_string(ast_chan->context, i->context, sizeof(ast_chan->context)); - ast_string_field_set(ast_chan, call_forward, i->call_forward); + if (!ast_strlen_zero(zap_chan->language)) + ast_string_field_set(ast_chan, language, zap_chan->language); + if (!zap_chan->owner) + zap_chan->owner = ast_chan; + if (!ast_strlen_zero(zap_chan->accountcode)) + ast_string_field_set(ast_chan, accountcode, zap_chan->accountcode); + if (zap_chan->amaflags) + ast_chan->amaflags = zap_chan->amaflags; + zap_chan->subs[index].owner = ast_chan; + ast_copy_string(ast_chan->context, zap_chan->context, sizeof(ast_chan->context)); + ast_string_field_set(ast_chan, call_forward, zap_chan->call_forward); /* If we've been told "no ADSI" then enforce it */ - if (!i->adsi) + if (!zap_chan->adsi) ast_chan->adsicpe = AST_ADSI_UNAVAILABLE; - if (!ast_strlen_zero(i->exten)) - ast_copy_string(ast_chan->exten, i->exten, sizeof(ast_chan->exten)); - if (!ast_strlen_zero(i->rdnis)) - ast_chan->cid.cid_rdnis = ast_strdup(i->rdnis); - if (!ast_strlen_zero(i->dnid)) - ast_chan->cid.cid_dnid = ast_strdup(i->dnid); + if (!ast_strlen_zero(zap_chan->exten)) + ast_copy_string(ast_chan->exten, zap_chan->exten, sizeof(ast_chan->exten)); + if (!ast_strlen_zero(zap_chan->rdnis)) + ast_chan->cid.cid_rdnis = ast_strdup(zap_chan->rdnis); + if (!ast_strlen_zero(zap_chan->dnid)) + ast_chan->cid.cid_dnid = ast_strdup(zap_chan->dnid); /* Don't use ast_set_callerid() here because it will * generate a needless NewCallerID event */ #ifdef PRI_ANI - if (!ast_strlen_zero(i->cid_ani)) - ast_chan->cid.cid_ani = ast_strdup(i->cid_ani); + if (!ast_strlen_zero(zap_chan->cid_ani)) + ast_chan->cid.cid_ani = ast_strdup(zap_chan->cid_ani); else - ast_chan->cid.cid_ani = ast_strdup(i->cid_num); + ast_chan->cid.cid_ani = ast_strdup(zap_chan->cid_num); #else - ast_chan->cid.cid_ani = ast_strdup(i->cid_num); + ast_chan->cid.cid_ani = ast_strdup(zap_chan->cid_num); #endif - ast_chan->cid.cid_pres = i->callingpres; - ast_chan->cid.cid_ton = i->cid_ton; - ast_chan->cid.cid_ani2 = i->cid_ani2; + ast_chan->cid.cid_pres = zap_chan->callingpres; + ast_chan->cid.cid_ton = zap_chan->cid_ton; + ast_chan->cid.cid_ani2 = zap_chan->cid_ani2; #if defined(HAVE_PRI) || defined(HAVE_SS7) ast_chan->transfercapability = transfercapability; pbx_builtin_setvar_helper(ast_chan, "TRANSFERCAPABILITY", ast_transfercapability2str(transfercapability)); if (transfercapability & AST_TRANS_CAP_DIGITAL) - i->digital = 1; + zap_chan->digital = 1; /* Assume calls are not idle calls unless we're told differently */ - i->isidlecall = 0; - i->alreadyhungup = 0; + zap_chan->isidlecall = 0; + zap_chan->alreadyhungup = 0; #endif /* clear the fake event in case we posted one before we had ast_channel */ - i->fake_event = 0; + zap_chan->fake_event = 0; /* Assure there is no confmute on this channel */ - zt_confmute(i, 0); + zt_confmute(zap_chan, 0); /* Configure the new channel jb */ ast_jb_configure(ast_chan, &global_jbconf); ast_device_state_changed_literal(ast_chan->name); - for (v = i->vars ; v ; v = v->next) + for (v = zap_chan->vars ; v ; v = v->next) pbx_builtin_setvar_helper(ast_chan, v->name, v->value); if (startpbx) { if (ast_pbx_start(ast_chan)) { ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_chan->name); ast_hangup(ast_chan); - i->owner = NULL; + zap_chan->owner = NULL; return NULL; } }