[asterisk-commits] branch oej/jitterbuffer r17900 - in /team/oej/jitterbuffer: ./ apps/ configs/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Apr 6 09:37:49 MST 2006


Author: oej
Date: Thu Apr  6 11:37:39 2006
New Revision: 17900

URL: http://svn.digium.com/view/asterisk?rev=17900&view=rev
Log:
resolve, reset, go

Modified:
    team/oej/jitterbuffer/   (props changed)
    team/oej/jitterbuffer/apps/app_cdr.c
    team/oej/jitterbuffer/cdr.c
    team/oej/jitterbuffer/channel.c
    team/oej/jitterbuffer/config.c
    team/oej/jitterbuffer/configs/extensions.conf.sample
    team/oej/jitterbuffer/configs/iax.conf.sample
    team/oej/jitterbuffer/configs/meetme.conf.sample
    team/oej/jitterbuffer/configs/mgcp.conf.sample
    team/oej/jitterbuffer/configs/queues.conf.sample
    team/oej/jitterbuffer/configs/sip.conf.sample
    team/oej/jitterbuffer/configs/skinny.conf.sample
    team/oej/jitterbuffer/configs/voicemail.conf.sample
    team/oej/jitterbuffer/file.c
    team/oej/jitterbuffer/formats/Makefile
    team/oej/jitterbuffer/res/res_agi.c
    team/oej/jitterbuffer/res/res_monitor.c
    team/oej/jitterbuffer/sched.c

Propchange: team/oej/jitterbuffer/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/jitterbuffer/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Apr  6 11:37:39 2006
@@ -1,1 +1,1 @@
-/trunk:1-17844
+/trunk:1-17899

Modified: team/oej/jitterbuffer/apps/app_cdr.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer/apps/app_cdr.c?rev=17900&r1=17899&r2=17900&view=diff
==============================================================================
--- team/oej/jitterbuffer/apps/app_cdr.c (original)
+++ team/oej/jitterbuffer/apps/app_cdr.c Thu Apr  6 11:37:39 2006
@@ -28,6 +28,8 @@
 #include <sys/types.h>
 #include <stdlib.h>
 
+#define STATIC_MODULE
+
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -35,9 +37,6 @@
 #include "asterisk/channel.h"
 #include "asterisk/module.h"
 #include "asterisk/pbx.h"
-
-
-static char *tdesc = "Tell Asterisk to not maintain a CDR for the current call";
 
 static char *nocdr_descrip = 
 "  NoCDR(): This application will tell Asterisk not to maintain a CDR for the\n"
@@ -64,7 +63,7 @@
 	return 0;
 }
 
-int unload_module(void)
+STATIC_MODULE int unload_module(void)
 {
 	int res;
 
@@ -75,24 +74,26 @@
 	return res;
 }
 
-int load_module(void)
+STATIC_MODULE int load_module(void)
 {
 	return ast_register_application(nocdr_app, nocdr_exec, nocdr_synopsis, nocdr_descrip);
 }
 
-char *description(void)
+STATIC_MODULE char *description(void)
 {
-	return tdesc;
+	return "Tell Asterisk to not maintain a CDR for the current call";
 }
 
-int usecount(void)
+STATIC_MODULE int usecount(void)
 {
 	int res;
 	STANDARD_USECOUNT(res);
 	return res;
 }
 
-char *key()
+STATIC_MODULE char *key(void)
 {
 	return ASTERISK_GPL_KEY;
 }
+
+STD_MOD(MOD_1, NULL, NULL, NULL);

