X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=chan_lcr.c;h=f4d8378701478d3b40b130fb12710eee2f2ee084;hp=25515d03b6109042f6bf910452b45ec7189beac7;hb=3fd79822b115b5a4d4eb1e3c490c5e0c254c9914;hpb=c62fe17ee353ac81c1fb126366902b5f6e1f05c5 diff --git a/chan_lcr.c b/chan_lcr.c index 25515d0..f4d8378 100644 --- a/chan_lcr.c +++ b/chan_lcr.c @@ -2172,24 +2172,38 @@ static int lcr_hangup(struct ast_channel *ast) return 0; } -static int lcr_write(struct ast_channel *ast, struct ast_frame *f) +static int lcr_write(struct ast_channel *ast, struct ast_frame *fr) { struct chan_call *call; + struct ast_frame * f = fr; if (!f->subclass) CDEBUG(NULL, ast, "No subclass\n"); - if (!(f->subclass & ast->nativeformats)) - CDEBUG(NULL, ast, "Unexpected format.\n"); + if (!(f->subclass & ast->nativeformats)) { + CDEBUG(NULL, ast, + "Unexpected format. " + "Activating emergency conversion...\n"); + + ast_set_write_format(ast, f->subclass); + f = (ast->writetrans) ? ast_translate( + ast->writetrans, fr, 0) : fr; + } ast_mutex_lock(&chan_lock); call = ast->tech_pvt; if (!call) { ast_mutex_unlock(&chan_lock); + if (f != fr) { + ast_frfree(f); + } return -1; } if (call->bchannel && f->samples) bchannel_transmit(call->bchannel, *((unsigned char **)&(f->data)), f->samples); ast_mutex_unlock(&chan_lock); + if (f != fr) { + ast_frfree(f); + } return 0; }