[asterisk-commits] jrose: branch jrose/volume-branch r309128 - in /team/jrose/volume-branch: ./ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 1 13:15:08 CST 2011


Author: jrose
Date: Tue Mar  1 13:15:04 2011
New Revision: 309128

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=309128
Log:
First attempt at Volume Fix

Modified:
    team/jrose/volume-branch/   (props changed)
    team/jrose/volume-branch/funcs/func_volume.c

Propchange: team/jrose/volume-branch/
------------------------------------------------------------------------------
    automerge-email = jrose at digium.com

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=309128&r1=309127&r2=309128
==============================================================================
--- team/jrose/volume-branch/funcs/func_volume.c (original)
+++ team/jrose/volume-branch/funcs/func_volume.c Tue Mar  1 13:15:04 2011
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2007, Digium, Inc.
  *
- * Joshua Colp <jcolp at digium.com> 
+ * Joshua Colp <jcolp at digium.com>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -20,7 +20,7 @@
  *
  * \brief Technology independent volume control
  *
- * \author Joshua Colp <jcolp at digium.com> 
+ * \author Joshua Colp <jcolp at digium.com>
  *
  * \ingroup functions
  *
@@ -35,6 +35,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/utils.h"
 #include "asterisk/audiohook.h"
+#include "asterisk/app.h"
 
 /*** DOCUMENTATION
 	<function name="VOLUME" language="en_US">
@@ -60,7 +61,23 @@
 	struct ast_audiohook audiohook;
 	int tx_gain;
 	int rx_gain;
-};
+	unsigned int flags;
+};
+
+enum volume_flags {
+    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),
+
+});
+
 
 static void destroy_callback(void *data)
 {
@@ -85,6 +102,7 @@
 	struct volume_information *vi = NULL;
 	int *gain = NULL;
 
+
 	/* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
 	if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE)
 		return 0;
@@ -96,18 +114,25 @@
 	vi = datastore->data;
 
 	/* If this is DTMF then allow them to increase/decrease the gains */
-	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;
-		}
-	} else if (frame->frametype == AST_FRAME_VOICE) {
+
+    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)
 			return 0;
@@ -123,6 +148,12 @@
 	struct ast_datastore *datastore = NULL;
 	struct volume_information *vi = NULL;
 	int is_new = 0;
+
+	/* Separate options from argument */
+	char* opts;
+	opts = strchr(data, ',');
+	if (opts)
+        *opts++ = '\0';
 
 	if (!(datastore = ast_channel_datastore_find(chan, &volume_datastore, NULL))) {
 		/* Allocate a new datastore to hold the reference to this volume and audiohook information */
@@ -141,8 +172,10 @@
 	}
 
 	/* Adjust gain on volume information structure */
+
 	if (!strcasecmp(data, "tx"))
 		vi->tx_gain = atoi(value);
+
 	else if (!strcasecmp(data, "rx"))
 		vi->rx_gain = atoi(value);
 
@@ -152,6 +185,22 @@
 		ast_audiohook_attach(chan, &vi->audiohook);
 	}
 
+	/* 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;
+	}
+	else { vi->flags = 0; }
+
 	return 0;
 }
 




More information about the asterisk-commits mailing list