Modified: team/oej/jitterbuffer/cdr.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer/cdr.c?rev=17900&r1=17899&r2=17900&view=diff
==============================================================================
--- team/oej/jitterbuffer/cdr.c (original)
+++ team/oej/jitterbuffer/cdr.c Thu Apr  6 11:37:39 2006
@@ -167,11 +167,10 @@
 */
 struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr) 
 {
-	struct ast_cdr *newcdr;
-
-	if (!(newcdr = ast_cdr_alloc())) {
+	struct ast_cdr *newcdr = ast_cdr_alloc();
+
+	if (!newcdr)
 		return NULL;
-	}
 
 	memcpy(newcdr, cdr, sizeof(*newcdr));
 	/* The varshead is unusable, volatile even, after the memcpy so we take care of that here */
@@ -184,31 +183,38 @@
 
 static const char *ast_cdr_getvar_internal(struct ast_cdr *cdr, const char *name, int recur) 
 {
-	struct ast_var_t *variables;
-	struct varshead *headp;
-
 	if (ast_strlen_zero(name))
 		return NULL;
 
-	while (cdr) {
-		headp = &cdr->varshead;
+	for (; cdr; cdr = recur ? cdr->next : NULL) {
+		struct ast_var_t *variables;
+		struct varshead *headp = &cdr->varshead;
 		AST_LIST_TRAVERSE(headp, variables, entries) {
 			if (!strcasecmp(name, ast_var_name(variables)))
 				return ast_var_value(variables);
 		}
-		if (!recur)
-			break;
-		cdr = cdr->next;
 	}
 
 	return NULL;
+}
+
+static void cdr_get_tv(struct timeval tv, const char *fmt, char *buf, int bufsize)
+{
+	if (fmt == NULL) {	/* raw mode */
+		snprintf(buf, bufsize, "%ld.%06ld", (long)tv.tv_sec, (long)tv.tv_usec);
+	} else {  
+		time_t t = tv.tv_sec;
+		if (t) {
+			struct tm tm;
+			localtime_r(&t, &tm);
+			strftime(buf, bufsize, fmt, &tm);
+		}
+	}
 }
 
 /*! CDR channel variable retrieval */
 void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw) 
 {
-	struct tm tm;
-	time_t t;
 	const char *fmt = "%Y-%m-%d %T";
 	const char *varbuf;
 
@@ -232,37 +238,13 @@
 		ast_copy_string(workspace, cdr->lastapp, workspacelen);
 	else if (!strcasecmp(name, "lastdata"))
 		ast_copy_string(workspace, cdr->lastdata, workspacelen);
-	else if (!strcasecmp(name, "start")) {
-		if (raw) {
-			snprintf(workspace, workspacelen, "%ld.%06ld", (long)cdr->start.tv_sec, (long)cdr->start.tv_usec);
-		} else {
-			t = cdr->start.tv_sec;
-			if (t) {
-				localtime_r(&t, &tm);
-				strftime(workspace, workspacelen, fmt, &tm);
-			}
-		}
-	} else if (!strcasecmp(name, "answer")) {
-		if (raw) {
-			snprintf(workspace, workspacelen, "%ld.%06ld", (long)cdr->answer.tv_sec, (long)cdr->answer.tv_usec);
-		} else {
-			t = cdr->answer.tv_sec;
-			if (t) {
-				localtime_r(&t, &tm);
-				strftime(workspace, workspacelen, fmt, &tm);
-			}
-		}
-	} else if (!strcasecmp(name, "end")) {
-		if (raw) {
-			snprintf(workspace, workspacelen, "%ld.%06ld", (long)cdr->end.tv_sec, (long)cdr->end.tv_usec);
-		} else {
-			t = cdr->end.tv_sec;
-			if (t) {
-				localtime_r(&t, &tm);
-				strftime(workspace, workspacelen, fmt, &tm);
-			}
-		}
-	} else if (!strcasecmp(name, "duration"))
+	else if (!strcasecmp(name, "start"))
+		cdr_get_tv(cdr->start, raw ? NULL : fmt, workspace, workspacelen);
+	else if (!strcasecmp(name, "answer"))
+		cdr_get_tv(cdr->answer, raw ? NULL : fmt, workspace, workspacelen);
+	else if (!strcasecmp(name, "end"))
+		cdr_get_tv(cdr->end, raw ? NULL : fmt, workspace, workspacelen);
+	else if (!strcasecmp(name, "duration"))
 		snprintf(workspace, workspacelen, "%ld", cdr->duration);
 	else if (!strcasecmp(name, "billsec"))
 		snprintf(workspace, workspacelen, "%ld", cdr->billsec);
@@ -317,7 +299,7 @@
 		return -1;
 	}
 
-	while (cdr) {
+	for (; cdr; cdr = recur ? cdr->next : NULL) {
 		headp = &cdr->varshead;
 		AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) {
 			if (!strcasecmp(ast_var_name(newvariable), name)) {
@@ -333,12 +315,6 @@
 			newvariable = ast_var_assign(name, value);
 			AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 		}
-
-		if (!recur) {
-			break;
-		}
-
-		cdr = cdr->next;
 	}
 
 	return 0;
@@ -413,33 +389,36 @@
 
 void ast_cdr_free_vars(struct ast_cdr *cdr, int recur)
 {
-	struct varshead *headp;
-	struct ast_var_t *vardata;
 
 	/* clear variables */
+	for (; cdr; cdr = recur ? cdr->next : NULL) {
+		struct ast_var_t *vardata;
+		struct varshead *headp = &cdr->varshead;
+		while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
+			ast_var_delete(vardata);
+	}
+}
+
+/*! \brief  print a warning if cdr already posted */
+static void check_post(struct ast_cdr *cdr)
+{
+	if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
+		ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", S_OR(cdr->channel, "<unknown>"));
+}
+
+/*! \brief  print a warning if cdr already started */
+static void check_start(struct ast_cdr *cdr)
+{
+	if (!ast_tvzero(cdr->start))
+		ast_log(LOG_WARNING, "CDR on channel '%s' already started\n", S_OR(cdr->channel, "<unknown>"));
+}
+
+void ast_cdr_free(struct ast_cdr *cdr)
+{
+
 	while (cdr) {
-		headp = &cdr->varshead;
-		while (!AST_LIST_EMPTY(headp)) {
-			vardata = AST_LIST_REMOVE_HEAD(headp, entries);
-			ast_var_delete(vardata);
-		}
-
-		if (!recur) {
-			break;
-		}
-
-		cdr = cdr->next;
-	}
-}
-
-void ast_cdr_free(struct ast_cdr *cdr)
-{
-	char *chan;
-	struct ast_cdr *next; 
-
-	while (cdr) {
-		next = cdr->next;
-		chan = S_OR(cdr->channel, "<unknown>");
+		struct ast_cdr *next = cdr->next;
+		char *chan = S_OR(cdr->channel, "<unknown>");
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_POSTED) && !ast_test_flag(cdr, AST_CDR_FLAG_POST_DISABLED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' not posted\n", chan);
 		if (ast_tvzero(cdr->end))
@@ -462,64 +441,48 @@
 {
 	char *chan; 
 
-	while (cdr) {
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			chan = S_OR(cdr->channel, "<unknown>");
-			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
-			if (!ast_tvzero(cdr->start))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already started\n", chan);
+			check_post(cdr);
+			check_start(cdr);
 			cdr->start = ast_tvnow();
 		}
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_answer(struct ast_cdr *cdr)
 {
-	char *chan; 
-
-	while (cdr) {
-		chan = S_OR(cdr->channel, "<unknown>");
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+
+	for (; cdr; cdr = cdr->next) {
+		check_post(cdr);
 		if (cdr->disposition < AST_CDR_ANSWERED)
 			cdr->disposition = AST_CDR_ANSWERED;
 		if (ast_tvzero(cdr->answer))
 			cdr->answer = ast_tvnow();
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_busy(struct ast_cdr *cdr)
 {
-	char *chan; 
-
-	while (cdr) {
+
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
-			chan = S_OR(cdr->channel, "<unknown>");
-			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+			check_post(cdr);
 			if (cdr->disposition < AST_CDR_BUSY)
 				cdr->disposition = AST_CDR_BUSY;
 		}
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_failed(struct ast_cdr *cdr)
 {
-	char *chan; 
-
-	while (cdr) {
-		chan = S_OR(cdr->channel, "<unknown>");
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+	for (; cdr; cdr = cdr->next) {
+		check_post(cdr);
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			if (cdr->disposition < AST_CDR_FAILED)
 				cdr->disposition = AST_CDR_FAILED;
 		}
-		cdr = cdr->next;
 	}
 }
 
@@ -527,7 +490,7 @@
 {
 	int res = 0;
 
-	while (cdr) {
+	for (; cdr; cdr = cdr->next) {
 		switch(cause) {
 		case AST_CAUSE_BUSY:
 			ast_cdr_busy(cdr);
@@ -544,34 +507,25 @@
 			res = -1;
 			ast_log(LOG_WARNING, "Cause not handled\n");
 		}
-		cdr = cdr->next;
 	}
 	return res;
 }
 
 void ast_cdr_setdestchan(struct ast_cdr *cdr, const char *chann)
 {
-	char *chan; 
-
-	while (cdr) {
-		chan = S_OR(cdr->channel, "<unknown>");
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+	for (; cdr; cdr = cdr->next) {
+		check_post(cdr);
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			ast_copy_string(cdr->dstchannel, chann, sizeof(cdr->dstchannel));
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data)
 {
-	char *chan; 
-
-	while (cdr) {
+
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
-			chan = S_OR(cdr->channel, "<unknown>");
-			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+			check_post(cdr);
 			if (!app)
 				app = "";
 			ast_copy_string(cdr->lastapp, app, sizeof(cdr->lastapp));
@@ -579,19 +533,17 @@
 				data = "";
 			ast_copy_string(cdr->lastdata, data, sizeof(cdr->lastdata));
 		}
-		cdr = cdr->next;
 	}
 }
 
 int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *c)
 {
 	char tmp[AST_MAX_EXTENSION] = "";
-	char *num;
-
-	while (cdr) {
+
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			/* Grab source from ANI or normal Caller*ID */
-			num = c->cid.cid_ani ? c->cid.cid_ani : c->cid.cid_num;
+			char *num = c->cid.cid_ani ? c->cid.cid_ani : c->cid.cid_num; /* XXX ast_strlen_zero ? */
 			
 			if (c->cid.cid_name && num)
 				snprintf(tmp, sizeof(tmp), "\"%s\" <%s>", c->cid.cid_name, num);
@@ -602,7 +554,6 @@
 			ast_copy_string(cdr->clid, tmp, sizeof(cdr->clid));
 			ast_copy_string(cdr->src, num ? num : "", sizeof(cdr->src));
 		}
-		cdr = cdr->next;
 	}
 
 	return 0;
@@ -615,7 +566,7 @@
 	char *num;
 	char tmp[AST_MAX_EXTENSION] = "";
 
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			chan = S_OR(cdr->channel, "<unknown>");
 			if (!ast_strlen_zero(cdr->channel)) 
@@ -642,23 +593,18 @@
 			/* Unique call identifier */
 			ast_copy_string(cdr->uniqueid, c->uniqueid, sizeof(cdr->uniqueid));
 		}
-		cdr = cdr->next;
 	}
 	return 0;
 }
 
 void ast_cdr_end(struct ast_cdr *cdr)
 {
-	char *chan;
-
-	while (cdr) {
-		chan = S_OR(cdr->channel, "<unknown>");
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+	for ( ; cdr ; cdr = cdr->next) {
+		check_post(cdr);
 		if (ast_tvzero(cdr->end))
 			cdr->end = ast_tvnow();
 		if (ast_tvzero(cdr->start)) {
-			ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", chan);
+			ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", S_OR(cdr->channel, "<unknown>"));
 			cdr->disposition = AST_CDR_FAILED;
 		} else
 			cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec;
@@ -666,7 +612,6 @@
 			cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec;
 		else
 			cdr->billsec = 0;
-		cdr = cdr->next;
 	}
 }
 
@@ -704,10 +649,9 @@
 	struct ast_cdr *cdr = chan->cdr;
 
 	ast_string_field_set(chan, accountcode, account);
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			ast_copy_string(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode));
-		cdr = cdr->next;
 	}
 	return 0;
 }
@@ -715,13 +659,10 @@
 int ast_cdr_setamaflags(struct ast_channel *chan, const char *flag)
 {
 	struct ast_cdr *cdr;
-	int newflag;
-
-	newflag = ast_cdr_amaflags2int(flag);
+	int newflag = ast_cdr_amaflags2int(flag);
 	if (newflag) {
-		for (cdr = chan->cdr; cdr; cdr = cdr->next) {
+		for (cdr = chan->cdr; cdr; cdr = cdr->next)
 			cdr->amaflags = newflag;
-		}
 	}
 
 	return 0;
@@ -731,10 +672,9 @@
 {
 	struct ast_cdr *cdr = chan->cdr;
 
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) 
 			ast_copy_string(cdr->userfield, userfield, sizeof(cdr->userfield));
-		cdr = cdr->next;
 	}
 
 	return 0;
@@ -744,13 +684,11 @@
 {
 	struct ast_cdr *cdr = chan->cdr;
 
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		int len = strlen(cdr->userfield);
 
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1);
-
-		cdr = cdr->next;
 	}
 
 	return 0;
@@ -762,7 +700,7 @@
 	char *num;
 	char tmp[AST_MAX_EXTENSION] = "";
 
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			num = c->cid.cid_ani ? c->cid.cid_ani : c->cid.cid_num;
 			
@@ -777,11 +715,10 @@
 
 			/* Copy account code et-al */	
 			ast_copy_string(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode));
-			/* Destination information */
+			/* Destination information */ /* XXX privilege macro* ? */
 			ast_copy_string(cdr->dst, S_OR(c->macroexten, c->exten), sizeof(cdr->dst));
 			ast_copy_string(cdr->dcontext, S_OR(c->macrocontext, c->context), sizeof(cdr->dcontext));
 		}
-		cdr = cdr->next;
 	}
 
 	return 0;
@@ -805,10 +742,9 @@
 	char *chan;
 	struct ast_cdr_beitem *i;
 
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		chan = S_OR(cdr->channel, "<unknown>");
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+		check_post(cdr);
 		if (ast_tvzero(cdr->end))
 			ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan);
 		if (ast_tvzero(cdr->start))
