Index: channel.c =================================================================== RCS file: /usr/cvsroot/asterisk/channel.c,v retrieving revision 1.139 diff -u -r1.139 channel.c --- channel.c 15 Sep 2004 14:12:45 -0000 1.139 +++ channel.c 6 Dec 2004 18:00:34 -0000 @@ -1686,6 +1686,21 @@ native = chan->nativeformats; fmt = fmts; + /* Don't waste time building a translator path, free that lock */ + if (chan->pvt->rawwriteformat == native && chan->writeformat == fmt) { + if (native == fmt) { + if (option_debug) + ast_log(LOG_DEBUG, "No need to translate on %s from %s to %s.\n", chan->name, ast_getformatname(native), ast_getformatname(fmt)); + if (chan->pvt->writetrans) + ast_translator_free_path(chan->pvt->writetrans); + } else { + if (option_debug) + ast_log(LOG_DEBUG, "Already translating on %s from %s to %s.\n", chan->name, ast_getformatname(native), ast_getformatname(fmt)); + } + ast_mutex_unlock(&chan->lock); + return 0; + } + res = ast_translator_best_choice(&native, &fmt); if (res < 0) { ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n", @@ -1718,6 +1733,22 @@ ast_mutex_lock(&chan->lock); native = chan->nativeformats; fmt = fmts; + + /* Don't waste time building a translator path, free that lock */ + if (chan->pvt->rawreadformat == native && chan->readformat == fmt) { + if (native == fmt) { + if (option_debug) + ast_log(LOG_DEBUG, "No need to translate on %s from %s to %s.\n", chan->name, ast_getformatname(native), ast_getformatname(fmt)); + if (chan->pvt->readtrans) + ast_translator_free_path(chan->pvt->readtrans); + } else { + if (option_debug) + ast_log(LOG_DEBUG, "Already translating on %s from %s to %s.\n", chan->name, ast_getformatname(native), ast_getformatname(fmt)); + } + ast_mutex_unlock(&chan->lock); + return 0; + } + /* Find a translation path from the native read format to one of the user's read formats */ res = ast_translator_best_choice(&fmt, &native); if (res < 0) {