From: Shaun Ruffell Date: Fri, 5 Nov 2010 00:02:53 +0000 (+0000) Subject: codecs/codec_dahdi: Prevent "choppy" audio when receiving unexpected frame sizes. X-Git-Tag: 1.4.38-rc1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb88f0dcc5e5c8975cfc906fbcc95cb608be8c80;p=thirdparty%2Fasterisk.git codecs/codec_dahdi: Prevent "choppy" audio when receiving unexpected frame sizes. dahdi-linux 2.4.0 (specifically commit 9034) added the capability for the wctc4xxp to return more than a single packet of data in response to a read. However, when decoding packets, codec_dahdi was still assuming that the default number of samples was in each read. In other words, each packet your provider sent you, regardless of size, would result in 20 ms of decoded data (30 ms if decoding G723). If your provider was sending 60 ms packets then codec_dahdi would end up stripping 40 ms of data from each transcoded frame resulting in "choppy" audio. This would only affect systems where G729 packets are arriving in sizes greater than 20ms or G723 packets arriving in sizes greater than 30ms. DAHDI-744. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@293968 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/codecs/codec_dahdi.c b/codecs/codec_dahdi.c index 5577272db4..fcea27d4cd 100644 --- a/codecs/codec_dahdi.c +++ b/codecs/codec_dahdi.c @@ -120,10 +120,10 @@ struct codec_dahdi_pvt { }; /* Only used by a decoder */ -static int ulawtolin(struct ast_trans_pvt *pvt) +static int ulawtolin(struct ast_trans_pvt *pvt, int samples) { struct codec_dahdi_pvt *ztp = pvt->pvt; - int i = ztp->required_samples; + int i = samples; uint8_t *src = &ztp->ulaw_buffer[0]; int16_t *dst = (int16_t *)pvt->outbuf + pvt->datalen; @@ -345,7 +345,7 @@ static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt) } } else { if (ztp->softslin) { - ulawtolin(pvt); + ulawtolin(pvt, res); pvt->f.datalen = res * 2; } else { pvt->f.datalen = res; @@ -357,7 +357,7 @@ static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt) pvt->f.offset = AST_FRIENDLY_OFFSET; pvt->f.src = pvt->t->name; pvt->f.data = pvt->outbuf; - pvt->f.samples = ztp->required_samples; + pvt->f.samples = res; pvt->samples = 0; return ast_frisolate(&pvt->f);