]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Change ast_translator_best_choice() to only pay attention to audio formats.
authorRussell Bryant <russell@russellbryant.com>
Thu, 27 Dec 2007 14:33:21 +0000 (14:33 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 27 Dec 2007 14:33:21 +0000 (14:33 +0000)
This fixes a problem where Asterisk claims that a translation path can not be
found for channels involving video.

(closes issue #11638)
Reported by: cwhuang
Tested by: cwhuang
Patch suggested by cwhuang, with some additional changes by me.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@94828 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/translate.c

index 7fa408c7c6c1d036d79d10ca74fe5783d86619a2..84e255f5222d79562044a89b035aa0c2e9a7dab5 100644 (file)
@@ -796,10 +796,10 @@ int ast_translator_best_choice(int *dst, int *srcs)
        int cur, cursrc;
        int besttime = INT_MAX;
        int beststeps = INT_MAX;
-       int common = (*dst) & (*srcs);  /* are there common formats ? */
+       int common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK;        /* are there common formats ? */
 
        if (common) { /* yes, pick one and return */
-               for (cur = 1, y = 0; y < MAX_FORMAT; cur <<= 1, y++) {
+               for (cur = 1, y = 0; y <= AST_FORMAT_MAX_AUDIO; cur <<= 1, y++) {
                        if (cur & common)       /* guaranteed to find one */
                                break;
                }
@@ -808,10 +808,10 @@ int ast_translator_best_choice(int *dst, int *srcs)
                return 0;
        } else {        /* No, we will need to translate */
                AST_LIST_LOCK(&translators);
-               for (cur = 1, y = 0; y < MAX_FORMAT; cur <<= 1, y++) {
+               for (cur = 1, y = 0; y <= AST_FORMAT_MAX_AUDIO; cur <<= 1, y++) {
                        if (! (cur & *dst))
                                continue;
-                       for (cursrc = 1, x = 0; x < MAX_FORMAT; cursrc <<= 1, x++) {
+                       for (cursrc = 1, x = 0; x <= AST_FORMAT_MAX_AUDIO; cursrc <<= 1, x++) {
                                if (!(*srcs & cursrc) || !tr_matrix[x][y].step ||
                                    tr_matrix[x][y].cost >  besttime)
                                        continue;       /* not existing or no better */