[asterisk-commits] russell: branch russell/indications r174542 - /team/russell/indications/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 10 09:15:31 CST 2009


Author: russell
Date: Tue Feb 10 09:15:31 2009
New Revision: 174542

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174542
Log:
minor tweaks ..

Modified:
    team/russell/indications/main/indications.c

Modified: team/russell/indications/main/indications.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/indications/main/indications.c?view=diff&rev=174542&r1=174541&r2=174542
==============================================================================
--- team/russell/indications/main/indications.c (original)
+++ team/russell/indications/main/indications.c Tue Feb 10 09:15:31 2009
@@ -238,7 +238,7 @@
 		ps->oldnpos = ps->npos;
 	}
 
-	for (x = 0; x < len/2; x++) {
+	for (x = 0; x < len / 2; x++) {
 		ps->v1_1 = ps->v2_1;
 		ps->v2_1 = ps->v3_1;
 		ps->v3_1 = (pi->fac1 * ps->v2_1 >> 15) - ps->v1_1;
@@ -355,6 +355,8 @@
 	struct playtones_def d = { vol, -1, 0, 1, NULL };
 	char *stringp;
 	char *separator;
+	static const float sample_rate = 8000.0;
+	static const float max_sample_val = 32768.0;
 
 	if (vol < 1) {
 		d.vol = 7219; /* Default to -8db */
@@ -410,15 +412,17 @@
 			return -1;
 		}
 
-		d.items[d.nitems].fac1 = 2.0 * cos(2.0 * M_PI * (tone_data.freq1 / 8000.0)) * 32768.0;
-		d.items[d.nitems].init_v2_1 = sin(-4.0 * M_PI * (tone_data.freq1 / 8000.0)) * d.vol;
-		d.items[d.nitems].init_v3_1 = sin(-2.0 * M_PI * (tone_data.freq1 / 8000.0)) * d.vol;
-
-		d.items[d.nitems].fac2 = 2.0 * cos(2.0 * M_PI * (tone_data.freq2 / 8000.0)) * 32768.0;
-		d.items[d.nitems].init_v2_2 = sin(-4.0 * M_PI * (tone_data.freq2 / 8000.0)) * d.vol;
-		d.items[d.nitems].init_v3_2 = sin(-2.0 * M_PI * (tone_data.freq2 / 8000.0)) * d.vol;
+		d.items[d.nitems].fac1 = 2.0 * cos(2.0 * M_PI * (tone_data.freq1 / sample_rate)) * max_sample_val;
+		d.items[d.nitems].init_v2_1 = sin(-4.0 * M_PI * (tone_data.freq1 / sample_rate)) * d.vol;
+		d.items[d.nitems].init_v3_1 = sin(-2.0 * M_PI * (tone_data.freq1 / sample_rate)) * d.vol;
+
+		d.items[d.nitems].fac2 = 2.0 * cos(2.0 * M_PI * (tone_data.freq2 / sample_rate)) * max_sample_val;
+		d.items[d.nitems].init_v2_2 = sin(-4.0 * M_PI * (tone_data.freq2 / sample_rate)) * d.vol;
+		d.items[d.nitems].init_v3_2 = sin(-2.0 * M_PI * (tone_data.freq2 / sample_rate)) * d.vol;
+
 		d.items[d.nitems].duration = tone_data.time;
 		d.items[d.nitems].modulate = tone_data.modulate;
+
 		d.nitems++;
 	}
 
@@ -435,8 +439,6 @@
 	ast_deactivate_generator(chan);
 }
 
-/*--------------------------------------------*/
-
 struct ao2_iterator ast_tone_zone_iterator_init(void)
 {
 	return ao2_iterator_init(ast_tone_zones, 0);
@@ -449,7 +451,7 @@
 
 	/* If no country is specified or we are unable to find the zone, then return not found */
 	if (ast_strlen_zero(country) || !(zone = ast_get_indication_zone(country))) {
-		return 1;
+		return -1;
 	}
 
 	ast_verb(3, "Setting default indication country to '%s'\n", country);
@@ -513,7 +515,6 @@
 
 	/* Look through list of tones in the zone searching for the right one */
 	AST_LIST_TRAVERSE(&zone->tones, ts, entry) {
-		/* XXX THE TONE ZONE SOUNDS NEED TO BE REF COUNTED TOO! */
 		if (!strcasecmp(ts->name, indication)) {
 			break;
 		}
@@ -555,8 +556,6 @@
 		zone->ringcadence = NULL;
 	}
 }
-
-/*--------------------------------------------*/
 
 /* add a new country, if country exists, it will be replaced. */
 static int ast_register_indication_country(struct ast_tone_zone *zone)




More information about the asterisk-commits mailing list