diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c index bc5d9dc4f3168ea509478da0d89f6d4863cd1fe3..3533650ce1a94fd84f98d7fc6d469521cf3ac640 100644 --- a/codecs/codec_gsm.c +++ b/codecs/codec_gsm.c @@ -183,14 +183,16 @@ static struct ast_frame *lintogsm_frameout(struct ast_trans_pvt *pvt) return NULL; while (pvt->samples >= GSM_SAMPLES) { /* Encode a frame of data */ - gsm_encode(tmp->gsm, tmp->buf, (gsm_byte *)pvt->outbuf + datalen); + gsm_encode(tmp->gsm, tmp->buf + samples, (gsm_byte *) pvt->outbuf + datalen); datalen += GSM_FRAME_LEN; samples += GSM_SAMPLES; pvt->samples -= GSM_SAMPLES; - /* Move the data at the end of the buffer to the front */ - if (pvt->samples) - memmove(tmp->buf, tmp->buf + GSM_SAMPLES, pvt->samples * 2); } + + /* Move the data at the end of the buffer to the front */ + if (pvt->samples) + memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); + return ast_trans_frameout(pvt, datalen, samples); } diff --git a/codecs/codec_ilbc.c b/codecs/codec_ilbc.c index 98d410e38f93e0ca8bf931473f89047013817863..34847fcc70e9f68b4fd28e18e94f94cf678e6c38 100644 --- a/codecs/codec_ilbc.c +++ b/codecs/codec_ilbc.c @@ -176,17 +176,21 @@ static struct ast_frame *lintoilbc_frameout(struct ast_trans_pvt *pvt) while (pvt->samples >= ILBC_SAMPLES) { float tmpf[ILBC_SAMPLES]; int i; + /* Encode a frame of data */ - for ( i = 0 ; i < ILBC_SAMPLES ; i++ ) - tmpf[i] = tmp->buf[i]; + for (i = 0 ; i < ILBC_SAMPLES ; i++) + tmpf[i] = tmp->buf[samples + i]; iLBC_encode((unsigned char *) pvt->outbuf + datalen, tmpf, &tmp->enc); + datalen += ILBC_FRAME_LEN; samples += ILBC_SAMPLES; pvt->samples -= ILBC_SAMPLES; - /* Move the data at the end of the buffer to the front */ - if (pvt->samples) - memmove(tmp->buf, tmp->buf + ILBC_SAMPLES, pvt->samples * 2); } + + /* Move the data at the end of the buffer to the front */ + if (pvt->samples) + memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); + return ast_trans_frameout(pvt, datalen, samples); } diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c index 7985a11d67d3711d927c4f50742014ea49b2db70..3f46e0af8c42daffdb8927f253d1651212724d5c 100644 --- a/codecs/codec_lpc10.c +++ b/codecs/codec_lpc10.c @@ -218,9 +218,6 @@ static struct ast_frame *lintolpc10_frameout(struct ast_trans_pvt *pvt) /* Use one of the two left over bits to record if this is a 22 or 23 ms frame... important for IAX use */ tmp->longer = 1 - tmp->longer; -#if 0 /* what the heck was this for? */ - ((char *)(tmp->f.data))[consumed - 1] |= tmp->longer; -#endif } /* Move the data at the end of the buffer to the front */ if (pvt->samples) diff --git a/codecs/codec_speex.c b/codecs/codec_speex.c index 06c23e4f0feb4ee6737a4bf3ce55b0b740378b43..6978184ae0df557730a06530060ba565572c88e1 100644 --- a/codecs/codec_speex.c +++ b/codecs/codec_speex.c @@ -274,11 +274,11 @@ static struct ast_frame *lintospeex_frameout(struct ast_trans_pvt *pvt) #ifdef _SPEEX_TYPES_H /* Preprocess audio */ if (preproc) - is_speech = speex_preprocess(tmp->pp, tmp->buf, NULL); + is_speech = speex_preprocess(tmp->pp, tmp->buf + samples, NULL); /* Encode a frame of data */ if (is_speech) { /* If DTX enabled speex_encode returns 0 during silence */ - is_speech = speex_encode_int(tmp->speex, tmp->buf, &tmp->bits) || !dtx; + is_speech = speex_encode_int(tmp->speex, tmp->buf + samples, &tmp->bits) || !dtx; } else { /* 5 zeros interpreted by Speex as silence (submode 0) */ speex_bits_pack(&tmp->bits, 0, 5); @@ -289,18 +289,19 @@ static struct ast_frame *lintospeex_frameout(struct ast_trans_pvt *pvt) int x; /* Convert to floating point */ for (x = 0; x < tmp->framesize; x++) - fbuf[x] = tmp->buf[x]; + fbuf[x] = tmp->buf[samples + x]; /* Encode a frame of data */ is_speech = speex_encode(tmp->speex, fbuf, &tmp->bits) || !dtx; } #endif samples += tmp->framesize; pvt->samples -= tmp->framesize; - /* Move the data at the end of the buffer to the front */ - if (pvt->samples) - memmove(tmp->buf, tmp->buf + tmp->framesize, pvt->samples * 2); } + /* Move the data at the end of the buffer to the front */ + if (pvt->samples) + memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); + /* Use AST_FRAME_CNG to signify the start of any silence period */ if (is_speech) { tmp->silent_state = 0;