[zaptel-commits] sruffell: branch sruffell/voicebus r3946 - /team/sruffell/voicebus/kernel/

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Wed Mar 5 17:45:49 CST 2008


Author: sruffell
Date: Wed Mar  5 17:45:49 2008
New Revision: 3946

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3946
Log:
Add a printk warning if a request to generate a tone comes in before a tone
zone is loaded.

Modified:
    team/sruffell/voicebus/kernel/zaptel-base.c

Modified: team/sruffell/voicebus/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/sruffell/voicebus/kernel/zaptel-base.c?view=diff&rev=3946&r1=3945&r2=3946
==============================================================================
--- team/sruffell/voicebus/kernel/zaptel-base.c (original)
+++ team/sruffell/voicebus/kernel/zaptel-base.c Wed Mar  5 17:45:49 2008
@@ -1141,29 +1141,32 @@
 	if (tone == -1) {
 		/* Just stop the current tone */
 		res = 0;
+	} else if (!chan->curzone) {
+		static int __warnonce = 1;
+		if (__warnonce) {
+			/* The tonezones are loaded by ztcfg based on /etc/zaptel.conf. */
+			printk(KERN_WARNING "zaptel: Cannot start tones until tone zone is loaded.\n");
+			__warnonce = 0;
+		}
+		/* Note that no tone zone exists at the moment */
+		res = -ENODATA;
 	} else if ((tone >= 0 && tone <= ZT_TONE_MAX)) {
-		if (chan->curzone) {
-			/* Have a tone zone */
-			if (chan->curzone->tones[tone]) {
-				chan->curtone = chan->curzone->tones[tone];
-				res = 0;
-			} else	/* Indicate that zone is loaded but no such tone exists */
-				res = -ENOSYS;
-		} else	/* Note that no tone zone exists at the moment */
-			res = -ENODATA;
+		/* Have a tone zone */
+		if (chan->curzone->tones[tone]) {
+			chan->curtone = chan->curzone->tones[tone];
+			res = 0;
+		} else { /* Indicate that zone is loaded but no such tone exists */
+			res = -ENOSYS;
+		}
 	} else if (tone >= ZT_TONE_DTMF_BASE && tone <= ZT_TONE_DTMF_MAX) {
 		/* ZT_SENDTONE should never be used on a channel configured for pulse dialing */
 		chan->dialing = 1;
 		res = 0;
-		if ((chan->digitmode == DIGIT_MODE_DTMF) &&
-		    (tone >= ZT_TONE_DTMF_BASE) &&
-		    (tone <= ZT_TONE_DTMF_MAX))
+		if (chan->digitmode == DIGIT_MODE_DTMF) {
 			chan->curtone = &chan->curzone->dtmf_continuous[tone - ZT_TONE_DTMF_BASE];
-		else if ((chan->digitmode == DIGIT_MODE_MFV1) &&
-			 (tone >= ZT_TONE_MF_BASE) &&
-			 (tone <= ZT_TONE_MF_MAX))
+		} else if (chan->digitmode == DIGIT_MODE_MFV1) {
 			chan->curtone = &chan->curzone->mf_continuous[tone - ZT_TONE_MF_BASE];
-		else {
+		} else {
 			chan->dialing = 0;
 			res = -EINVAL;
 		}




More information about the zaptel-commits mailing list