mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
Merged revisions 44166 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r44166 | pcadach | 2006-10-02 23:15:11 +0600 (Пнд, 02 Окт 2006) | 1 line Optimization of oh323_indicate(): less locks - less problems, plus single exit point ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44187 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -873,6 +873,8 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
|
|||||||
got_progress = pvt->got_progress;
|
got_progress = pvt->got_progress;
|
||||||
if (condition == AST_CONTROL_PROGRESS)
|
if (condition == AST_CONTROL_PROGRESS)
|
||||||
pvt->got_progress = 1;
|
pvt->got_progress = 1;
|
||||||
|
else if ((condition == AST_CONTROL_BUSY) || (condition == AST_CONTROL_CONGESTION))
|
||||||
|
pvt->alreadygone = 1;
|
||||||
ast_mutex_unlock(&pvt->lock);
|
ast_mutex_unlock(&pvt->lock);
|
||||||
|
|
||||||
if (h323debug)
|
if (h323debug)
|
||||||
@@ -883,72 +885,51 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
|
|||||||
if (c->_state == AST_STATE_RING || c->_state == AST_STATE_RINGING) {
|
if (c->_state == AST_STATE_RING || c->_state == AST_STATE_RINGING) {
|
||||||
h323_send_alerting(token);
|
h323_send_alerting(token);
|
||||||
res = (got_progress ? 0 : -1); /* Do not simulate any audio tones if we got PROGRESS message */
|
res = (got_progress ? 0 : -1); /* Do not simulate any audio tones if we got PROGRESS message */
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (token)
|
break;
|
||||||
free(token);
|
|
||||||
return -1;
|
|
||||||
case AST_CONTROL_PROGRESS:
|
case AST_CONTROL_PROGRESS:
|
||||||
if (c->_state != AST_STATE_UP) {
|
if (c->_state != AST_STATE_UP) {
|
||||||
/* Do not send PROGRESS message more than once */
|
/* Do not send PROGRESS message more than once */
|
||||||
if (!got_progress)
|
if (!got_progress)
|
||||||
h323_send_progress(token);
|
h323_send_progress(token);
|
||||||
break;
|
res = 0;
|
||||||
}
|
}
|
||||||
if (token)
|
break;
|
||||||
free(token);
|
|
||||||
return -1;
|
|
||||||
case AST_CONTROL_BUSY:
|
case AST_CONTROL_BUSY:
|
||||||
if (c->_state != AST_STATE_UP) {
|
if (c->_state != AST_STATE_UP) {
|
||||||
h323_answering_call(token, 1);
|
h323_answering_call(token, 1);
|
||||||
ast_mutex_lock(&pvt->lock);
|
|
||||||
pvt->alreadygone = 1;
|
|
||||||
ast_mutex_unlock(&pvt->lock);
|
|
||||||
ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
|
ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
|
||||||
break;
|
res = 0;
|
||||||
}
|
}
|
||||||
if (token)
|
break;
|
||||||
free(token);
|
|
||||||
return -1;
|
|
||||||
case AST_CONTROL_CONGESTION:
|
case AST_CONTROL_CONGESTION:
|
||||||
if (c->_state != AST_STATE_UP) {
|
if (c->_state != AST_STATE_UP) {
|
||||||
h323_answering_call(token, 1);
|
h323_answering_call(token, 1);
|
||||||
ast_mutex_lock(&pvt->lock);
|
|
||||||
pvt->alreadygone = 1;
|
|
||||||
ast_mutex_unlock(&pvt->lock);
|
|
||||||
ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
|
ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
|
||||||
break;
|
res = 0;
|
||||||
}
|
}
|
||||||
if (token)
|
break;
|
||||||
free(token);
|
|
||||||
return -1;
|
|
||||||
case AST_CONTROL_HOLD:
|
case AST_CONTROL_HOLD:
|
||||||
h323_hold_call(token, 1);
|
h323_hold_call(token, 1);
|
||||||
/* We should start MOH only if remote party isn't provide audio for us */
|
/* We should start MOH only if remote party isn't provide audio for us */
|
||||||
ast_moh_start(c, data, NULL);
|
ast_moh_start(c, data, NULL);
|
||||||
if (token)
|
res = 0;
|
||||||
free(token);
|
break;
|
||||||
return 0;
|
|
||||||
case AST_CONTROL_UNHOLD:
|
case AST_CONTROL_UNHOLD:
|
||||||
h323_hold_call(token, 0);
|
h323_hold_call(token, 0);
|
||||||
ast_moh_stop(c);
|
ast_moh_stop(c);
|
||||||
if (token)
|
res = 0;
|
||||||
free(token);
|
break;
|
||||||
return 0;
|
|
||||||
case AST_CONTROL_PROCEEDING:
|
case AST_CONTROL_PROCEEDING:
|
||||||
case -1:
|
case -1:
|
||||||
if (token)
|
break;
|
||||||
free(token);
|
|
||||||
return -1;
|
|
||||||
default:
|
default:
|
||||||
ast_log(LOG_WARNING, "Don't know how to indicate condition %d on %s\n", condition, token);
|
ast_log(LOG_WARNING, "OH323: Don't know how to indicate condition %d on %s\n", condition, token);
|
||||||
if (token)
|
break;
|
||||||
free(token);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h323debug)
|
if (h323debug)
|
||||||
ast_log(LOG_DEBUG, "OH323: Indicated %d on %s\n", condition, token);
|
ast_log(LOG_DEBUG, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
|
||||||
if (token)
|
if (token)
|
||||||
free(token);
|
free(token);
|
||||||
oh323_update_info(c);
|
oh323_update_info(c);
|
||||||
|
Reference in New Issue
Block a user