@@ -819,7 +755,6 @@
 			i->be(cdr);
 		}
 		AST_LIST_UNLOCK(&be_list);
-		cdr = cdr->next;
 	}
 }
 
@@ -831,7 +766,7 @@
 	if (_flags)
 		ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);
 
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		/* Detach if post is requested */
 		if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) {
@@ -857,8 +792,6 @@
 			ast_cdr_start(cdr);
 			cdr->disposition = AST_CDR_NOANSWER;
 		}
-			
-		cdr = cdr->next;
 	}
 }
 
@@ -891,9 +824,8 @@
 static int init_batch(void)
 {
 	/* This is the single meta-batch used to keep track of all CDRs during the entire life of the program */
-	if (!(batch = ast_malloc(sizeof(*batch)))) {
+	if (!(batch = ast_malloc(sizeof(*batch))))
 		return -1;
-	}
 
 	reset_batch();
 
@@ -999,7 +931,7 @@
 	if (option_debug)
 		ast_log(LOG_DEBUG, "CDR detaching from this thread\n");
 
-	/* we'll need a new tail for every CDR */	
+	/* we'll need a new tail for every CDR */
 	if (!(newtail = ast_calloc(1, sizeof(*newtail)))) {
 		post_cdr(cdr);
 		ast_cdr_free(cdr);

Modified: team/oej/jitterbuffer/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer/channel.c?rev=17900&r1=17899&r2=17900&view=diff
==============================================================================
--- team/oej/jitterbuffer/channel.c (original)
+++ team/oej/jitterbuffer/channel.c Thu Apr  6 11:37:39 2006
@@ -194,8 +194,8 @@
 		return -1;
 	}
 	AST_LIST_TRAVERSE(&backends, cl, list) {
-		ast_cli(fd, FORMAT, cl->tech->type, cl->tech->description, 
-			(cl->tech->devicestate) ? "yes" : "no", 
+		ast_cli(fd, FORMAT, cl->tech->type, cl->tech->description,
+			(cl->tech->devicestate) ? "yes" : "no",
 			(cl->tech->indicate) ? "yes" : "no",
 			(cl->tech->transfer) ? "yes" : "no");
 		count_chan++;
@@ -231,7 +231,7 @@
 		ast_cli(fd, "\n%s is not a registered channel driver.\n", argv[2]);
 		AST_LIST_UNLOCK(&channels);
 		return RESULT_FAILURE;
-	} 
+	}
 
 	ast_cli(fd,
 		"-- Info about channel driver: %s --\n"
@@ -281,15 +281,15 @@
 	return ret;
 }
 
-static char show_channeltypes_usage[] = 
+static char show_channeltypes_usage[] =
 "Usage: show channeltypes\n"
 "       Shows available channel types registered in your Asterisk server.\n";
 
-static char show_channeltype_usage[] = 
+static char show_channeltype_usage[] =
 "Usage: show channeltype <name>\n"
 "	Show details about the specified channel type, <name>.\n";
 
-static struct ast_cli_entry cli_show_channeltypes = 
+static struct ast_cli_entry cli_show_channeltypes =
 	{ { "show", "channeltypes", NULL }, show_channeltypes, "Show available channel types", show_channeltypes_usage };
 
 static struct ast_cli_entry cli_show_channeltype =
@@ -298,22 +298,15 @@
 /*! \brief Checks to see if a channel is needing hang up */
 int ast_check_hangup(struct ast_channel *chan)
 {
-	time_t	myt;
-
-	/* if soft hangup flag, return true */
-	if (chan->_softhangup) 
+	if (chan->_softhangup)		/* yes if soft hangup flag set */
 		return 1;
-	/* if no technology private data, return true */
-	if (!chan->tech_pvt) 
+	if (!chan->tech_pvt)		/* yes if no technology private data */
 		return 1;
-	/* if no hangup scheduled, just return here */
-	if (!chan->whentohangup) 
+	if (!chan->whentohangup)	/* no if no hangup scheduled */
 		return 0;
-	time(&myt); /* get current time */
-	/* return, if not yet */
-	if (chan->whentohangup > myt) 
+	if (chan->whentohangup > time(NULL)) 	/* no if hangup time has not come yet. */
 		return 0;
-	chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+	chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT;	/* record event */
 	return 1;
 }
 
@@ -366,15 +359,8 @@
 /*! \brief Set when to hangup channel */
 void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset)
 {
-	time_t	myt;
-	struct ast_frame fr = { AST_FRAME_NULL, };
-
-	time(&myt);
-	if (offset)
-		chan->whentohangup = myt + offset;
-	else
-		chan->whentohangup = 0;
-	ast_queue_frame(chan, &fr);
+	chan->whentohangup = offset ? time(NULL) + offset : 0;
+	ast_queue_frame(chan, &ast_null_frame);
 	return;
 }
 
