From ee8ba9f9bf668ecbbe56f2ffb798c0e81062f4bf Mon Sep 17 00:00:00 2001 From: tzafrir Date: Thu, 10 Jul 2008 08:03:56 +0000 Subject: PCM: A bugfix that was reintroduced in r4353: After this change, the echo-canceler buffers were not cleared in some cases. As a result when one FXS is put ONHOOK, the other side could hear noise for a second or two until full disconnect is done. Merged revisions 4407 via svnmerge from http://svn.digium.com/svn/zaptel/branches/1.2 git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4408 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- kernel/xpp/xbus-pcm.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'kernel/xpp') diff --git a/kernel/xpp/xbus-pcm.c b/kernel/xpp/xbus-pcm.c index 644f1b9..ff4bee1 100644 --- a/kernel/xpp/xbus-pcm.c +++ b/kernel/xpp/xbus-pcm.c @@ -865,23 +865,30 @@ void generic_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack) pcm = RPACKET_FIELD(pack, GLOBAL, PCM_READ, pcm); pcm_mask = RPACKET_FIELD(pack, GLOBAL, PCM_READ, lines); spin_lock_irqsave(&xpd->lock, flags); - pcm_mute = xpd->mute_dtmf | xpd->silence_pcm; + /* + * Calculate the channels we want to mute + */ + pcm_mute = ~xpd->wanted_pcm_mask; + pcm_mute |= xpd->mute_dtmf | xpd->silence_pcm; if(!SPAN_REGISTERED(xpd)) goto out; for (i = 0; i < xpd->channels; i++) { volatile u_char *r = xpd->span.chans[i].readchunk; bool got_data = IS_SET(pcm_mask, i); - if(IS_SET(xpd->wanted_pcm_mask, i)) { - /* Must fill zaptel buffers */ - if(got_data && !IS_SET(pcm_mute, i)) { - /* We have and want real data */ - // memset((u_char *)r, 0x5A, ZT_CHUNKSIZE); // DEBUG - // fill_beep((u_char *)r, 1, 1); // DEBUG: BEEP - memcpy((u_char *)r, pcm, ZT_CHUNKSIZE); - } else { - /* Inject SILENCE */ - memset((u_char *)r, 0x7F, ZT_CHUNKSIZE); + if(got_data && !IS_SET(pcm_mute, i)) { + /* We have and want real data */ + // memset((u_char *)r, 0x5A, ZT_CHUNKSIZE); // DEBUG + // fill_beep((u_char *)r, 1, 1); // DEBUG: BEEP + memcpy((u_char *)r, pcm, ZT_CHUNKSIZE); + } else if(IS_SET(xpd->wanted_pcm_mask | xpd->silence_pcm, i)) { + /* Inject SILENCE */ + memset((u_char *)r, 0x7F, ZT_CHUNKSIZE); + if(IS_SET(xpd->silence_pcm, i)) { + /* + * This will clear the EC buffers until next tick + * So we don't have noise residues from the past. + */ memset(xpd->ec_chunk2[i], 0x7F, ZT_CHUNKSIZE); memset(xpd->ec_chunk1[i], 0x7F, ZT_CHUNKSIZE); } -- cgit v1.2.3