[zaptel-commits] qwell: branch 1.4 r2423 - in /branches/1.4: ./ zaptel-base.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Fri Apr 13 16:14:33 MST 2007


Author: qwell
Date: Fri Apr 13 18:14:33 2007
New Revision: 2423

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2423
Log:
Merged revisions 2422 via svnmerge from 
https://origsvn.digium.com/svn/zaptel/branches/1.2

........
r2422 | qwell | 2007-04-13 18:12:23 -0500 (Fri, 13 Apr 2007) | 14 lines

Fix several places where we treat confmode as a bitmask.
It is a bitmask...sort of..  I'll explain..

confmode is used for 2 different things.
It defines both the "mode" and the "flags" of the conference.

The "mode" part is in 0x00FF and is NOT bitwise.
The "flag" part is in 0xFF00 and *IS* bitwise.
Confused yet?  Good.

So, when we want to check the "mode" of the conference, we need to check only within 0xFF.
There were several places where this was not happening - but due to luck, it worked (...sort of).
That's what this patch fixes.

........

Modified:
    branches/1.4/   (props changed)
    branches/1.4/zaptel-base.c

Propchange: branches/1.4/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: branches/1.4/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel-base.c?view=diff&rev=2423&r1=2422&r2=2423
==============================================================================
--- branches/1.4/zaptel-base.c (original)
+++ branches/1.4/zaptel-base.c Fri Apr 13 18:14:33 2007
@@ -705,7 +705,12 @@
 	if (!confalias[x])
 		return;
 	for (y=0;y<maxchans;y++) {
-		if (chans[y] && (chans[y]->confna == x) && (chans[y]->confmode & (ZT_CONF_CONF | ZT_CONF_CONFANN | ZT_CONF_CONFMON | ZT_CONF_CONFANNMON | ZT_CONF_REALANDPSEUDO)))
+		if (chans[y] && (chans[y]->confna == x) &&
+			((chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONF ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANN ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFMON ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANNMON ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_REALANDPSEUDO))
 			return;
 	}
 	/* If we get here, nobody is in the conference anymore.  Clear it out
@@ -1705,9 +1710,10 @@
 				chans[x]->master = chans[x];
 			}
 			if ((chans[x]->confna == chan->channo) &&
-				(((chans[x]->confmode >= ZT_CONF_MONITOR) &&
-				(chans[x]->confmode <= ZT_CONF_MONITORBOTH)) ||
-				(chans[x]->confmode == ZT_CONF_DIGITALMON))) {
+				((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_DIGITALMON)) {
 				/* Take them out of conference with us */
 				/* release conference resource if any */
 				if (chans[x]->confna) {
@@ -3912,7 +3918,9 @@
 		  /* make sure channel number makes sense */
 		if ((i < 1) || (i > ZT_MAX_CHANNELS) || (!chans[i])) return(-EINVAL);
 		if (!(chans[i]->flags & ZT_FLAG_AUDIO)) return (-EINVAL); 
-		if (stack.conf.confmode && ((stack.conf.confmode & ZT_CONF_MODE_MASK) < 4)) {
+		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) {
 			/* Monitor mode -- it's a channel */
 			if ((stack.conf.confno < 0) || (stack.conf.confno >= ZT_MAX_CHANNELS) || !chans[stack.conf.confno]) return(-EINVAL);
 		} else {
@@ -3948,17 +3956,20 @@
 		zt_check_conf(j);
 		zt_check_conf(stack.conf.confno);
 		if (chans[i]->span && chans[i]->span->dacs) {
-			if ((stack.conf.confmode == ZT_CONF_DIGITALMON) && chans[stack.conf.confno]->span &&
+			if (((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_DIGITALMON) && chans[stack.conf.confno]->span &&
 					(chans[stack.conf.confno]->span->dacs == chans[i]->span->dacs)) {
 				chans[i]->span->dacs(chans[i], chans[stack.conf.confno]);
 			} else {
 				chans[i]->span->dacs(chans[i], NULL);
 			}
 		}
-		/* k will be non-zero if in a real conf */
-		k = stack.conf.confmode & (ZT_CONF_CONF | ZT_CONF_CONFANN | ZT_CONF_CONFMON | ZT_CONF_CONFANNMON | ZT_CONF_REALANDPSEUDO);
 		/* if we are going onto a conf */
-		if (stack.conf.confno && k) {
+		if (stack.conf.confno &&
+			((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONF ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANN ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFMON ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANNMON ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_REALANDPSEUDO)) {
 			/* Get alias */
 			chans[i]->_confn = zt_get_conf_alias(stack.conf.confno);
 		}



More information about the zaptel-commits mailing list