[asterisk-commits] seanbright: branch 1.4 r155553 - in /branches/1.4: apps/ include/asterisk/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Nov 8 19:08:07 CST 2008


Author: seanbright
Date: Sat Nov  8 19:08:07 2008
New Revision: 155553

URL: http://svn.digium.com/view/asterisk?view=rev&rev=155553
Log:
Use static functions here instead of nested ones.  This requires a small
change to the ast_bridge_config struct as well.  To understand the reason
for this change, see the following post:

    http://gcc.gnu.org/ml/gcc-help/2008-11/msg00049.html

Modified:
    branches/1.4/apps/app_dial.c
    branches/1.4/apps/app_followme.c
    branches/1.4/include/asterisk/channel.h
    branches/1.4/res/res_features.c

Modified: branches/1.4/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_dial.c?view=diff&rev=155553&r1=155552&r2=155553
==============================================================================
--- branches/1.4/apps/app_dial.c (original)
+++ branches/1.4/apps/app_dial.c Sat Nov  8 19:08:07 2008
@@ -832,6 +832,27 @@
 		ast_set_flag(&(features->features_caller), AST_FEATURE_PARKCALL);
 }
 
+static void end_bridge_callback (void *data)
+{
+	char buf[80];
+	time_t end;
+	struct ast_channel *chan = data;
+
+	time(&end);
+
+	ast_channel_lock(chan);
+	if (chan->cdr->answer.tv_sec) {
+		snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+		pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+	}
+
+	if (chan->cdr->start.tv_sec) {
+		snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+		pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+	}
+	ast_channel_unlock(chan);
+}
+
 static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags *peerflags, int *continue_exec)
 {
 	int res = -1;
@@ -1735,27 +1756,6 @@
 		if (!res) {
 			struct ast_bridge_config config;
 
-			auto void end_bridge_callback(void);
-			void end_bridge_callback (void)
-			{
-				char buf[80];
-				time_t end;
-
-				time(&end);
-
-				ast_channel_lock(chan);
-				if (chan->cdr->answer.tv_sec) {
-					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
-					pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
-				}
-
-				if (chan->cdr->start.tv_sec) {
-					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
-					pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
-				}
-				ast_channel_unlock(chan);
-			}
-
 			memset(&config,0,sizeof(struct ast_bridge_config));
 			if (play_to_caller)
 				ast_set_flag(&(config.features_caller), AST_FEATURE_PLAY_WARNING);
@@ -1787,6 +1787,7 @@
 			config.end_sound = end_sound;
 			config.start_sound = start_sound;
 			config.end_bridge_callback = end_bridge_callback;
+			config.end_bridge_callback_data = chan;
 			if (moh) {
 				moh = 0;
 				ast_moh_stop(chan);

Modified: branches/1.4/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_followme.c?view=diff&rev=155553&r1=155552&r2=155553
==============================================================================
--- branches/1.4/apps/app_followme.c (original)
+++ branches/1.4/apps/app_followme.c Sat Nov  8 19:08:07 2008
@@ -914,6 +914,27 @@
 		
 }
 
+static void end_bridge_callback (void *data)
+{
+	char buf[80];
+	time_t end;
+	struct ast_channel *chan = data;
+
+	time(&end);
+
+	ast_channel_lock(chan);
+	if (chan->cdr->answer.tv_sec) {
+		snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+		pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+	}
+
+	if (chan->cdr->start.tv_sec) {
+		snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+		pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+	}
+	ast_channel_unlock(chan);
+}
+
 static int app_exec(struct ast_channel *chan, void *data)
 {
 	struct fm_args targs;
@@ -1025,27 +1046,6 @@
 				ast_stream_and_wait(chan, targs.sorryprompt, chan->language, "");
 			res = 0;
 		} else {
-			auto void end_bridge_callback(void);
-			void end_bridge_callback (void)
-			{
-				char buf[80];
-				time_t end;
-
-				time(&end);
-
-				ast_channel_lock(chan);
-				if (chan->cdr->answer.tv_sec) {
-					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
-					pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
-				}
-
-				if (chan->cdr->start.tv_sec) {
-					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
-					pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
-				}
-				ast_channel_unlock(chan);
-			}
-
 			caller = chan;
 			outbound = targs.outbound;
 			/* Bridge the two channels. */
@@ -1056,6 +1056,7 @@
 			ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
 
 			config.end_bridge_callback = end_bridge_callback;
+			config.end_bridge_callback_data = chan;
 
 			ast_moh_stop(caller);
 			/* Be sure no generators are left on it */

Modified: branches/1.4/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/channel.h?view=diff&rev=155553&r1=155552&r2=155553
==============================================================================
--- branches/1.4/include/asterisk/channel.h (original)
+++ branches/1.4/include/asterisk/channel.h Sat Nov  8 19:08:07 2008
@@ -540,7 +540,8 @@
 	const char *start_sound;
 	int firstpass;
 	unsigned int flags;
-	void (* end_bridge_callback)(void);   /*!< A callback that is called after a bridge attempt */
+	void (* end_bridge_callback)(void *);   /*!< A callback that is called after a bridge attempt */
+	void *end_bridge_callback_data;         /*!< Data passed to the callback */
 };
 
 struct chanmon;

Modified: branches/1.4/res/res_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/res_features.c?view=diff&rev=155553&r1=155552&r2=155553
==============================================================================
--- branches/1.4/res/res_features.c (original)
+++ branches/1.4/res/res_features.c Sat Nov  8 19:08:07 2008
@@ -1714,7 +1714,7 @@
 	}
   before_you_go:
 	if (res != AST_PBX_KEEPALIVE && config->end_bridge_callback) {
-		config->end_bridge_callback();
+		config->end_bridge_callback(config->end_bridge_callback_data);
 	}
 
 	autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);




More information about the asterisk-commits mailing list