@@ -384,12 +370,9 @@
 	time_t whentohangup;
 
 	if (chan->whentohangup == 0) {
-		if (offset == 0)
-			return (0);
-		else
-			return (-1);
-	} else { 
-		if (offset == 0)
+		return (offset == 0) ? 0 : -1;
+	} else {
+		if (offset == 0)	/* XXX why is this special ? */
 			return (1);
 		else {
 			whentohangup = offset + time (NULL);
@@ -486,9 +469,10 @@
 {
 	int x;
 
-	for (x=0; x < sizeof(causes) / sizeof(causes[0]); x++) 
+	for (x=0; x < sizeof(causes) / sizeof(causes[0]); x++) {
 		if (causes[x].cause == cause)
 			return causes[x].desc;
+	}
 
 	return "Unknown";
 }
@@ -548,7 +532,7 @@
 	/* This just our opinion, expressed in code.  We are asked to choose
 	   the best codec to use, given no information */
 	int x;
-	static int prefs[] = 
+	static int prefs[] =
 	{
 		/*! Okay, ulaw is used by all telephony equipment, so start with it */
 		AST_FORMAT_ULAW,
@@ -596,8 +580,7 @@
 	struct ast_channel *tmp;
 	int x;
 	int flags;
-	struct varshead *headp;        
-	        
+	struct varshead *headp;
 
 	/* If shutting down, don't allocate any new channels */
 	if (shutting_down) {
@@ -605,9 +588,8 @@
 		return NULL;
 	}
 
-	if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
+	if (!(tmp = ast_calloc(1, sizeof(*tmp))))
 		return NULL;
-	}
 
 	if (!(tmp->sched = sched_context_create())) {
 		ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
@@ -647,8 +629,7 @@
 			flags = fcntl(tmp->alertpipe[1], F_GETFL);
 			fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK);
 		}
-	} else 
-		/* Make sure we've got it done right if they don't */
+	} else	/* Make sure we've got it done right if they don't */
 		tmp->alertpipe[0] = tmp->alertpipe[1] = -1;
 
 	/* Always watch the alertpipe */
