[svn-commits] file: branch file/bridging r126117 - /team/file/bridging/main/bridging.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 27 18:46:15 CDT 2008


Author: file
Date: Fri Jun 27 18:46:14 2008
New Revision: 126117

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126117
Log:
This does not need to be an API call.

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=126117&r1=126116&r2=126117
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Fri Jun 27 18:46:14 2008
@@ -106,6 +106,22 @@
 	return current ? 0 : -1;
 }
 
+/*! \brief Helper function to change the state of a bridge channel and poke the thread handling it */
+static int bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
+{
+	/* Change the state on the bridge channel */
+	bridge_channel->state = new_state;
+
+	/* Poke it's thread using a few different ways */
+	pthread_kill(bridge_channel->thread, SIGURG);
+	
+	ast_mutex_lock(&bridge_channel->lock);
+	ast_cond_signal(&bridge_channel->cond);
+	ast_mutex_unlock(&bridge_channel->lock);
+	
+	return 0;
+}
+
 /*! \brief Helper function to find a bridge channel given a channel */
 static struct ast_bridge_channel *find_bridge_channel(struct ast_bridge *bridge, struct ast_channel *chan)
 {
@@ -131,7 +147,7 @@
 
 	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)
-			ast_bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+			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 */
@@ -155,7 +171,7 @@
 		if (hook->dtmf[0] == frame->subclass) {
 			ast_frfree(frame);
 			frame = NULL;
-			ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_FEATURE);
+			bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_FEATURE);
 			ast_bridge_rebuild(bridge);
 			break;
 		}
@@ -178,7 +194,7 @@
 		/* This is pretty simple... see if they hung up */
 		if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_HANGUP)) {
 			/* Signal the thread that is handling the bridged channel that it should be ended */
-			ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+			bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 			/* Perform bridge dissolving stuff if needed */
 			bridge_check_dissolve(bridge, bridge_channel);
 		} else if (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_ANSWER) {
@@ -384,7 +400,7 @@
 
 	/* Drop every bridged channel, the last one will cause the bridge thread (if it exists) to exit */
 	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
-		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+		bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 	}
 
 	ao2_unlock(bridge);
@@ -669,7 +685,7 @@
 		/* If we are performing a swap operation we do not need to execute the smart bridge operation as the actual number of channels involved will not have changed, we just need to tell the other channel to leave */
 		if ((bridge_channel2 = find_bridge_channel(bridge_channel->bridge, bridge_channel->swap))) {
 			ast_debug(1, "Swapping bridge channel %p out from bridge %p so bridge channel %p can slip in\n", bridge_channel2, bridge_channel->bridge, bridge_channel);
-			ast_bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+			bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
 		}
 
 		bridge_channel->swap = NULL;
@@ -845,7 +861,7 @@
 		return -1;
 	}
 
-	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
+	bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
 	thread = bridge_channel->thread;
 
 	ao2_unlock(bridge);
@@ -867,24 +883,9 @@
 		return -1;
 	}
 
-	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+	bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
 
 	ao2_unlock(bridge);
-
-	return 0;
-}
-
-int ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
-{
-	/* Change the state on the bridge channel */
-	bridge_channel->state = new_state;
-	
-	/* Signal it's thread using a few different ways... */
-	pthread_kill(bridge_channel->thread, SIGURG);
-
-	ast_mutex_lock(&bridge_channel->lock);
-	ast_cond_signal(&bridge_channel->cond);
-	ast_mutex_unlock(&bridge_channel->lock);
 
 	return 0;
 }
@@ -1149,7 +1150,7 @@
 	}
 
 	/* Now we basically eject the other channel from the bridge. This will cause their thread to hang them up, and our own code to consider the transfer failed. */
-	ast_bridge_change_state(called_bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+	bridge_change_state(called_bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
 
 	bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_END;
 
@@ -1303,8 +1304,8 @@
 		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);
-	}
-
-	return 0;
-}
+		bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DTMF);
+	}
+
+	return 0;
+}




More information about the svn-commits mailing list