diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-30 22:19:55 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-30 22:19:55 +0000 |
commit | fcf7da39e7a1ed7dcbb2a726ab31f4104a511513 (patch) | |
tree | a58bea53669057a61b8653f4f32a8fb4bd9a44a8 /main | |
parent | 85ca4c6330dbfee154d6d176daa0f9689cbfb44f (diff) |
when unregistering a translator, don't rebuild the translation matrix unless needed
when filtering formats out of an offer, ensure we check for translation ability in both directions
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46526 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/translate.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/main/translate.c b/main/translate.c index f538c6b5d..f3918d9d2 100644 --- a/main/translate.c +++ b/main/translate.c @@ -729,18 +729,25 @@ int ast_unregister_translator(struct ast_translator *t) { char tmp[80]; struct ast_translator *u; + int found = 0; + AST_LIST_LOCK(&translators); AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { if (u == t) { AST_LIST_REMOVE_CURRENT(&translators, list); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt)); + found = 1; break; } } AST_LIST_TRAVERSE_SAFE_END; - rebuild_matrix(0); + + if (found) + rebuild_matrix(0); + AST_LIST_UNLOCK(&translators); + return (u ? 0 : -1); } @@ -850,6 +857,11 @@ unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src to this format, remove it from the result */ if (!tr_matrix[src_audio][powerof(x)].step) res &= ~x; + + /* now check the opposite direction */ + if (!tr_matrix[powerof(x)][src_audio].step) + res &= ~x; + } /* For a given source video format, traverse the list of @@ -870,6 +882,10 @@ unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src to this format, remove it from the result */ if (!tr_matrix[src_video][powerof(x)].step) res &= ~x; + + /* now check the opposite direction */ + if (!tr_matrix[powerof(x)][src_video].step) + res &= ~x; } AST_LIST_UNLOCK(&translators); |