From 77522717ff36508f6a0b22b190d3f4712a478e8e Mon Sep 17 00:00:00 2001 From: tzafrir Date: Sun, 15 Jun 2008 17:10:12 +0000 Subject: Muted DTMF PCM (from FXS modules) could "leak" to the next channel. (From xpp r5796). Merged revisions 4352 via svnmerge from http://svn.digium.com/svn/zaptel/branches/1.2 git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4353 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- kernel/xpp/xbus-pcm.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'kernel/xpp') diff --git a/kernel/xpp/xbus-pcm.c b/kernel/xpp/xbus-pcm.c index 6155f35..644f1b9 100644 --- a/kernel/xpp/xbus-pcm.c +++ b/kernel/xpp/xbus-pcm.c @@ -858,34 +858,36 @@ void generic_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack) { byte *pcm; xpp_line_t pcm_mask; + xpp_line_t pcm_mute; unsigned long flags; int i; 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; if(!SPAN_REGISTERED(xpd)) goto out; for (i = 0; i < xpd->channels; i++) { volatile u_char *r = xpd->span.chans[i].readchunk; - - if(!IS_SET(xpd->wanted_pcm_mask, i)) { - if(IS_SET(xpd->silence_pcm, i)) { - memset((u_char *)r, 0x7F, ZT_CHUNKSIZE); // SILENCE + 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); memset(xpd->ec_chunk2[i], 0x7F, ZT_CHUNKSIZE); memset(xpd->ec_chunk1[i], 0x7F, ZT_CHUNKSIZE); } - continue; } - pcm_mask &= ~xpd->mute_dtmf; - if(IS_SET(pcm_mask, i)) { - // memset((u_char *)r, 0x5A, ZT_CHUNKSIZE); // DEBUG - // fill_beep((u_char *)r, 1, 1); // DEBUG: BEEP - memcpy((u_char *)r, pcm, ZT_CHUNKSIZE); + if(got_data) pcm += ZT_CHUNKSIZE; - } else { - memset((u_char *)r, 0x7F, ZT_CHUNKSIZE); // SILENCE - } } out: XPD_COUNTER(xpd, PCM_READ)++; -- cgit v1.2.3