--- main/translate.c (Asterisk 13.18.2) +++ main/translate.c (working copy) @@ -36,2 +36,3 @@ #include +#include @@ -1492,2 +1493,16 @@ int ast_translator_best_choice(struct as beststeps = matrix_get(x, y)->multistep; + } else if (matrix_get(x, y)->table_cost == besttablecost + && matrix_get(x, y)->multistep == beststeps) { + int gap_selected = abs(ast_format_get_sample_rate(best) + - ast_format_get_sample_rate(bestdst)); + int gap_current = abs(ast_format_get_sample_rate(src) + - ast_format_get_sample_rate(dst)); + + if (gap_current < gap_selected) { + /* better than what we have so far */ + ao2_replace(best, src); + ao2_replace(bestdst, dst); + besttablecost = matrix_get(x, y)->table_cost; + beststeps = matrix_get(x, y)->multistep; + } }