[Asterisk-cvs] asterisk asterisk.c, 1.116, 1.117 channel.c, 1.133, 1.134

markster at lists.digium.com markster at lists.digium.com
Thu Aug 26 22:28:53 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv21947

Modified Files:
	asterisk.c channel.c 
Log Message:
Run generators from zap timers when available so as to interop with VAD


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- asterisk.c	22 Aug 2004 18:33:19 -0000	1.116
+++ asterisk.c	27 Aug 2004 03:28:32 -0000	1.117
@@ -3,9 +3,9 @@
  *
  * Top level source file for asterisk
  * 
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
  *
- * Mark Spencer <markster at linux-support.net>
+ * Mark Spencer <markster at digium.com>
  *
  * This program is free software, distributed under the terms of
  * the GNU General Public License

Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- channel.c	26 Aug 2004 22:45:26 -0000	1.133
+++ channel.c	27 Aug 2004 03:28:32 -0000	1.134
@@ -3,9 +3,9 @@
  *
  * Channel Management
  * 
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
  *
- * Mark Spencer <markster at linux-support.net>
+ * Mark Spencer <markster at digium.com>
  *
  * This program is free software, distributed under the terms of
  * the GNU General Public License
@@ -816,10 +816,30 @@
 		chan->generatordata = NULL;
 		chan->generator = NULL;
 		chan->writeinterrupt = 0;
+		ast_settimeout(chan, 0, NULL, NULL);
 	}
 	ast_mutex_unlock(&chan->lock);
 }
 
+static int generator_force(void *data)
+{
+	/* Called if generator doesn't have data */
+	void *tmp;
+	int res;
+	int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples);
+	struct ast_channel *chan = data;
+	tmp = chan->generatordata;
+	chan->generatordata = NULL;
+	generate = chan->generator->generate;
+	res = generate(chan, tmp, 0, 160);
+	chan->generatordata = tmp;
+	if (res) {
+		ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+		ast_deactivate_generator(chan);
+	}
+	return 0;
+}
+
 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
 {
 	int res = 0;
@@ -831,6 +851,7 @@
 	}
 	ast_prod(chan);
 	if ((chan->generatordata = gen->alloc(chan, params))) {
+		ast_settimeout(chan, 160, generator_force, chan);
 		chan->generator = gen;
 	} else {
 		res = -1;
@@ -1338,8 +1359,9 @@
 	} 
 
 	/* Run any generator sitting on the line */
-	if (f && (f->frametype == AST_FRAME_VOICE) && chan->generatordata) {
-		/* Mask generator data temporarily */
+	if (f && (f->frametype == AST_FRAME_VOICE) && chan->generatordata && !chan->timingfunc) {
+		/* Mask generator data temporarily and apply.  If there is a timing function, it
+		   will be calling the generator instead */
 		void *tmp;
 		int res;
 		int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples);




More information about the svn-commits mailing list