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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 14 15:39:40 CST 2007


Author: kpfleming
Date: Fri Dec 14 15:38:35 2007
New Revision: 3487

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3487
Log:
a bunch of bug fixes found while actually testing the code (imagine that)

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

Modified: team/kpfleming/dtmf-twister/tonezone.c
URL: http://svn.digium.com/view/zaptel/team/kpfleming/dtmf-twister/tonezone.c?view=diff&rev=3487&r1=3486&r2=3487
==============================================================================
--- team/kpfleming/dtmf-twister/tonezone.c (original)
+++ team/kpfleming/dtmf-twister/tonezone.c Fri Dec 14 15:38:35 2007
@@ -204,23 +204,23 @@
 }
 
 #ifdef TONEZONE_DRIVER
-static void dump_tone_zone(void *data)
+static void dump_tone_zone(void *data, int size)
 {
 	struct zt_tone_def_header *z;
 	struct zt_tone_def *td;
 	int x;
-	int len=0;
+	int len = sizeof(*z);
+
 	z = data;
 	data += sizeof(*z);
 	printf("Header: %d tones, %d bytes of data, zone %d (%s)\n", 
-		z->count, z->size, z->zone, z->name);
-	for (x=0;x < z->count; x++) {
+		z->count, size, z->zone, z->name);
+	for (x = 0; x < z->count; x++) {
 		td = data;
-		printf("Tone Fragment %d: %d bytes, %s tone, next is %d, %d samples total\n",
-			x, td->size, tone_name(td->tone), td->next, td->samples);
+		printf("Tone Fragment %d: tone is %d, next is %d, %d samples\n",
+			x, td->tone, td->next, td->samples);
 		data += sizeof(*td);
-		data += td->size;
-		len += td->size;
+		len += sizeof(*td);
 	}
 	printf("Total measured bytes of data: %d\n", len);
 }
@@ -284,9 +284,9 @@
 			return -1;
 		}
 		td = data;
-		data += sizeof(td);
-		used += sizeof(td);
-		size -= sizeof(td);
+		data += sizeof(*td);
+		used += sizeof(*td);
+		size -= sizeof(*td);
 		td->tone = tone->tone;
 		*count += 1;
 
@@ -343,8 +343,6 @@
 		space -= res;
 	}
 
-	h->count = count;
-
 	if ((res = build_mf_tones(ptr, space, &count, dtmf_dial, z->dtmf_low_level, z->dtmf_high_level)) < 0) {
 		fprintf(stderr, "Could not build DTMF tones.\n");
 		return -1;
@@ -358,6 +356,8 @@
 	}
 	ptr += res;
 	space -= res;
+
+	h->count = count;
 
 	if (fd < 0) {
 		if ((fd = open(DEFAULT_ZT_DEV, O_RDWR)) < 0) {
@@ -372,6 +372,10 @@
 		fprintf(stderr, "ioctl(ZT_FREEZONE) failed: %s\n", strerror(errno));
 		return res;
 	}
+
+#if defined(TONEZONE_DRIVER)
+	dump_tone_zone(h, MAX_SIZE - space);
+#endif
 
 	if ((res = ioctl(fd, ZT_LOADZONE, h))) {
 		fprintf(stderr, "ioctl(ZT_LOADZONE) failed: %s\n", strerror(errno));

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=3487&r1=3486&r2=3487
==============================================================================
--- team/kpfleming/dtmf-twister/zaptel-base.c (original)
+++ team/kpfleming/dtmf-twister/zaptel-base.c Fri Dec 14 15:38:35 2007
@@ -2563,8 +2563,8 @@
 
 /* No bigger than 32k for everything per tone zone */
 #define MAX_SIZE 32768
-/* No more than 64 subtones */
-#define MAX_TONES 64
+/* No more than 128 subtones */
+#define MAX_TONES 128
 
 /* The tones to be loaded can (will) be a mix of regular tones,
    DTMF tones and MF tones. We need to load DTMF and MF tones
@@ -2643,7 +2643,7 @@
 
 		data += sizeof(td);
 
-		if ((td.tone > 0) && (td.tone < ZT_TONE_MAX)) {
+		if ((td.tone >= 0) && (td.tone < ZT_TONE_MAX)) {
 			tone_type = REGULAR_TONE;
 
 			t = samples[x] = ptr;
@@ -3633,11 +3633,13 @@
 		if ((j < 0) || (j >= ZT_TONE_ZONE_MAX))
 			return -EINVAL;
 		write_lock(&zone_lock);
+#if 0
 		if (j == default_zone) {
 			write_unlock(&zone_lock);
 			/* XXX: possibly a better return code here */
 			return -EINVAL;
 		}
+#endif
 		free_tone_zone(j);
 		write_unlock(&zone_lock);
 		break;




More information about the svn-commits mailing list