From d80219f36636faa876c84b586e7b4b4815767be3 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 26 Jul 2006 11:23:07 +0000 Subject: Fixed rather loud clicking/tick noise when call is established. This was caused by the PLC not properly cleared before it is reused for the next call git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@627 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/pjmedia-codec/gsm.c | 10 ++++++++++ pjmedia/src/pjmedia/g711.c | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'pjmedia/src') diff --git a/pjmedia/src/pjmedia-codec/gsm.c b/pjmedia/src/pjmedia-codec/gsm.c index 57eb1900..633ddc1b 100644 --- a/pjmedia/src/pjmedia-codec/gsm.c +++ b/pjmedia/src/pjmedia-codec/gsm.c @@ -343,6 +343,8 @@ static pj_status_t gsm_dealloc_codec( pjmedia_codec_factory *factory, pjmedia_codec *codec ) { struct gsm_data *gsm_data; + pj_int16_t frame[160]; + int i; PJ_ASSERT_RETURN(factory && codec, PJ_EINVAL); PJ_ASSERT_RETURN(factory == &gsm_codec_factory.base, PJ_EINVAL); @@ -352,6 +354,14 @@ static pj_status_t gsm_dealloc_codec( pjmedia_codec_factory *factory, /* Close codec, if it's not closed. */ gsm_codec_close(codec); + /* Clear left samples in the PLC, since codec+plc will be reused + * next time. + */ + for (i=0; i<2; ++i) { + pjmedia_zero_samples(frame, PJ_ARRAY_SIZE(frame)); + pjmedia_plc_save(gsm_data->plc, frame); + } + /* Put in the free list. */ pj_mutex_lock(gsm_codec_factory.mutex); pj_list_push_front(&gsm_codec_factory.codec_list, codec); diff --git a/pjmedia/src/pjmedia/g711.c b/pjmedia/src/pjmedia/g711.c index 96604a91..a28051a0 100644 --- a/pjmedia/src/pjmedia/g711.c +++ b/pjmedia/src/pjmedia/g711.c @@ -357,7 +357,10 @@ static pj_status_t g711_alloc_codec( pjmedia_codec_factory *factory, static pj_status_t g711_dealloc_codec(pjmedia_codec_factory *factory, pjmedia_codec *codec ) { - + struct g711_private *priv = codec->codec_data; + pj_int16_t frame[SAMPLES_PER_FRAME]; + int i; + PJ_ASSERT_RETURN(factory==&g711_factory.base, PJ_EINVAL); /* Check that this node has not been deallocated before */ @@ -366,6 +369,14 @@ static pj_status_t g711_dealloc_codec(pjmedia_codec_factory *factory, return PJ_EINVALIDOP; } + /* Clear left samples in the PLC, since codec+plc will be reused + * next time. + */ + for (i=0; i<2; ++i) { + pjmedia_zero_samples(frame, PJ_ARRAY_SIZE(frame)); + pjmedia_plc_save(priv->plc, frame); + } + /* Lock mutex. */ pj_mutex_lock(g711_factory.mutex); -- cgit v1.2.3