@@ -783,8 +764,8 @@
 }
 
 /*!
- * \brief Helper function to find channels. 
- * 
+ * \brief Helper function to find channels.
+ *
  * It supports these modes:
  *
  * prev != NULL : get channel next in list after prev
@@ -792,10 +773,10 @@
  * name != NULL && namelen != 0 : get channel whose name starts with prefix
  * exten != NULL : get channel whose exten or macroexten matches
  * context != NULL && exten != NULL : get channel whose context or macrocontext
- *                                    
+ *
  * It returns with the channel's lock held. If getting the individual lock fails,
  * unlock and retry quickly up to 10 times, then give up.
- * 
+ *
  * \note XXX Note that this code has cost O(N) because of the need to verify
  * that the object is still on the global list.
  *
@@ -981,7 +962,7 @@
 		ast_translator_free_path(chan->readtrans);
 	if (chan->writetrans)
 		ast_translator_free_path(chan->writetrans);
-	if (chan->pbx) 
+	if (chan->pbx)
 		ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name);
 	free_cid(&chan->cid);
 	ast_mutex_destroy(&chan->lock);
@@ -1130,7 +1111,7 @@
 	}
 }
 
-static void detach_spies(struct ast_channel *chan) 
+static void detach_spies(struct ast_channel *chan)
 {
 	struct ast_channel_spy *spy;
 
@@ -1155,17 +1136,15 @@
 /*! \brief Softly hangup a channel, don't lock */
 int ast_softhangup_nolock(struct ast_channel *chan, int cause)
 {
-	int res = 0;
-	struct ast_frame f = { AST_FRAME_NULL };
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name);
 	/* Inform channel driver that we need to be hung up, if it cares */
 	chan->_softhangup |= cause;
-	ast_queue_frame(chan, &f);
+	ast_queue_frame(chan, &ast_null_frame);
 	/* Interrupt any poll call or such */
 	if (ast_test_flag(chan, AST_FLAG_BLOCKING))
 		pthread_kill(chan->blocker, SIGURG);
-	return res;
+	return 0;
 }
 
 /*! \brief Softly hangup a channel, lock */
@@ -1339,7 +1318,7 @@
 	detach_spies(chan);		/* get rid of spies */
 
 	if (chan->masq) {
-		if (ast_do_masquerade(chan)) 
+		if (ast_do_masquerade(chan))
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
 	}
 
@@ -1348,7 +1327,7 @@
 		ast_mutex_unlock(&chan->lock);
 		return 0;
 	}
