[zaptel-commits] kpfleming: branch qwell/echocan-debug r2428 - /team/qwell/echocan-debug/

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Sat Apr 21 08:16:40 MST 2007


Author: kpfleming
Date: Sat Apr 21 10:16:37 2007
New Revision: 2428

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2428
Log:
various cleanups, and don't set a variable to NULL when we just tested to find out that it is already NULL

Modified:
    team/qwell/echocan-debug/zaptel-base.c
    team/qwell/echocan-debug/zaptel.h
    team/qwell/echocan-debug/ztmonitor.c

Modified: team/qwell/echocan-debug/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/qwell/echocan-debug/zaptel-base.c?view=diff&rev=2428&r1=2427&r2=2428
==============================================================================
--- team/qwell/echocan-debug/zaptel-base.c (original)
+++ team/qwell/echocan-debug/zaptel-base.c Sat Apr 21 10:16:37 2007
@@ -1278,8 +1278,6 @@
 				chan->master = chan;
 			if (!chan->readchunk)
 				chan->readchunk = chan->sreadchunk;
-			if (!chan->readchunkpreec)
-				chan->readchunkpreec = NULL;
 			if (!chan->writechunk)
 				chan->writechunk = chan->swritechunk;
 			zt_set_law(chan, 0);
@@ -1717,8 +1715,8 @@
 				((chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR ||
 				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORTX ||
 				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH ||
-				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_PREECHO ||
-				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORTX_PREECHO ||
+				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_RX_PREECHO ||
+				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_TX_PREECHO ||
 				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH_PREECHO ||
 				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_DIGITALMON)) {
 				/* Take them out of conference with us */
@@ -3928,8 +3926,8 @@
 		if ((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR ||
 			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORTX ||
 			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH ||
-			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_PREECHO ||
-			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORTX_PREECHO ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_RX_PREECHO ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_TX_PREECHO ||
 			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH_PREECHO) {
 			/* Monitor mode -- it's a channel */
 			if ((stack.conf.confno < 0) || (stack.conf.confno >= ZT_MAX_CHANNELS) || !chans[stack.conf.confno]) return(-EINVAL);
@@ -3984,11 +3982,10 @@
 			chans[i]->_confn = zt_get_conf_alias(stack.conf.confno);
 		}
 
-		if ((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_PREECHO ||
-			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORTX_PREECHO ||
-			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH_PREECHO) {
+		if ((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_RX_PREECHO ||
+		    (stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_TX_PREECHO ||
+		    (stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH_PREECHO)
 			chans[stack.conf.confno]->readchunkpreec = kmalloc(sizeof(short) * ZT_MAX_CHUNKSIZE, GFP_KERNEL);
-		}
 
 		spin_unlock_irqrestore(&chan->lock, flags);
 		spin_unlock_irqrestore(&bigzaplock, flagso);
@@ -5010,38 +5007,50 @@
 			for (x=0;x<ZT_CHUNKSIZE;x++)
 				txb[x] = ZT_LIN2X(getlin[x], ms);
 			break;
-		case ZT_CONF_MONITOR_PREECHO:	/* Monitor a channel's rx mode */
+		case ZT_CONF_MONITOR_RX_PREECHO:	/* Monitor a channel's rx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & ZT_FLAG_PSEUDO) break;
+			if (ms->flags & ZT_FLAG_PSEUDO)
+				break;
+
+			if (!chans[ms->confna]->readchunkpreec)
+				break;
+
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & ZT_FLAG_PSEUDO) {
-				ACSS(getlin, chans[ms->confna]->readchunkpreec);
-			} else {
-				ACSS(getlin, chans[ms->confna]->putlin);
-			}
-			for (x=0;x<ZT_CHUNKSIZE;x++)
+			ACSS(getlin, chans[ms->confna]->flags & ZT_FLAG_PSEUDO ?
+			     chans[ms->confna]->readchunkpreec : chans[ms->confna]->putlin);
+			for (x = 0; x < ZT_CHUNKSIZE; x++)
 				txb[x] = ZT_LIN2X(getlin[x], ms);
+
 			break;
-		case ZT_CONF_MONITORTX_PREECHO: /* Monitor a channel's tx mode */
+		case ZT_CONF_MONITOR_TX_PREECHO: /* Monitor a channel's tx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & ZT_FLAG_PSEUDO) break;
+			if (ms->flags & ZT_FLAG_PSEUDO)
+				break;
+
+			if (!chans[ms->confna]->readchunkpreec)
+				break;
+
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & ZT_FLAG_PSEUDO) {
-				ACSS(getlin, chans[ms->confna]->putlin);
-			} else {
-				ACSS(getlin, chans[ms->confna]->readchunkpreec);
-			}
-
-			for (x=0;x<ZT_CHUNKSIZE;x++)
+			ACSS(getlin, chans[ms->confna]->flags & ZT_FLAG_PSEUDO ?
+			     chans[ms->confna]->putlin : chans[ms->confna]->readchunkpreec);
+			for (x = 0; x < ZT_CHUNKSIZE; x++)
 				txb[x] = ZT_LIN2X(getlin[x], ms);
+
 			break;
 		case ZT_CONF_MONITORBOTH_PREECHO: /* monitor a channel's rx and tx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & ZT_FLAG_PSEUDO) break;
+			if (ms->flags & ZT_FLAG_PSEUDO)
+				break;
+
+			if (!chans[ms->confna]->readchunkpreec)
+				break;
+
 			ACSS(getlin, chans[ms->confna]->putlin);
 			ACSS(getlin, chans[ms->confna]->readchunkpreec);
-			for (x=0;x<ZT_CHUNKSIZE;x++)
+
+			for (x = 0; x < ZT_CHUNKSIZE; x++)
 				txb[x] = ZT_LIN2X(getlin[x], ms);
+
 			break;
 		case ZT_CONF_REALANDPSEUDO:
 			/* This strange mode takes the transmit buffer and
@@ -5731,14 +5740,16 @@
 	short rxlin, txlin;
 	int x;
 	unsigned long flags;
+
 	spin_lock_irqsave(&ss->lock, flags);
+
 	if (ss->readchunkpreec) {
 		/* Save a copy of the audio before the echo can has it's way with it */
-		for (x=0;x<ZT_CHUNKSIZE;x++) {
+		for (x = 0; x < ZT_CHUNKSIZE; x++)
 			/* We only ever really need to deal with signed linear - let's just convert it now */
 			ss->readchunkpreec[x] = ZT_XLAW(rxchunk[x], ss);
-		}
-	}
+	}
+
 	/* Perform echo cancellation on a chunk if necessary */
 	if (ss->ec) {
 #if defined(CONFIG_ZAPTEL_MMX) || defined(ECHO_CAN_FP)
@@ -5973,44 +5984,53 @@
 			for(x=0;x<ZT_CHUNKSIZE;x++)
 				rxb[x] = ZT_LIN2X(putlin[x], ms);
 			break;
-		case ZT_CONF_MONITOR_PREECHO:		/* Monitor a channel's rx mode */
+		case ZT_CONF_MONITOR_RX_PREECHO:		/* Monitor a channel's rx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & ZT_FLAG_PSEUDO)) break;
+			if (!(ms->flags & ZT_FLAG_PSEUDO))
+				break;
+
+			if (!chans[ms->confna]->readchunkpreec)
+				break;
+
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & ZT_FLAG_PSEUDO) {
-				ACSS(putlin, chans[ms->confna]->getlin);
-			} else {
-				ACSS(putlin, chans[ms->confna]->readchunkpreec);
-			}
-			/* Convert back */
-			for(x=0;x<ZT_CHUNKSIZE;x++)
+			ACSS(putlin, chans[ms->confna]->flags & ZT_FLAG_PSEUDO ?
+			     chans[ms->confna]->getlin : chans[ms->confna]->readchunkpreec);
+			for (x = 0; x < ZT_CHUNKSIZE; x++)
 				rxb[x] = ZT_LIN2X(putlin[x], ms);
+
 			break;
-		case ZT_CONF_MONITORTX_PREECHO:	/* Monitor a channel's tx mode */
+		case ZT_CONF_MONITOR_TX_PREECHO:	/* Monitor a channel's tx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & ZT_FLAG_PSEUDO)) break;
+			if (!(ms->flags & ZT_FLAG_PSEUDO))
+				break;
+
+			if (!chans[ms->confna]->readchunkpreec)
+				break;
+
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & ZT_FLAG_PSEUDO) {
-				ACSS(putlin, chans[ms->confna]->readchunkpreec);
-			} else {
-				ACSS(putlin, chans[ms->confna]->getlin);
-			}
-			/* Convert back */
-			for(x=0;x<ZT_CHUNKSIZE;x++)
+			ACSS(putlin, chans[ms->confna]->flags & ZT_FLAG_PSEUDO ?
+			     chans[ms->confna]->readchunkpreec : chans[ms->confna]->getlin);
+			for (x = 0; x < ZT_CHUNKSIZE; x++)
 				rxb[x] = ZT_LIN2X(putlin[x], ms);
+
 			break;
 		case ZT_CONF_MONITORBOTH_PREECHO:	/* Monitor a channel's tx and rx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & ZT_FLAG_PSEUDO)) break;
+			if (!(ms->flags & ZT_FLAG_PSEUDO))
+				break;
+
+			if (!chans[ms->confna]->readchunkpreec)
+				break;
+
 			/* Note: Technically, saturation should be done at 
 			   the end of the whole addition, but for performance
 			   reasons, we don't do that.  Besides, it only matters
 			   when you're so loud you're clipping anyway */
 			ACSS(putlin, chans[ms->confna]->getlin);
 			ACSS(putlin, chans[ms->confna]->readchunkpreec);
-			/* Convert back */
-			for(x=0;x<ZT_CHUNKSIZE;x++)
+			for (x = 0; x < ZT_CHUNKSIZE; x++)
 				rxb[x] = ZT_LIN2X(putlin[x], ms);
+
 			break;
 		case ZT_CONF_REALANDPSEUDO:
 			  /* do normal conf mode processing */

Modified: team/qwell/echocan-debug/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/qwell/echocan-debug/zaptel.h?view=diff&rev=2428&r1=2427&r2=2428
==============================================================================
--- team/qwell/echocan-debug/zaptel.h (original)
+++ team/qwell/echocan-debug/zaptel.h Sat Apr 21 10:16:37 2007
@@ -970,8 +970,8 @@
 #define	ZT_CONF_CONFANNMON 7		/* conference announce/monitor mode */
 #define	ZT_CONF_REALANDPSEUDO 8	/* real and pseudo port both on conf */
 #define ZT_CONF_DIGITALMON 9	/* Do not decode or interpret */
-#define	ZT_CONF_MONITOR_PREECHO 10	/* monitor mode (rx of other chan) - before echo can is done */
-#define	ZT_CONF_MONITORTX_PREECHO 11	/* monitor mode (tx of other chan) - before echo can is done */
+#define	ZT_CONF_MONITOR_RX_PREECHO 10	/* monitor mode (rx of other chan) - before echo can is done */
+#define	ZT_CONF_MONITOR_TX_PREECHO 11	/* monitor mode (tx of other chan) - before echo can is done */
 #define	ZT_CONF_MONITORBOTH_PREECHO 12	/* monitor mode (rx & tx of other chan) - before echo can is done */
 #define	ZT_CONF_FLAG_MASK 0xff00	/* mask for flags */
 #define	ZT_CONF_LISTENER 0x100		/* is a listener on the conference */

Modified: team/qwell/echocan-debug/ztmonitor.c
URL: http://svn.digium.com/view/zaptel/team/qwell/echocan-debug/ztmonitor.c?view=diff&rev=2428&r1=2427&r2=2428
==============================================================================
--- team/qwell/echocan-debug/ztmonitor.c (original)
+++ team/qwell/echocan-debug/ztmonitor.c Sat Apr 21 10:16:37 2007
@@ -407,7 +407,7 @@
 			zc.chan = 0;
 			zc.confno = atoi(argv[1]);
 			/* Two pseudo's, one for tx, one for rx */
-			zc.confmode = ZT_CONF_MONITORTX_PREECHO;
+			zc.confmode = ZT_CONF_MONITOR_TX_PREECHO;
 			if (ioctl(pfd[2], ZT_SETCONF, &zc) < 0) {
 				fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
 				exit(1);
@@ -415,7 +415,7 @@
 			memset(&zc, 0, sizeof(zc));
 			zc.chan = 0;
 			zc.confno = atoi(argv[1]);
-			zc.confmode = ZT_CONF_MONITOR_PREECHO;
+			zc.confmode = ZT_CONF_MONITOR_RX_PREECHO;
 			if (ioctl(pfd[3], ZT_SETCONF, &zc) < 0) {
 				fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
 				exit(1);



More information about the zaptel-commits mailing list