[asterisk-commits] file: branch file/bridging r127659 - /team/file/bridging/main/bridging.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 2 18:39:26 CDT 2008


Author: file
Date: Wed Jul  2 18:39:25 2008
New Revision: 127659

URL: http://svn.digium.com/view/asterisk?view=rev&rev=127659
Log:
Some code clean up, plus get features going again.

Modified:
    team/file/bridging/main/bridging.c

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=127659&r1=127658&r2=127659
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Wed Jul  2 18:39:25 2008
@@ -811,7 +811,7 @@
 	}
 
 	/* Actually execute the respective threading model, and keep our bridge thread alive */
-	while (state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
+	while (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
 		/* If the technology requires a thread and one is not running, start it up */
 		if (bridge_channel->bridge->thread == AST_PTHREADT_NULL && (bridge_channel->bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_THREAD)) {
 			bridge_channel->bridge->stop = 0;
@@ -827,7 +827,9 @@
 		state = (bridge_channel->bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_MULTITHREADED ? bridge_channel_join_multithreaded(bridge_channel) : bridge_channel_join_singlethreaded(bridge_channel));
 		/* Depending on the above state see what we need to do */
 		if (state == AST_BRIDGE_CHANNEL_STATE_FEATURE) {
+			bridge_array_remove(bridge_channel->bridge, bridge_channel->chan);
 			bridge_channel_feature(bridge_channel->bridge, bridge_channel);
+			bridge_array_add(bridge_channel->bridge, bridge_channel->chan);
 		}
 	}
 
@@ -1133,8 +1135,9 @@
 	struct ast_bridge_features_hook *hook = NULL;
 
 	/* Allocate new memory and setup it's various variables */
-	if (!(hook = ast_calloc(1, sizeof(*hook))))
+	if (!(hook = ast_calloc(1, sizeof(*hook)))) {
 		return -1;
+	}
 
 	ast_copy_string(hook->dtmf, dtmf, sizeof(hook->dtmf));
 	hook->callback = callback;
@@ -1158,8 +1161,9 @@
 	ast_stopstream(chan);
 
 	/* If the person hit a DTMF digit while the above played back stick it into the buffer */
-	if (res)
+	if (res) {
 		exten[0] = (char)res;
+	}
 
 	/* Drop to dialtone so they can enter the extension they want to transfer to */
 	res = ast_app_dtget(chan, context, exten, exten_len, 100, 1000);
@@ -1342,12 +1346,15 @@
 	}
 
 	/* Grab the callback for each feature */
-	if (feature == AST_BRIDGE_BUILTIN_BLINDTRANSFER)
+	if (feature == AST_BRIDGE_BUILTIN_BLINDTRANSFER) {
 		callback = feature_blind_transfer;
-	else if (feature == AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER)
+	} else if (feature == AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER) {
 		callback = feature_attended_transfer;
-	else if (feature == AST_BRIDGE_BUILTIN_HANGUP)
+	} else if (feature == AST_BRIDGE_BUILTIN_HANGUP) {
 		callback = feature_hangup;
+	} else {
+		return -1;
+	}
 
 	/* The rest is basically pretty easy. We create another hook using the built in feature's callback and DTMF, easy as pie. */
 	return ast_bridge_features_hook(features, dtmf, callback, NULL);
@@ -1376,8 +1383,9 @@
 	struct ast_bridge_features_hook *hook = NULL;
 
 	/* This is relatively simple, hooks are kept as a list on the features structure so we just pop them off and free them */
-	while ((hook = AST_LIST_REMOVE_HEAD(&features->hooks, entry)))
-		free(hook);
+	while ((hook = AST_LIST_REMOVE_HEAD(&features->hooks, entry))) {
+		ast_free(hook);
+	}
 
 	return 0;
 }
@@ -1385,6 +1393,8 @@
 int ast_bridge_dtmf_stream(struct ast_bridge *bridge, const char *dtmf, struct ast_channel *chan)
 {
 	struct ast_bridge_channel *bridge_channel = NULL;
+
+	ao2_lock(bridge);
 
 	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
 		if (bridge_channel->chan == chan)
@@ -1393,5 +1403,7 @@
 		bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DTMF);
 	}
 
-	return 0;
-}
+	ao2_unlock(bridge);
+
+	return 0;
+}




More information about the asterisk-commits mailing list