-	/* If this channel is one which will be masqueraded into something, 
+	/* If this channel is one which will be masqueraded into something,
 	   mark it as a zombie already, so we know to free it later */
 	if (chan->masqr) {
 		ast_set_flag(chan, AST_FLAG_ZOMBIE);
@@ -1365,13 +1344,13 @@
 		chan->sched = NULL;
 	}
 	
-	if (chan->generatordata)	/* Clear any tone stuff remaining */ 
+	if (chan->generatordata)	/* Clear any tone stuff remaining */
 		chan->generator->release(chan, chan->generatordata);
 	chan->generatordata = NULL;
 	chan->generator = NULL;
-	if (chan->cdr) {		/* End the CDR if it hasn't already */ 
+	if (chan->cdr) {		/* End the CDR if it hasn't already */
 		ast_cdr_end(chan->cdr);
-		ast_cdr_detach(chan->cdr);	/* Post and Free the CDR */ 
+		ast_cdr_detach(chan->cdr);	/* Post and Free the CDR */
 		chan->cdr = NULL;
 	}
 	if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
@@ -1391,13 +1370,13 @@
 	}
 			
 	ast_mutex_unlock(&chan->lock);
-	manager_event(EVENT_FLAG_CALL, "Hangup", 
+	manager_event(EVENT_FLAG_CALL, "Hangup",
 			"Channel: %s\r\n"
 			"Uniqueid: %s\r\n"
 			"Cause: %d\r\n"
 			"Cause-txt: %s\r\n",
-			chan->name, 
-			chan->uniqueid, 
+			chan->name,
+			chan->uniqueid,
 			chan->hangupcause,
 			ast_cause2str(chan->hangupcause)
 			);
@@ -1438,7 +1417,7 @@
 {
 	ast_mutex_lock(&chan->lock);
 	if (chan->generatordata) {
-		if (chan->generator && chan->generator->release) 
+		if (chan->generator && chan->generator->release)
 			chan->generator->release(chan, chan->generatordata);
 		chan->generatordata = NULL;
 		chan->generator = NULL;
@@ -1504,7 +1483,7 @@
 }
 
 /*! \brief Wait for x amount of time on a file descriptor to have input.  */
-struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, 
+struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds,
 	int *exception, int *outfd, int *ms)
 {
 	struct timeval start = { 0 , 0 };
@@ -1586,7 +1565,7 @@
 		max += ast_add_fd(&pfds[max], fds[x]);
 	}
 
-	if (*ms > 0) 
+	if (*ms > 0)
 		start = ast_tvnow();
 	
 	if (sizeof(int) == 4) {	/* XXX fix timeout > 600000 on linux x86-32 */
@@ -1676,19 +1655,19 @@
 	int result = 0;
 
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
 		return -1;
 
 	/* Wait for a digit, no more than ms milliseconds total. */
 	while(ms && !result) {
 		ms = ast_waitfor(c, ms);
 		if (ms < 0) /* Error */
-			result = -1; 
+			result = -1;
 		else if (ms > 0) {
 			/* Read something */
 			f = ast_read(c);
 			if (f) {
-				if (f->frametype == AST_FRAME_DTMF) 
+				if (f->frametype == AST_FRAME_DTMF)
 					result = f->subclass;
 				ast_frfree(f);
 			} else
@@ -1724,13 +1703,13 @@
 	int res;
 
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
 		return -1;
 	/* Wait for a digit, no more than ms milliseconds total. */
 	while(ms) {
 		errno = 0;
 		rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
-		if ((!rchan) && (outfd < 0) && (ms)) { 
+		if ((!rchan) && (outfd < 0) && (ms)) {
 			if (errno == 0 || errno == EINTR)
 				continue;
 			ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
@@ -1824,7 +1803,7 @@
 		blah = -1;
 		/* IF we can't get event, assume it's an expired as-per the old interface */
 		res = ioctl(chan->timingfd, ZT_GETEVENT, &blah);
-		if (res) 
+		if (res)
 			blah = ZT_EVENT_TIMER_EXPIRED;
 
 		if (blah == ZT_EVENT_TIMER_PING) {
@@ -1885,7 +1864,7 @@
 	} else {
 		chan->blocker = pthread_self();
 		if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
-			if (chan->tech->exception) 
+			if (chan->tech->exception)
 				f = chan->tech->exception(chan);
 			else {
 				ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name);
@@ -2040,7 +2019,7 @@
 int ast_internal_timing_enabled(struct ast_channel *chan)
 {
 	int ret = ast_opt_internal_timing && chan->timingfd > -1;
-	if (option_debug > 3) 
+	if (option_debug > 3)
 		ast_log(LOG_DEBUG, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd);
 	return ret;
 }
@@ -2153,7 +2132,7 @@
 {
 	int res = 0;
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
 		return -1;
 	CHECK_BLOCKING(chan);
 	if (chan->tech->send_text)
@@ -2518,7 +2497,7 @@
 			if (oh->priority)	
 				chan->priority = oh->priority;
 		}
-		if (chan->_state == AST_STATE_UP) 
+		if (chan->_state == AST_STATE_UP)
 			state = AST_CONTROL_ANSWER;
 	}
 	if (outstate)
@@ -2608,29 +2587,29 @@
 	return NULL;
 }
 
-int ast_call(struct ast_channel *chan, char *addr, int timeout) 
-{
-	/* Place an outgoing call, but don't wait any longer than timeout ms before returning. 
-	   If the remote end does not answer within the timeout, then do NOT hang up, but 
+int ast_call(struct ast_channel *chan, char *addr, int timeout)
+{
+	/* Place an outgoing call, but don't wait any longer than timeout ms before returning.
+	   If the remote end does not answer within the timeout, then do NOT hang up, but
 	   return anyway.  */
 	int res = -1;
 	/* Stop if we're a zombie or need a soft hangup */
 	ast_mutex_lock(&chan->lock);
-	if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) 
+	if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan))
 		if (chan->tech->call)
 			res = chan->tech->call(chan, addr, timeout);
 	ast_mutex_unlock(&chan->lock);
 	return res;
 }
 
-/*! 
+/*!
   \brief Transfer a call to dest, if the channel supports transfer
 
-  Called by: 
+  Called by:
     \arg app_transfer
     \arg the manager interface
 */
-int ast_transfer(struct ast_channel *chan, char *dest) 
+int ast_transfer(struct ast_channel *chan, char *dest)
 {
 	int res = -1;
 
@@ -2656,7 +2635,7 @@
 
 	/* XXX Merge with full version? XXX */
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
 		return -1;
 	if (!len)
 		return -1;
@@ -2695,7 +2674,7 @@
 	int d;
 
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
 		return -1;
 	if (!len)
 		return -1;
@@ -2820,10 +2799,10 @@
 	ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n",
 		clone->name, original->name);
 	if (original->masq) {
-		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 
+		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
 			original->masq->name, original->name);
 	} else if (clone->masqr) {
-		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 
+		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
 			clone->name, clone->masqr->name);
 	} else {
 		original->masq = clone;
@@ -2889,11 +2868,11 @@
 
 /*!
   \brief Clone channel variables from 'clone' channel into 'original' channel
-   
+
   All variables except those related to app_groupcount are cloned.
   Variables are actually _removed_ from 'clone' channel, presumably
   because it will subsequently be destroyed.
-  
+
   \note Assumes locks will be in place on both channels when called.
 */
 static void clone_variables(struct ast_channel *original, struct ast_channel *clone)
@@ -2923,7 +2902,7 @@
 /*!
   \brief Masquerade a channel
 
-  \note Assumes channel will be locked when called 
+  \note Assumes channel will be locked when called
 */
 int ast_do_masquerade(struct ast_channel *original)
 {
@@ -2948,7 +2927,7 @@
 
 	/* XXX This is a seriously wacked out operation.  We're essentially putting the guts of
 	   the clone channel into the original channel.  Start by killing off the original
-	   channel's backend.   I'm not sure we're going to keep this function, because 
+	   channel's backend.   I'm not sure we're going to keep this function, because
 	   while the features are nice, the cost is very high in terms of pure nastiness. XXX */
 
 	/* We need the clone's lock, too */
@@ -3020,7 +2999,7 @@
 		x++;
 		prev = cur;
 	}
-	/* If we had any, prepend them to the ones already in the queue, and 
+	/* If we had any, prepend them to the ones already in the queue, and
 	 * load up the alertpipe */
 	if (prev) {
 		prev->next = original->readq;
@@ -3044,7 +3023,7 @@
 
 	if (clone->tech->fixup){
 		res = clone->tech->fixup(original, clone);
-		if (res) 
+		if (res)
 			ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clone->name);
 	}
 
@@ -3135,13 +3114,13 @@
 	if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) {
 		ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name);
 		ast_mutex_unlock(&clone->lock);
-		manager_event(EVENT_FLAG_CALL, "Hangup", 
+		manager_event(EVENT_FLAG_CALL, "Hangup",
 			"Channel: %s\r\n"
 			"Uniqueid: %s\r\n"
 			"Cause: %d\r\n"
 			"Cause-txt: %s\r\n",
-			clone->name, 
-			clone->uniqueid, 
+			clone->name,
+			clone->uniqueid,
 			clone->hangupcause,
 			ast_cause2str(clone->hangupcause)
 			);
@@ -3188,15 +3167,15 @@
 	}
 	if (chan->cdr)
 		ast_cdr_setcid(chan->cdr, chan);
-	manager_event(EVENT_FLAG_CALL, "Newcallerid", 
+	manager_event(EVENT_FLAG_CALL, "Newcallerid",
 				"Channel: %s\r\n"
 				"CallerID: %s\r\n"
 				"CallerIDName: %s\r\n"
 				"Uniqueid: %s\r\n"
 				"CID-CallingPres: %d (%s)\r\n",
-				chan->name, chan->cid.cid_num ? 
-				chan->cid.cid_num : "<Unknown>",
-				chan->cid.cid_name ? 
+				chan->name, chan->cid.cid_num ?
+					chan->cid.cid_num : "<Unknown>",
+				chan->cid.cid_name ?
 				chan->cid.cid_name : "<Unknown>",
 				chan->uniqueid,
 				chan->cid.cid_pres,
@@ -3220,9 +3199,9 @@
 		      "CallerID: %s\r\n"
 		      "CallerIDName: %s\r\n"
 		      "Uniqueid: %s\r\n",
-		      chan->name, ast_state2str(chan->_state), 
-		      chan->cid.cid_num ? chan->cid.cid_num : "<unknown>", 
-		      chan->cid.cid_name ? chan->cid.cid_name : "<unknown>", 
+		      chan->name, ast_state2str(chan->_state),
+		      chan->cid.cid_num ? chan->cid.cid_num : "<unknown>",
+		      chan->cid.cid_name ? chan->cid.cid_name : "<unknown>",
 		      chan->uniqueid);
 
 	return 0;
@@ -3233,17 +3212,17 @@
 {
 	struct ast_channel *bridged;
 	bridged = chan->_bridge;
-	if (bridged && bridged->tech->bridged_channel) 
+	if (bridged && bridged->tech->bridged_channel)
 		bridged = bridged->tech->bridged_channel(chan, bridged);
 	return bridged;
 }
 
-static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain) 
+static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain)
 {
 	int min = 0, sec = 0, check;
 
 	check = ast_autoservice_start(peer);
-	if (check) 
+	if (check)
 		return;
 
 	if (remain > 0) {
@@ -3376,7 +3355,7 @@
 		}
 		if ((f->frametype == AST_FRAME_VOICE) ||
 		    (f->frametype == AST_FRAME_DTMF) ||
-		    (f->frametype == AST_FRAME_VIDEO) || 
+		    (f->frametype == AST_FRAME_VIDEO) ||
 		    (f->frametype == AST_FRAME_IMAGE) ||
 		    (f->frametype == AST_FRAME_HTML) ||
 #if defined(T38_SUPPORT)
@@ -3397,7 +3376,7 @@
 			} else {
 #if 0
 				ast_log(LOG_DEBUG, "Read from %s\n", who->name);
-				if (who == last) 
+				if (who == last)
 					ast_log(LOG_DEBUG, "Servicing channel %s twice in a row?\n", last->name);
 				last = who;
 #endif
@@ -3428,7 +3407,7 @@
 
 /*! \brief Bridge two channels together */
 enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1,
-					  struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc) 
+					  struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
 {
 	struct ast_channel *who = NULL;
 	enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
@@ -3443,19 +3422,19 @@
 	int to;
 
 	if (c0->_bridge) {
-		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 
+		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
 			c0->name, c0->_bridge->name);
 		return -1;
 	}
 	if (c1->_bridge) {
-		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 
+		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
 			c1->name, c1->_bridge->name);
 		return -1;
 	}
 	
 	/* Stop if we're a zombie or need a soft hangup */
 	if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
