[asterisk-commits] file: branch file/bridging r171835 - in /team/file/bridging: bridges/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 28 06:50:46 CST 2009


Author: file
Date: Wed Jan 28 06:50:46 2009
New Revision: 171835

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=171835
Log:
This commit may or may not have the bridging core conform better to the coding guidelines.

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

Modified: team/file/bridging/bridges/bridge_simple.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/bridges/bridge_simple.c?view=diff&rev=171835&r1=171834&r2=171835
==============================================================================
--- team/file/bridging/bridges/bridge_simple.c (original)
+++ team/file/bridging/bridges/bridge_simple.c Wed Jan 28 06:50:46 2009
@@ -45,12 +45,14 @@
 	struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan, *c1 = AST_LIST_LAST(&bridge->channels)->chan;
 
 	/* If this is the first channel we can't make it compatible... unless we make it compatible with itself O.o */
-	if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels))
+	if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
 		return 0;
+	}
 
 	/* See if we need to make these compatible */
-	if (((c0->writeformat == c1->readformat) && (c0->readformat == c1->writeformat) && (c0->nativeformats == c1->nativeformats)))
+	if (((c0->writeformat == c1->readformat) && (c0->readformat == c1->writeformat) && (c0->nativeformats == c1->nativeformats))) {
 		return 0;
+	}
 
 	/* BOOM! We do. */
 	return ast_channel_make_compatible(c0, c1);
@@ -61,16 +63,19 @@
 	struct ast_bridge_channel *other = NULL;
 
 	/* If this is the only channel in this bridge then immediately exit */
-	if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels))
+	if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
 		return AST_BRIDGE_WRITE_FAILED;
+	}
 
 	/* Find the channel we actually want to write to */
-	if (!(other = (AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels) : AST_LIST_FIRST(&bridge->channels))))
+	if (!(other = (AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels) : AST_LIST_FIRST(&bridge->channels)))) {
 		return AST_BRIDGE_WRITE_FAILED;
+	}
 
 	/* Write the frame out if they are in the waiting state... don't worry about freeing it, the bridging core will take care of it */
-	if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT)
+	if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
 		ast_write(other->chan, frame);
+	}
 
 	return AST_BRIDGE_WRITE_SUCCESS;
 }

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=171835&r1=171834&r2=171835
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Wed Jan 28 06:50:46 2009
@@ -211,14 +211,16 @@
 {
 	struct ast_bridge_channel *bridge_channel2 = NULL;
 
-	if (!ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_DISSOLVE) && (!bridge_channel->features || !bridge_channel->features->usable || !ast_test_flag(&bridge_channel->features->feature_flags, AST_BRIDGE_FLAG_DISSOLVE)))
+	if (!ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_DISSOLVE) && (!bridge_channel->features || !bridge_channel->features->usable || !ast_test_flag(&bridge_channel->features->feature_flags, AST_BRIDGE_FLAG_DISSOLVE))) {
 		return;
+	}
 
 	ast_debug(1, "Dissolving bridge %p\n", bridge);
 
 	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel2, entry) {
-		if (bridge_channel2->state != AST_BRIDGE_CHANNEL_STATE_END && bridge_channel2->state != AST_BRIDGE_CHANNEL_STATE_DEPART)
+		if (bridge_channel2->state != AST_BRIDGE_CHANNEL_STATE_END && bridge_channel2->state != AST_BRIDGE_CHANNEL_STATE_DEPART) {
 			ast_bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+		}
 	}
 
 	/* Since all the channels are going away let's go ahead and stop our on thread */
@@ -234,8 +236,9 @@
 	struct ast_bridge_features_hook *hook = NULL;
 
 	/* If the features structure we grabbed is not usable immediately return the frame */
-	if (!features->usable)
+	if (!features->usable) {
 		return frame;
+	}
 
 	/* See if this DTMF matches the beginnings of any feature hooks, if so we switch to the feature state to either execute the feature or collect more DTMF */
 	AST_LIST_TRAVERSE(&features->hooks, hook, entry) {
@@ -253,9 +256,10 @@
 void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd)
 {
 	/* If no bridge channel has been provided and the actual channel has been provided find it */
-	if (chan && !bridge_channel)
+	if (chan && !bridge_channel) {
 		bridge_channel = find_bridge_channel(bridge, chan);
-
+	}
+	
 	/* If a bridge channel with actual channel is present read a frame and handle it */
 	if (chan && bridge_channel) {
 		struct ast_frame *frame = (((bridge->features.mute) || (bridge_channel->features && bridge_channel->features->mute)) ? ast_read_noaudio(chan) : ast_read(chan));
@@ -267,15 +271,18 @@
 		} else if (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_ANSWER) {
 			ast_debug(1, "Dropping answer frame from bridge channel %p\n", bridge_channel);
 		} else {
-			if (frame->frametype == AST_FRAME_DTMF_BEGIN)
+			if (frame->frametype == AST_FRAME_DTMF_BEGIN) {
 				frame = bridge_handle_dtmf(bridge, bridge_channel, frame);
+			}
 			/* Simply write the frame out to the bridge technology if it still exists */
-			if (frame)
+			if (frame) {
 				bridge->technology->write(bridge, bridge_channel, frame);
-		}
-
-		if (frame)
+			}
+		}
+
+		if (frame) {
 			ast_frfree(frame);
+		}
 		return;
 	}
 
@@ -434,8 +441,9 @@
 	}
 
 	/* We have everything we need to create this bridge... so allocate the memory, link things together, and fire her up! */
-	if (!(bridge = ao2_alloc(sizeof(*bridge), destroy_bridge)))
+	if (!(bridge = ao2_alloc(sizeof(*bridge), destroy_bridge))) {
 		return NULL;
+	}
 
 	bridge->technology = bridge_technology;
 	bridge->thread = AST_PTHREADT_NULL;
@@ -449,8 +457,9 @@
 	/* Pass off the bridge to the technology to manipulate if needed */
 	if (bridge->technology->create) {
 		ast_debug(1, "Giving bridge technology %s the bridge structure %p to setup\n", bridge->technology->name, bridge);
-		if (bridge->technology->create(bridge))
+		if (bridge->technology->create(bridge)) {
 			ast_debug(1, "Bridge technology %s failed to setup bridge structure %p\n", bridge->technology->name, bridge);
+		}
 	}
 
 	return bridge;
@@ -1197,8 +1206,9 @@
 	snprintf(destination, sizeof(destination), "%s@%s", exten, context);
 
 	/* Now we request that chan_local prepare to call the destination */
-	if (!(chan = ast_request("Local", caller->nativeformats, destination, &cause)))
+	if (!(chan = ast_request("Local", caller->nativeformats, destination, &cause))) {
 		return NULL;
+	}
 
 	/* Before we actually dial out let's inherit the appropriate dialplan variables */
 	ast_channel_inherit_variables(caller, chan);
@@ -1410,8 +1420,9 @@
 	ao2_lock(bridge);
 
 	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
-		if (bridge_channel->chan == chan)
+		if (bridge_channel->chan == chan) {
 			continue;
+		}
 		ast_copy_string(bridge_channel->dtmf_stream_q, dtmf, sizeof(bridge_channel->dtmf_stream_q));
 		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DTMF);
 	}




More information about the asterisk-commits mailing list