[asterisk-commits] jrose: branch jrose/volume-branch r309336 - /team/jrose/volume-branch/funcs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 2 15:59:25 CST 2011


Author: jrose
Date: Wed Mar  2 15:59:21 2011
New Revision: 309336

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=309336
Log:
Changes as suggested by David Vossel

Modified:
    team/jrose/volume-branch/funcs/func_volume.c

Modified: team/jrose/volume-branch/funcs/func_volume.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/volume-branch/funcs/func_volume.c?view=diff&rev=309336&r1=309335&r2=309336
==============================================================================
--- team/jrose/volume-branch/funcs/func_volume.c (original)
+++ team/jrose/volume-branch/funcs/func_volume.c Wed Mar  2 15:59:21 2011
@@ -68,11 +68,6 @@
     VOLUMEFLAG_CHANGE = (1 << 1),
 };
 
-enum volume_args {
-    OPT_ARG_TXRX = 0,
-    OPT_ARG_ARRAY_SIZE,
-};
-
 AST_APP_OPTIONS(volume_opts, {
 	AST_APP_OPTION('p', VOLUMEFLAG_CHANGE),
 
@@ -115,23 +110,20 @@
 
 	/* If this is DTMF then allow them to increase/decrease the gains */
 
-    if (ast_test_flag(vi, VOLUMEFLAG_CHANGE)) {
-        if (frame->frametype == AST_FRAME_DTMF) {
-            /* Only use DTMF coming from the source... not going to it */
-            if (direction != AST_AUDIOHOOK_DIRECTION_READ)
-                return 0;
-            if (frame->subclass.integer == '*') {
-                vi->tx_gain += 1;
-                vi->rx_gain += 1;
-            } else if (frame->subclass.integer == '#') {
-                vi->tx_gain -= 1;
-                vi->rx_gain -= 1;
-            }
-        }
-	}
-
-
-
+	if (ast_test_flag(vi, VOLUMEFLAG_CHANGE)) {
+		if (frame->frametype == AST_FRAME_DTMF) {
+		/* Only use DTMF coming from the source... not going to it */
+		if (direction != AST_AUDIOHOOK_DIRECTION_READ) { return 0; } 
+		if (frame->subclass.integer == '*') {
+			vi->tx_gain += 1;
+			vi->rx_gain += 1;
+		} else if (frame->subclass.integer == '#') {
+			vi->tx_gain -= 1;
+			vi->rx_gain -= 1;
+			}
+		}
+	}
+	
 	if (frame->frametype == AST_FRAME_VOICE) {
 		/* Based on direction of frame grab the gain, and confirm it is applicable */
 		if (!(gain = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? &vi->rx_gain : &vi->tx_gain) || !*gain)
@@ -139,7 +131,7 @@
 		/* Apply gain to frame... easy as pi */
 		ast_frame_adjust_volume(frame, *gain);
 	}
-
+	
 	return 0;
 }
 
@@ -150,10 +142,15 @@
 	int is_new = 0;
 
 	/* Separate options from argument */
-	char* opts;
-	opts = strchr(data, ',');
-	if (opts)
-        *opts++ = '\0';
+	
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(direction);
+		AST_APP_ARG(options);
+	);
+	
+	AST_STANDARD_APP_ARGS(args, data);
+	
+	ast_verb(2, "direction: %s\n  == options: %s\n", args.direction, args.options);
 
 	if (!(datastore = ast_channel_datastore_find(chan, &volume_datastore, NULL))) {
 		/* Allocate a new datastore to hold the reference to this volume and audiohook information */
@@ -172,12 +169,11 @@
 	}
 
 	/* Adjust gain on volume information structure */
-
-	if (!strcasecmp(data, "tx"))
-		vi->tx_gain = atoi(value);
-
-	else if (!strcasecmp(data, "rx"))
+	if (!strcasecmp(args.direction, "tx")) {
+		vi->tx_gain = atoi(value); 
+	} else if (!strcasecmp(args.direction, "rx")) {
 		vi->rx_gain = atoi(value);
+	}
 
 	if (is_new) {
 		datastore->data = vi;
@@ -186,18 +182,11 @@
 	}
 
 	/* Add Option data to struct */
-
-	AST_DECLARE_APP_ARGS(args,
-
-						 AST_APP_ARG(options);
-    );
-
-    AST_STANDARD_APP_ARGS(args, opts);
-
-	if (!ast_strlen_zero(opts)) {
-	    struct ast_flags flags = { 0 };
-        ast_app_parse_options(volume_opts, &flags, &opts, args.options);
-        vi->flags = flags.flags;
+	
+	if (!ast_strlen_zero(args.direction)) {
+		struct ast_flags flags = { 0 };
+		ast_app_parse_options(volume_opts, &flags, &data, args.options);
+		vi->flags = flags.flags;
 	}
 	else { vi->flags = 0; }
 




More information about the asterisk-commits mailing list