-	    ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) 
+	    ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1))
 		return -1;
 
 	*fo = NULL;
@@ -3480,7 +3459,7 @@
 	c0->_bridge = c1;
 	c1->_bridge = c0;
 	
-	manager_event(EVENT_FLAG_CALL, "Link", 
+	manager_event(EVENT_FLAG_CALL, "Link",
 		      "Channel1: %s\r\n"
 		      "Channel2: %s\r\n"
 		      "Uniqueid1: %s\r\n"
@@ -3488,7 +3467,7 @@
 		      "CallerID1: %s\r\n"
 		      "CallerID2: %s\r\n",
 		      c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
-                                                                        
+
 	o0nativeformats = c0->nativeformats;
 	o1nativeformats = c1->nativeformats;
 
@@ -3516,7 +3495,7 @@
 				if (callee_warning && config->end_sound)
 					bridge_playfile(c1, c0, config->end_sound, 0);
 				*fo = NULL;
-				if (who) 
+				if (who)
 					*rc = who;
 				res = 0;
 				break;
@@ -3575,7 +3554,7 @@
 			ast_set_flag(c0, AST_FLAG_NBRIDGE);
 			ast_set_flag(c1, AST_FLAG_NBRIDGE);
 			if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, to)) == AST_BRIDGE_COMPLETE) {
-				manager_event(EVENT_FLAG_CALL, "Unlink", 
+				manager_event(EVENT_FLAG_CALL, "Unlink",
 					      "Channel1: %s\r\n"
 					      "Channel2: %s\r\n"
 					      "Uniqueid1: %s\r\n"
@@ -3731,7 +3710,7 @@
 	struct tonepair_state *ts = data;
 	int x;
 
-	/* we need to prepare a frame with 16 * timelen samples as we're 
+	/* we need to prepare a frame with 16 * timelen samples as we're
 	 * generating SLIN audio
 	 */
 	len = samples * 2;
@@ -3775,10 +3754,7 @@
 	d.freq1 = freq1;
 	d.freq2 = freq2;
 	d.duration = duration;
-	if (vol < 1)
-		d.vol = 8192;
-	else
-		d.vol = vol;
+	d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
 	if (ast_activate_generator(chan, &tonepair, &d))
 		return -1;
 	return 0;
@@ -3791,15 +3767,14 @@
 
 int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 {
-	struct ast_frame *f;
 	int res;
 
 	if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
 		return res;
 
 	/* Give us some wiggle room */
-	while (chan->generatordata && (ast_waitfor(chan, 100) >= 0)) {
-		f = ast_read(chan);
+	while (chan->generatordata && ast_waitfor(chan, 100) >= 0) {
+		struct ast_frame *f = ast_read(chan);
 		if (f)
 			ast_frfree(f);
 		else
@@ -3853,7 +3828,7 @@
 	ast_moh_cleanup_ptr = cleanup_ptr;
 }
 
-void ast_uninstall_music_functions(void) 
+void ast_uninstall_music_functions(void)
 {
 	ast_moh_start_ptr = NULL;
 	ast_moh_stop_ptr = NULL;
@@ -3861,7 +3836,7 @@
 }
 
 /*! \brief Turn on music on hold on a given channel */
-int ast_moh_start(struct ast_channel *chan, const char *mclass) 
+int ast_moh_start(struct ast_channel *chan, const char *mclass)
 {
 	if (ast_moh_start_ptr)
 		return ast_moh_start_ptr(chan, mclass);
@@ -3873,13 +3848,13 @@
 }
 
 /*! \brief Turn off music on hold on a given channel */
-void ast_moh_stop(struct ast_channel *chan) 

[... 1258 lines stripped ...]


More information about the asterisk-commits mailing list