[asterisk-dev] [Code Review] 3783: media formats: Fix double unref and allow translators to control output format

rmudgett reviewboard at asterisk.org
Mon Jul 14 17:03:11 CDT 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3783/#review12641
-----------------------------------------------------------



/team/group/media_formats-reviewed-trunk/main/translate.c
<https://reviewboard.asterisk.org/r/3783/#comment22915>

    This is the code that I had here for my version:
    
    	/* Setup normal static translation frame. */
    	pvt->f.frametype = AST_FRAME_VOICE;
    	pvt->f.mallocd = 0;
    	pvt->f.offset = AST_FRIENDLY_OFFSET;
    	pvt->f.src = pvt->t->name;
    	pvt->f.data.ptr = pvt->outbuf.c;
    	if (!pvt->f.subclass.format) {
    		struct ast_format *dst_format = NULL;
    
    		if (!ast_strlen_zero(pvt->t->format)) {
    			dst_format = ast_format_cache_get(pvt->t->format);
    		}
    		if (!dst_format) {
    			struct ast_codec *codec;
    
    			codec = ast_codec_get(t->dst_codec.name, t->dst_codec.type,
    				t->dst_codec.sample_rate);
    			if (!codec) {
    				ast_log(LOG_ERROR, "Unable to get destination codec\n");
    				destroy(pvt);
    				return NULL;
    			}
    			dst_format = ast_format_create(codec);
    			ao2_ref(codec, -1);
    			if (!dst_format) {
    				ast_log(LOG_ERROR, "Unable to create destination format\n");
    				destroy(pvt);
    				return NULL;
    			}
    		}
    		pvt->f.subclass.format = dst_format;
    	}
    	return pvt;
    


- rmudgett


On July 14, 2014, 4:57 p.m., Joshua Colp wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/3783/
> -----------------------------------------------------------
> 
> (Updated July 14, 2014, 4:57 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> The codec_resample module is special in that it wants to control the format placed on the output frame. This was not achievable as the format would get overwritten as soon as the resample instance was initialized. The translation core now gives priority to translator implementations and falls back to finding or creating a format if that fails. The codec_resample module also assumed it had to release the format reference when in reality this is done by the translation core itself.
> 
> 
> Diffs
> -----
> 
>   /team/group/media_formats-reviewed-trunk/main/translate.c 418611 
>   /team/group/media_formats-reviewed-trunk/codecs/codec_resample.c 418611 
> 
> Diff: https://reviewboard.asterisk.org/r/3783/diff/
> 
> 
> Testing
> -------
> 
> Before patch: Placed an outbound call and had it recorded using MixMonitor. Hung up and saw that a format had been double freed.
> After patch: Placed an outbound call and had it recorded using MixMonitor. Hung up and saw normal termination.
> 
> 
> Thanks,
> 
> Joshua Colp
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140714/63e2b80b/attachment-0001.html>


More information about the asterisk-dev mailing list