]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use static functions here instead of nested ones. This requires a small
authorSean Bright <sean@malleable.com>
Sun, 9 Nov 2008 01:08:07 +0000 (01:08 +0000)
committerSean Bright <sean@malleable.com>
Sun, 9 Nov 2008 01:08:07 +0000 (01:08 +0000)
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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@155553 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_dial.c
apps/app_followme.c
include/asterisk/channel.h
res/res_features.c

index db2e43b2d6f8189cd0a406a324451717fa0f1316..72ad5a6c4805d9022cd0ef60363cf2dfacebf810 100644 (file)
@@ -832,6 +832,27 @@ static void set_dial_features(struct ast_flags *opts, struct ast_dial_features *
                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 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                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 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                        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);
index 654bf373c28a83d43a10a71908943e7006fdf1d2..3de1a4608090f54184a3f12479039550f1a5b010 100644 (file)
@@ -914,6 +914,27 @@ static void findmeexec(struct fm_args *tpargs)
                
 }
 
+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 @@ static int app_exec(struct ast_channel *chan, void *data)
                                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 @@ static int app_exec(struct ast_channel *chan, void *data)
                        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 */
index 82055be1494d71f147807ce088f01c8eb8a1b54d..be08873aefa2eadab2d99e978c282da6fb879038 100644 (file)
@@ -540,7 +540,8 @@ struct ast_bridge_config {
        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;
index 9e5d5054a329f9e93d53ba20d15050cc45c5b839..816e1630fe9ca4cafe6b02cda3f2e5e0734e1526 100644 (file)
@@ -1714,7 +1714,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
        }
   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);