Minor translation performance improvement (bug #2987, not that patch though)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4393 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Mark Spencer 21 years ago
parent dc074b7029
commit 77b5459c59

@ -3,9 +3,9 @@
* *
* Translate via the use of pseudo channels * Translate via the use of pseudo channels
* *
* Copyright (C) 1999, Mark Spencer * Copyright (C) 1999-2004, Digium, Inc.
* *
* Mark Spencer <markster@linux-support.net> * Mark Spencer <markster@digium.com>
* *
* This program is free software, distributed under the terms of * This program is free software, distributed under the terms of
* the GNU General Public License * the GNU General Public License
@ -442,15 +442,21 @@ int ast_translator_best_choice(int *dst, int *srcs)
int bestdst=0; int bestdst=0;
int cur = 1; int cur = 1;
int besttime=999999999; int besttime=999999999;
ast_mutex_lock(&list_lock); if ((*dst) & (*srcs)) {
/* We have a format in common */
for (y=0;y<MAX_FORMAT;y++) { for (y=0;y<MAX_FORMAT;y++) {
if ((cur & *dst) && (cur & *srcs)) { if ((cur & *dst) && (cur & *srcs)) {
/* This is a common format to both. Pick it if we don't have one already */ /* This is a common format to both. Pick it if we don't have one already */
besttime=0; besttime=0;
bestdst = cur; bestdst = cur;
best = cur; best = cur;
break;
} }
cur = cur << 1;
}
} else {
/* We will need to translate */
ast_mutex_lock(&list_lock);
for (y=0;y<MAX_FORMAT;y++) {
if (cur & *dst) if (cur & *dst)
for (x=0;x<MAX_FORMAT;x++) { for (x=0;x<MAX_FORMAT;x++) {
if (tr_matrix[x][y].step && /* There's a step */ if (tr_matrix[x][y].step && /* There's a step */
@ -464,11 +470,12 @@ int ast_translator_best_choice(int *dst, int *srcs)
} }
cur = cur << 1; cur = cur << 1;
} }
ast_mutex_unlock(&list_lock);
}
if (best > -1) { if (best > -1) {
*srcs = best; *srcs = best;
*dst = bestdst; *dst = bestdst;
best = 0; best = 0;
} }
ast_mutex_unlock(&list_lock);
return best; return best;
} }

Loading…
Cancel
Save