[svn-commits] russell: branch group/vldtmf r1267 - in /team/group/vldtmf: zaptel.c zaptel.h

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Aug 8 20:42:40 MST 2006


Author: russell
Date: Tue Aug  8 22:42:39 2006
New Revision: 1267

URL: http://svn.digium.com/view/zaptel?rev=1267&view=rev
Log:
allow the ZT_SENDTONE ioctl to be used to starting/ending DTMF on a channel

Modified:
    team/group/vldtmf/zaptel.c
    team/group/vldtmf/zaptel.h

Modified: team/group/vldtmf/zaptel.c
URL: http://svn.digium.com/view/zaptel/team/group/vldtmf/zaptel.c?rev=1267&r1=1266&r2=1267&view=diff
==============================================================================
--- team/group/vldtmf/zaptel.c (original)
+++ team/group/vldtmf/zaptel.c Tue Aug  8 22:42:39 2006
@@ -1104,28 +1104,35 @@
 static int start_tone(struct zt_chan *chan, int tone)
 {
 	int res = -EINVAL;
+
 	/* Stop the current tone, no matter what */
 	chan->tonep = 0;
 	chan->curtone = NULL;
 	chan->pdialcount = 0;
 	chan->txdialbuf[0] = '\0';
 	chan->dialing =  0;
-	if ((tone >= ZT_TONE_MAX) || (tone < -1)) 
-		return -EINVAL;
-	/* Just wanted to stop the tone anyway */
-	if (tone < 0)
-		return 0;
-	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;
+
+	if (tone == -1) {
+		/* Just stop the current tone */
+		res = 0;
+	} 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;
+	} else if (tone >= ZT_TONE_DTMF_BASE && tone <= ZT_TONE_DTMF_MAX) {
+		chan->curtone = &dtmf_tones[tone - ZT_TONE_DTMF_BASE];
+		res = 0;
+	}
+
 	if (chan->curtone)
 		zt_init_tone_state(&chan->ts, chan->curtone);
+	
 	return res;
 }
 

Modified: team/group/vldtmf/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/group/vldtmf/zaptel.h?rev=1267&r1=1266&r2=1267&view=diff
==============================================================================
--- team/group/vldtmf/zaptel.h (original)
+++ team/group/vldtmf/zaptel.h Tue Aug  8 22:42:39 2006
@@ -667,6 +667,32 @@
 #define ZT_TONE_CUST2		9
 #define ZT_TONE_STUTTER		10
 #define ZT_TONE_MAX		16
+
+#define ZT_TONE_DTMF_BASE	64
+
+/*
+ * These must be in the same order as the dtmf_tones array in tones.h 
+ */
+enum {
+	ZT_TONE_DTMF_0 = ZT_TONE_DTMF_BASE,
+	ZT_TONE_DTMF_1,
+	ZT_TONE_DTMF_2,
+	ZT_TONE_DTMF_3,
+	ZT_TONE_DTMF_4,
+	ZT_TONE_DTMF_5,
+	ZT_TONE_DTMF_6,
+	ZT_TONE_DTMF_7,
+	ZT_TONE_DTMF_8,
+	ZT_TONE_DTMF_9,
+	ZT_TONE_DTMF_s,
+	ZT_TONE_DTMF_p,
+	ZT_TONE_DTMF_A,
+	ZT_TONE_DTMF_B,
+	ZT_TONE_DTMF_C,
+	ZT_TONE_DTMF_D
+};
+
+#define ZT_TONE_DTMF_MAX ZT_TONE_DTMF_D
 
 #define ZT_MAX_CADENCE		16
 



More information about the svn-commits mailing list