--- main/translate.c (Asterisk 13.5.0) +++ main/translate.c (working copy) @@ -306,5 +306,5 @@ * and possibly desc. */ -static struct ast_trans_pvt *newpvt(struct ast_translator *t) +static struct ast_trans_pvt *newpvt(struct ast_translator *t, struct ast_format *format) { struct ast_trans_pvt *pvt; @@ -332,4 +332,5 @@ pvt->outbuf.c = ofs + AST_FRIENDLY_OFFSET; } + pvt->f.subclass.format = ao2_bump(format); ast_module_ref(t->module); @@ -484,5 +485,10 @@ return NULL; } - if (!(cur = newpvt(t))) { + if ((t->dst_codec.sample_rate != ast_format_get_sample_rate(dst)) || (strcmp(t->dst_codec.name, ast_format_get_name(dst)))) { + cur = newpvt(t, NULL); + } else { + cur = newpvt(t, dst); + } + if (!cur) { ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n", ast_format_get_name(src), ast_format_get_name(dst)); @@ -622,5 +628,5 @@ } - pvt = newpvt(t); + pvt = newpvt(t, NULL); if (!pvt) { ast_log(LOG_WARNING, "Translator '%s' appears to be broken and will probably fail.\n", t->name);