aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-29 17:40:24 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-29 17:40:24 +0000
commit0fdee4f59cb1e46bf5a1057800c84cff8353f3d6 (patch)
tree26cb286c262d61acbb5df15fbefd655db9141ef6 /channel.c
parent27aa525896fbc6cbb581621ea21eb5fc7088e225 (diff)
code cleanups
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6696 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/channel.c b/channel.c
index 12b423ba9..9296ed10d 100755
--- a/channel.c
+++ b/channel.c
@@ -2203,7 +2203,7 @@ struct ast_channel *ast_request_and_dial(const char *type, int format, void *dat
struct ast_channel *ast_request(const char *type, int format, void *data, int *cause)
{
struct chanlist *chan;
- struct ast_channel *c = NULL;
+ struct ast_channel *c;
int capabilities;
int fmt;
int res;
@@ -2212,45 +2212,51 @@ struct ast_channel *ast_request(const char *type, int format, void *data, int *c
if (!cause)
cause = &foo;
*cause = AST_CAUSE_NOTDEFINED;
+
if (ast_mutex_lock(&chlock)) {
ast_log(LOG_WARNING, "Unable to lock channel list\n");
return NULL;
}
- chan = backends;
- while(chan) {
- if (!strcasecmp(type, chan->tech->type)) {
- capabilities = chan->tech->capabilities;
- fmt = format;
- res = ast_translator_best_choice(&fmt, &capabilities);
- if (res < 0) {
- ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format);
- ast_mutex_unlock(&chlock);
- return NULL;
- }
+
+ for (chan = backends; chan; chan = chan->next) {
+ if (strcasecmp(type, chan->tech->type))
+ continue;
+
+ capabilities = chan->tech->capabilities;
+ fmt = format;
+ res = ast_translator_best_choice(&fmt, &capabilities);
+ if (res < 0) {
+ ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format);
ast_mutex_unlock(&chlock);
- if (chan->tech->requester)
- c = chan->tech->requester(type, capabilities, data, cause);
- if (c) {
- if (c->_state == AST_STATE_DOWN) {
- manager_event(EVENT_FLAG_CALL, "Newchannel",
- "Channel: %s\r\n"
- "State: %s\r\n"
- "CallerID: %s\r\n"
- "CallerIDName: %s\r\n"
- "Uniqueid: %s\r\n",
- c->name, ast_state2str(c->_state), c->cid.cid_num ? c->cid.cid_num : "<unknown>", c->cid.cid_name ? c->cid.cid_name : "<unknown>",c->uniqueid);
- }
- }
- return c;
+ return NULL;
}
- chan = chan->next;
- }
- if (!chan) {
- ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
- *cause = AST_CAUSE_NOSUCHDRIVER;
+ ast_mutex_unlock(&chlock);
+ if (!chan->tech->requester)
+ return NULL;
+
+ if (!(c = chan->tech->requester(type, capabilities, data, cause)))
+ return NULL;
+
+ if (c->_state == AST_STATE_DOWN) {
+ manager_event(EVENT_FLAG_CALL, "Newchannel",
+ "Channel: %s\r\n"
+ "State: %s\r\n"
+ "CallerID: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "Uniqueid: %s\r\n",
+ c->name, ast_state2str(c->_state),
+ c->cid.cid_num ? c->cid.cid_num : "<unknown>",
+ c->cid.cid_name ? c->cid.cid_name : "<unknown>",
+ c->uniqueid);
+ }
+ return c;
}
+
+ ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
+ *cause = AST_CAUSE_NOSUCHDRIVER;
ast_mutex_unlock(&chlock);
- return c;
+
+ return NULL;
}
int ast_call(struct ast_channel *chan, char *addr, int timeout)