[svn-commits] kpfleming: branch kpfleming/dtmf-twister r3489 - /team/kpfleming/dtmf-twister/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 14 17:36:21 CST 2007


Author: kpfleming
Date: Fri Dec 14 17:36:20 2007
New Revision: 3489

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3489
Log:
store the global dial parameters in a structure intended for that purpose, instead of trying to just store/retrieve them from a default zone's DTMF/MF tones (which may not exist)

Modified:
    team/kpfleming/dtmf-twister/zaptel-base.c

Modified: team/kpfleming/dtmf-twister/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/kpfleming/dtmf-twister/zaptel-base.c?view=diff&rev=3489&r1=3488&r2=3489
==============================================================================
--- team/kpfleming/dtmf-twister/zaptel-base.c (original)
+++ team/kpfleming/dtmf-twister/zaptel-base.c Fri Dec 14 17:36:20 2007
@@ -302,6 +302,11 @@
 #define DIGIT_MODE_PULSE	2
 
 #include "digits.h"
+
+static struct zt_dialparams global_dialparams = {
+	.dtmf_tonelen = DEFAULT_DTMF_LENGTH,
+	.mfv1_tonelen = DEFAULT_MFV1_LENGTH,
+};
 
 static int zt_chan_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data, int unit);
 
@@ -2585,8 +2590,6 @@
 	size_t space;
 	size_t size;
 	int res;
-	int dtmf_length = DEFAULT_DTMF_LENGTH;
-	int mf_length = DEFAULT_MFV1_LENGTH;
 	
 	if (copy_from_user(&th, (struct zt_tone_def_header *) data, sizeof(th)))
 		return -EFAULT;
@@ -2615,13 +2618,6 @@
 
 	for (x = 0; x < ZT_MAX_CADENCE; x++)
 		z->ringcadence[x] = th.ringcadence[x];
-
-	/* if the DTMF and/or MF tone lengths have been adjusted via SET_DIALPARAMS,
-	   respect that for tones in this zone as well */
-	if (default_zone) {
-		dtmf_length = tone_zones[default_zone]->dtmf[0].tonesamples;
-		mf_length = tone_zones[default_zone]->mf[0].tonesamples;
-	}
 
 	for (x = 0; x < th.count; x++) {
 		enum {
@@ -2693,13 +2689,13 @@
 				z->tones[td.tone] = t;
 			break;
 		case DTMF_TONE:
-			t->tonesamples = dtmf_length;
+			t->tonesamples = global_dialparams.dtmf_tonelen;
 			t->next = &dtmf_silence;
 			z->dtmf_continuous[td.tone] = *t;
 			z->dtmf_continuous[td.tone].next = &z->dtmf_continuous[td.tone];
 			break;
 		case MF_TONE:
-			t->tonesamples = mf_length;
+			t->tonesamples = global_dialparams.mfv1_tonelen;
 			t->next = &mfv1_silence;
 			/* Special case for K/P tone */
 			if (td.tone == 10)
@@ -3651,6 +3647,8 @@
 		if ((tdp.mfv1_tonelen > 4000) || (tdp.mfv1_tonelen < 10))
 			return -EINVAL;
 
+		global_dialparams = tdp;
+
 		/* update the lengths in all currently loaded zones */
 		write_lock(&zone_lock);
 		for (j = 0; j < sizeof(tone_zones) / sizeof(tone_zones[0]); j++) {
@@ -3675,12 +3673,7 @@
 
 		break;
 	case ZT_GET_DIALPARAMS:
-		tdp.dtmf_tonelen = tone_zones[default_zone]->dtmf[0].tonesamples / ZT_CHUNKSIZE;
-		tdp.mfv1_tonelen = tone_zones[default_zone]->mf[0].tonesamples / ZT_CHUNKSIZE;
-		tdp.reserved[0] = 0;
-		tdp.reserved[1] = 0;
-		tdp.reserved[2] = 0;
-		tdp.reserved[3] = 0;
+		tdp = global_dialparams;
 		if (copy_to_user((struct zt_dialparams *) data, &tdp, sizeof(tdp)))
 			return -EFAULT;
 		break;




More information about the svn-commits mailing list