[svn-commits] sruffell: linux/trunk r9361 - /linux/trunk/drivers/dahdi/dahdi-base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Sep 20 15:33:07 CDT 2010


Author: sruffell
Date: Mon Sep 20 15:33:03 2010
New Revision: 9361

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9361
Log:
dahdi: chans[ms->confna] -> conf_chan.

In  __dahdi_process_getaudio_chunk and __dahdi_process_putaudio_chunk we
can streamline the operation slightly by saving a constant pointer to
the conference channel instead of constantly dereferencing the master
channel and indexing into the chan array.

Review: https://reviewboard.asterisk.org/r/905/

Signed-off-by: Shaun Ruffell <sruffell at digium.com>

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9361&r1=9360&r2=9361
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Sep 20 15:33:03 2010
@@ -6494,6 +6494,7 @@
 
 	if ((!ms->confmute && !ms->dialing) || (ms->flags & DAHDI_FLAG_PSEUDO)) {
 		/* Handle conferencing on non-clear channel and non-HDLC channels */
+		struct dahdi_chan *const conf_chan = chans[ms->confna];
 		switch(ms->confmode & DAHDI_CONF_MODE_MASK) {
 		case DAHDI_CONF_NORMAL:
 			/* Do nuffin */
@@ -6502,11 +6503,11 @@
 			  /* if a pseudo-channel, ignore */
 			if (ms->flags & DAHDI_FLAG_PSEUDO) break;
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO) {
-				ACSS(getlin, chans[ms->confna]->getlin);
-			} else {
-				ACSS(getlin, chans[ms->confna]->putlin);
-			}
+			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+				ACSS(getlin, conf_chan->getlin);
+			else
+				ACSS(getlin, conf_chan->putlin);
+
 			for (x=0;x<DAHDI_CHUNKSIZE;x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
 			break;
@@ -6514,11 +6515,10 @@
 			  /* if a pseudo-channel, ignore */
 			if (ms->flags & DAHDI_FLAG_PSEUDO) break;
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO) {
-				ACSS(getlin, chans[ms->confna]->putlin);
-			} else {
-				ACSS(getlin, chans[ms->confna]->getlin);
-			}
+			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+				ACSS(getlin, conf_chan->putlin);
+			else
+				ACSS(getlin, conf_chan->getlin);
 
 			for (x=0;x<DAHDI_CHUNKSIZE;x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
@@ -6526,8 +6526,8 @@
 		case DAHDI_CONF_MONITORBOTH: /* monitor a channel's rx and tx mode */
 			  /* if a pseudo-channel, ignore */
 			if (ms->flags & DAHDI_FLAG_PSEUDO) break;
-			ACSS(getlin, chans[ms->confna]->putlin);
-			ACSS(getlin, chans[ms->confna]->getlin);
+			ACSS(getlin, conf_chan->putlin);
+			ACSS(getlin, conf_chan->getlin);
 			for (x=0;x<DAHDI_CHUNKSIZE;x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
 			break;
@@ -6536,12 +6536,12 @@
 			if (ms->flags & DAHDI_FLAG_PSEUDO)
 				break;
 
-			if (!chans[ms->confna]->readchunkpreec)
+			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(getlin, chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO ?
-			     chans[ms->confna]->readchunkpreec : chans[ms->confna]->putlin);
+			ACSS(getlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			     conf_chan->readchunkpreec : conf_chan->putlin);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
 
@@ -6551,12 +6551,12 @@
 			if (ms->flags & DAHDI_FLAG_PSEUDO)
 				break;
 
-			if (!chans[ms->confna]->readchunkpreec)
+			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(getlin, chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO ?
-			     chans[ms->confna]->putlin : chans[ms->confna]->readchunkpreec);
+			ACSS(getlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			     conf_chan->putlin : conf_chan->readchunkpreec);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
 
@@ -6566,11 +6566,11 @@
 			if (ms->flags & DAHDI_FLAG_PSEUDO)
 				break;
 
-			if (!chans[ms->confna]->readchunkpreec)
+			if (!conf_chan->readchunkpreec)
 				break;
 
-			ACSS(getlin, chans[ms->confna]->putlin);
-			ACSS(getlin, chans[ms->confna]->readchunkpreec);
+			ACSS(getlin, conf_chan->putlin);
+			ACSS(getlin, conf_chan->readchunkpreec);
 
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
@@ -6654,21 +6654,22 @@
 			break;
 		case DAHDI_CONF_DIGITALMON:
 			/* Real digital monitoring, but still echo cancel if desired */
-			if (!chans[ms->confna])
+			if (!conf_chan)
 				break;
-			if (chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO) {
+			if (conf_chan->flags & DAHDI_FLAG_PSEUDO) {
 				if (ms->ec_state) {
 					for (x=0;x<DAHDI_CHUNKSIZE;x++)
-						txb[x] = DAHDI_LIN2X(chans[ms->confna]->getlin[x], ms);
+						txb[x] = DAHDI_LIN2X(conf_chan->getlin[x], ms);
 				} else {
-					memcpy(txb, chans[ms->confna]->getraw, DAHDI_CHUNKSIZE);
+					memcpy(txb, conf_chan->getraw, DAHDI_CHUNKSIZE);
 				}
 			} else {
 				if (ms->ec_state) {
-					for (x=0;x<DAHDI_CHUNKSIZE;x++)
-						txb[x] = DAHDI_LIN2X(chans[ms->confna]->putlin[x], ms);
+					for (x = 0; x < DAHDI_CHUNKSIZE; x++)
+						txb[x] = DAHDI_LIN2X(conf_chan->putlin[x], ms);
 				} else {
-					memcpy(txb, chans[ms->confna]->putraw, DAHDI_CHUNKSIZE);
+					memcpy(txb, conf_chan->putraw,
+					       DAHDI_CHUNKSIZE);
 				}
 			}
 			for (x=0;x<DAHDI_CHUNKSIZE;x++)
@@ -7561,6 +7562,7 @@
 	   back */
 	if ((!ms->confmute && !ms->afterdialingtimer) ||
 	    (ms->flags & DAHDI_FLAG_PSEUDO)) {
+		struct dahdi_chan *const conf_chan = chans[ms->confna];
 		switch(ms->confmode & DAHDI_CONF_MODE_MASK) {
 		case DAHDI_CONF_NORMAL:		/* Normal mode */
 			/* Do nothing.  rx goes output */
@@ -7569,11 +7571,10 @@
 			  /* if not a pseudo-channel, ignore */
 			if (!(ms->flags & DAHDI_FLAG_PSEUDO)) break;
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO) {
-				ACSS(putlin, chans[ms->confna]->getlin);
-			} else {
-				ACSS(putlin, chans[ms->confna]->putlin);
-			}
+			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+				ACSS(putlin, conf_chan->getlin);
+			else
+				ACSS(putlin, conf_chan->putlin);
 			/* Convert back */
 			for(x=0;x<DAHDI_CHUNKSIZE;x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
@@ -7582,11 +7583,10 @@
 			  /* if not a pseudo-channel, ignore */
 			if (!(ms->flags & DAHDI_FLAG_PSEUDO)) break;
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO) {
-				ACSS(putlin, chans[ms->confna]->putlin);
-			} else {
-				ACSS(putlin, chans[ms->confna]->getlin);
-			}
+			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+				ACSS(putlin, conf_chan->putlin);
+			else
+				ACSS(putlin, conf_chan->getlin);
 			/* Convert back */
 			for(x=0;x<DAHDI_CHUNKSIZE;x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
@@ -7598,8 +7598,8 @@
 			   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]->putlin);
+			ACSS(putlin, conf_chan->getlin);
+			ACSS(putlin, conf_chan->putlin);
 			/* Convert back */
 			for(x=0;x<DAHDI_CHUNKSIZE;x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
@@ -7609,12 +7609,12 @@
 			if (!(ms->flags & DAHDI_FLAG_PSEUDO))
 				break;
 
-			if (!chans[ms->confna]->readchunkpreec)
+			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(putlin, chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO ?
-			     chans[ms->confna]->getlin : chans[ms->confna]->readchunkpreec);
+			ACSS(putlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			     conf_chan->getlin : conf_chan->readchunkpreec);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
 
@@ -7624,12 +7624,12 @@
 			if (!(ms->flags & DAHDI_FLAG_PSEUDO))
 				break;
 
-			if (!chans[ms->confna]->readchunkpreec)
+			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(putlin, chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO ?
-			     chans[ms->confna]->readchunkpreec : chans[ms->confna]->getlin);
+			ACSS(putlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			     conf_chan->readchunkpreec : conf_chan->getlin);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
 
@@ -7639,15 +7639,15 @@
 			if (!(ms->flags & DAHDI_FLAG_PSEUDO))
 				break;
 
-			if (!chans[ms->confna]->readchunkpreec)
+			if (!conf_chan->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);
+			ACSS(putlin, conf_chan->getlin);
+			ACSS(putlin, conf_chan->readchunkpreec);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
 
@@ -7731,11 +7731,10 @@
 			  /* if not a pseudo-channel, ignore */
 			if (!(ms->flags & DAHDI_FLAG_PSEUDO)) break;
 			/* Add monitored channel */
-			if (chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO) {
-				memcpy(rxb, chans[ms->confna]->getraw, DAHDI_CHUNKSIZE);
-			} else {
-				memcpy(rxb, chans[ms->confna]->putraw, DAHDI_CHUNKSIZE);
-			}
+			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+				memcpy(rxb, conf_chan->getraw, DAHDI_CHUNKSIZE);
+			else
+				memcpy(rxb, conf_chan->putraw, DAHDI_CHUNKSIZE);
 			break;
 		}
 	}




More information about the svn-commits mailing list