[asterisk-commits] file: trunk r54528 - /trunk/apps/app_milliwatt.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Feb 14 18:52:11 MST 2007


Author: file
Date: Wed Feb 14 19:52:10 2007
New Revision: 54528

URL: http://svn.digium.com/view/asterisk?view=rev&rev=54528
Log:
Clean up app_milliwatt code.

Modified:
    trunk/apps/app_milliwatt.c

Modified: trunk/apps/app_milliwatt.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_milliwatt.c?view=diff&rev=54528&r1=54527&r2=54528
==============================================================================
--- trunk/apps/app_milliwatt.c (original)
+++ trunk/apps/app_milliwatt.c Wed Feb 14 19:52:10 2007
@@ -50,7 +50,6 @@
 static char *descrip = 
 "Milliwatt(): Generate a Constant 1000Hz tone at 0dbm (mu-law)\n";
 
-
 static char digital_milliwatt[] = {0x1e,0x0b,0x0b,0x1e,0x9e,0x8b,0x8b,0x9e} ;
 
 static void *milliwatt_alloc(struct ast_channel *chan, void *params)
@@ -82,7 +81,6 @@
 	* a multiple of samples, given by number of samples times bytes per
 	* sample. In the case of ulaw, len = samples. for signed linear
 	* len = 2 * samples */
-
 	if (samples > maxsamples) {
 		ast_log(LOG_WARNING, "Only doing %d samples (%d requested)\n", maxsamples, samples);
 		samples = maxsamples;
@@ -90,17 +88,18 @@
 	len = samples * sizeof (buf[0]);
 	wf.datalen = len;
 	wf.samples = samples;
+
 	/* create a buffer containing the digital milliwatt pattern */
-	for(i = 0; i < len; i++)
-	{
+	for (i = 0; i < len; i++) {
 		buf[AST_FRIENDLY_OFFSET + i] = digital_milliwatt[(*indexp)++];
 		*indexp &= 7;
 	}
-	if (ast_write(chan,&wf) < 0)
-	{
+
+	if (ast_write(chan,&wf) < 0) {
 		ast_log(LOG_WARNING,"Failed to write frame to '%s': %s\n",chan->name,strerror(errno));
 		return -1;
 	}
+
 	return 0;
 }
 
@@ -109,28 +108,33 @@
 	alloc: milliwatt_alloc,
 	release: milliwatt_release,
 	generate: milliwatt_generate,
-} ;
+};
 
 static int milliwatt_exec(struct ast_channel *chan, void *data)
 {
 
 	struct ast_module_user *u;
 	u = ast_module_user_add(chan);
+
 	ast_set_write_format(chan, AST_FORMAT_ULAW);
 	ast_set_read_format(chan, AST_FORMAT_ULAW);
+
+
 	if (chan->_state != AST_STATE_UP)
-	{
 		ast_answer(chan);
-	}
-	if (ast_activate_generator(chan,&milliwattgen,"milliwatt") < 0)
-	{
+
+	if (ast_activate_generator(chan,&milliwattgen,"milliwatt") < 0) {
 		ast_log(LOG_WARNING,"Failed to activate generator on '%s'\n",chan->name);
 		ast_module_user_remove(u);
 		return -1;
 	}
+
 	while(!ast_safe_sleep(chan, 10000));
+
 	ast_deactivate_generator(chan);
+
 	ast_module_user_remove(u);
+
 	return -1;
 }
 



More information about the asterisk-commits mailing list