[asterisk-commits] file: branch file/bridging-softmixgen2 r180645 - in /team/file/bridging-softm...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 7 10:12:31 CST 2009


Author: file
Date: Sat Mar  7 10:12:27 2009
New Revision: 180645

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=180645
Log:
Add support for attaching additional file descriptors at bridge level, and get rid of a magic value.

Modified:
    team/file/bridging-softmixgen2/include/asterisk/bridging.h
    team/file/bridging-softmixgen2/main/bridging.c

Modified: team/file/bridging-softmixgen2/include/asterisk/bridging.h
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging-softmixgen2/include/asterisk/bridging.h?view=diff&rev=180645&r1=180644&r2=180645
==============================================================================
--- team/file/bridging-softmixgen2/include/asterisk/bridging.h (original)
+++ team/file/bridging-softmixgen2/include/asterisk/bridging.h Sat Mar  7 10:12:27 2009
@@ -107,6 +107,9 @@
 	/*! Bridge technology does not support writing out a frame of this type */
 	AST_BRIDGE_WRITE_UNSUPPORTED,
 };
+
+/*! \brief Maximum number of additional file descriptors supported */
+#define AST_BRIDGING_MAX_FDS 4
 
 struct ast_bridge_technology;
 struct ast_bridge;
@@ -132,7 +135,7 @@
 	/*! Thread handling the bridged channel */
 	pthread_t thread;
 	/*! Additional file descriptors to look at */
-	int fds[4];
+	int fds[AST_BRIDGING_MAX_FDS];
 	/*! Bit to indicate whether the channel is suspended from the bridge or not */
 	unsigned int suspended:1;
 	/*! Features structure for features that are specific to this channel */
@@ -163,6 +166,8 @@
 	void *bridge_pvt;
 	/*! Thread running the bridge */
 	pthread_t thread;
+	/*! Additional file descriptors to look at */
+	int fds[AST_BRIDGING_MAX_FDS];
 	/*! Enabled features information */
 	struct ast_bridge_features features;
 	/*! Array of channels that the bridge thread is currently handling */

Modified: team/file/bridging-softmixgen2/main/bridging.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging-softmixgen2/main/bridging.c?view=diff&rev=180645&r1=180644&r2=180645
==============================================================================
--- team/file/bridging-softmixgen2/main/bridging.c (original)
+++ team/file/bridging-softmixgen2/main/bridging.c Sat Mar  7 10:12:27 2009
@@ -312,9 +312,17 @@
 /*! \brief Generic thread loop, TODO: Rethink this/improve it */
 static int generic_thread_loop(struct ast_bridge *bridge)
 {
+	int fds[AST_BRIDGING_MAX_FDS] = { -1, }, nfds = 0, i;
+
+	for (i = 0; i < AST_BRIDGING_MAX_FDS; i++) {
+		if (bridge->fds[i] > -1) {
+			fds[nfds++] = bridge->fds[i];
+		}
+	}
+
 	while (!bridge->stop && !bridge->refresh && bridge->array_num) {
 		struct ast_channel *winner = NULL;
-		int to = -1;
+		int to = -1, outfd = -1;
 
 		/* Move channels around for priority reasons if we have more than one channel in our array */
 		if (bridge->array_num > 1) {
@@ -326,12 +334,12 @@
 		/* Wait on the channels */
 		bridge->waiting = 1;
 		ao2_unlock(bridge);
-		winner = ast_waitfor_n(bridge->array, (int)bridge->array_num, &to);
+		winner = ast_waitfor_nandfds(bridge->array, (int)bridge->array_num, fds, nfds, NULL, &outfd, &to);
 		bridge->waiting = 0;
 		ao2_lock(bridge);
 
 		/* Process whatever they did */
-		ast_bridge_handle_trip(bridge, NULL, winner, -1);
+		ast_bridge_handle_trip(bridge, NULL, winner, outfd);
 	}
 
 	return 0;
@@ -685,7 +693,7 @@
 /*! \brief Run in a multithreaded model. Each joined channel does writing/reading in their own thread. TODO: Improve */
 static enum ast_bridge_channel_state bridge_channel_join_multithreaded(struct ast_bridge_channel *bridge_channel)
 {
-	int fds[4] = { -1, }, nfds = 0, i = 0, outfd = -1, ms = -1;
+	int fds[AST_BRIDGING_MAX_FDS] = { -1, }, nfds = 0, i = 0, outfd = -1, ms = -1;
 	struct ast_channel *chan = NULL;
 
 	/* Add any file descriptors we may want to monitor */




More information about the asterisk-commits mailing list