[asterisk-commits] rmudgett: branch group/bridge_construction r382665 - in /team/group/bridge_co...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 7 17:50:27 CST 2013


Author: rmudgett
Date: Thu Mar  7 17:50:21 2013
New Revision: 382665

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382665
Log:
* Remove enum ast_bridge_write_result.  Nobody checked the bridge tech
write callback return value.  Might as well use the standard
success(0)/failed(-1) return.

* Removed unused extra fds[] in struct ast_bridge_channel and the code
using it.

Modified:
    team/group/bridge_construction/bridges/bridge_holding.c
    team/group/bridge_construction/bridges/bridge_multiplexed.c
    team/group/bridge_construction/bridges/bridge_simple.c
    team/group/bridge_construction/bridges/bridge_softmix.c
    team/group/bridge_construction/include/asterisk/bridging.h
    team/group/bridge_construction/include/asterisk/bridging_technology.h
    team/group/bridge_construction/main/bridging.c

Modified: team/group/bridge_construction/bridges/bridge_holding.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_holding.c?view=diff&rev=382665&r1=382664&r2=382665
==============================================================================
--- team/group/bridge_construction/bridges/bridge_holding.c (original)
+++ team/group/bridge_construction/bridges/bridge_holding.c Thu Mar  7 17:50:21 2013
@@ -250,19 +250,19 @@
 	bridge_channel->bridge_pvt = NULL;
 }
 
-static enum ast_bridge_write_result holding_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static int holding_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
 	struct ast_bridge_channel *other;
 	struct holding_channel *hc = bridge_channel->bridge_pvt;
 
 	/* If there is no bridge_pvt, then the channel failed to allocate one when it joined and is borked. Don't listen to him. */
 	if (!hc) {
-		return AST_BRIDGE_WRITE_FAILED;
+		return -1;
 	}
 
 	/* If we aren't an announcer, we never have any business writing anything. */
 	if (!ast_test_flag(&hc->holding_roles, HOLDING_ROLE_ANNOUNCER)) {
-		return AST_BRIDGE_WRITE_FAILED;
+		return -1;
 	}
 
 	/* Ok, so we are the announcer and there are one or more people available to receive our writes. Let's do it. */
@@ -280,7 +280,7 @@
 		}
 	}
 
-	return AST_BRIDGE_WRITE_SUCCESS;
+	return 0;
 }
 
 static struct ast_bridge_technology holding_bridge = {

Modified: team/group/bridge_construction/bridges/bridge_multiplexed.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_multiplexed.c?view=diff&rev=382665&r1=382664&r2=382665
==============================================================================
--- team/group/bridge_construction/bridges/bridge_multiplexed.c (original)
+++ team/group/bridge_construction/bridges/bridge_multiplexed.c Thu Mar  7 17:50:21 2013
@@ -291,7 +291,7 @@
 			}
 			if (!stop && bridge) {
 /* BUGBUG need to update thread callid for each bridge trip. */
-				ast_bridge_handle_trip(bridge, NULL, winner, -1);
+				ast_bridge_handle_trip(bridge, NULL, winner);
 				ao2_unlock(bridge);
 			}
 			ao2_lock(muxed_thread);
@@ -466,13 +466,13 @@
 }
 
 /*! \brief Write function for writing frames into the bridge */
-static enum ast_bridge_write_result multiplexed_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static int multiplexed_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
 	struct ast_bridge_channel *other;
 
 	/* If this is the only channel in this bridge then immediately exit */
 	if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
-		return AST_BRIDGE_WRITE_FAILED;
+		return -1;
 	}
 
 	/* Find the channel we actually want to write to */
@@ -489,7 +489,7 @@
 		}
 	}
 
-	return AST_BRIDGE_WRITE_SUCCESS;
+	return 0;
 }
 
 static struct ast_bridge_technology multiplexed_bridge = {

Modified: team/group/bridge_construction/bridges/bridge_simple.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_simple.c?view=diff&rev=382665&r1=382664&r2=382665
==============================================================================
--- team/group/bridge_construction/bridges/bridge_simple.c (original)
+++ team/group/bridge_construction/bridges/bridge_simple.c Thu Mar  7 17:50:21 2013
@@ -66,13 +66,13 @@
 	return ast_channel_make_compatible(c0, c1);
 }
 
-static enum ast_bridge_write_result simple_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static int simple_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
 	struct ast_bridge_channel *other;
 
 	/* If this is the only channel in this bridge then immediately exit */
 	if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
-		return AST_BRIDGE_WRITE_FAILED;
+		return -1;
 	}
 
 	/* Find the channel we actually want to write to */
@@ -89,7 +89,7 @@
 		}
 	}
 
-	return AST_BRIDGE_WRITE_SUCCESS;
+	return 0;
 }
 
 static struct ast_bridge_technology simple_bridge = {

Modified: team/group/bridge_construction/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_softmix.c?view=diff&rev=382665&r1=382664&r2=382665
==============================================================================
--- team/group/bridge_construction/bridges/bridge_softmix.c (original)
+++ team/group/bridge_construction/bridges/bridge_softmix.c Thu Mar  7 17:50:21 2013
@@ -472,7 +472,7 @@
 }
 
 /*! \brief Function called when a channel writes a frame into the bridge */
-static enum ast_bridge_write_result softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static int softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
 	struct softmix_channel *sc = bridge_channel->bridge_pvt;
 	struct softmix_bridge_data *softmix_data = bridge->bridge_pvt;
@@ -482,14 +482,15 @@
 		bridge_channel->tech_args.silence_threshold :
 		DEFAULT_SOFTMIX_SILENCE_THRESHOLD;
 	char update_talking = -1;  /* if this is set to 0 or 1, tell the bridge that the channel has started or stopped talking. */
-	int res = AST_BRIDGE_WRITE_SUCCESS;
+	int res = 0;
 
 	/* Only accept audio frames, all others are unsupported */
 	if (frame->frametype == AST_FRAME_DTMF_END || frame->frametype == AST_FRAME_DTMF_BEGIN) {
 		softmix_pass_dtmf(bridge, bridge_channel, frame);
 		goto bridge_write_cleanup;
 	} else if (frame->frametype != AST_FRAME_VOICE && frame->frametype != AST_FRAME_VIDEO) {
-		res = AST_BRIDGE_WRITE_UNSUPPORTED;
+		/* Frame type unsupported. */
+		res = -1;
 		goto bridge_write_cleanup;
 	} else if (frame->datalen == 0) {
 		goto bridge_write_cleanup;

Modified: team/group/bridge_construction/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/bridging.h?view=diff&rev=382665&r1=382664&r2=382665
==============================================================================
--- team/group/bridge_construction/include/asterisk/bridging.h (original)
+++ team/group/bridge_construction/include/asterisk/bridging.h Thu Mar  7 17:50:21 2013
@@ -94,16 +94,6 @@
 	AST_BRIDGE_CHANNEL_STATE_HANGUP,
 };
 
-/*! \brief Return values for bridge technology write function */
-enum ast_bridge_write_result {
-	/*! Bridge technology wrote out frame fine */
-	AST_BRIDGE_WRITE_SUCCESS = 0,
-	/*! Bridge technology attempted to write out the frame but failed */
-	AST_BRIDGE_WRITE_FAILED,
-	/*! Bridge technology does not support writing out a frame of this type */
-	AST_BRIDGE_WRITE_UNSUPPORTED,
-};
-
 struct ast_bridge_technology;
 struct ast_bridge;
 
@@ -141,8 +131,6 @@
 	void *bridge_pvt;
 	/*! Thread handling the bridged channel */
 	pthread_t thread;
-	/*! Additional file descriptors to look at */
-	int fds[4];
 	/*! TRUE if the channel has been poked. */
 	unsigned int poked;
 	/*! TRUE if the channel is in a bridge. */

Modified: team/group/bridge_construction/include/asterisk/bridging_technology.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/bridging_technology.h?view=diff&rev=382665&r1=382664&r2=382665
==============================================================================
--- team/group/bridge_construction/include/asterisk/bridging_technology.h (original)
+++ team/group/bridge_construction/include/asterisk/bridging_technology.h Thu Mar  7 17:50:21 2013
@@ -49,11 +49,21 @@
 	uint32_t capabilities;
 	/*! Preference level that should be used when determining whether to use this bridge technology or not */
 	enum ast_bridge_preference preference;
-	/*! Callback for when a bridge is being created */
+	/*!
+	 * \brief Callback for when a bridge is being created.
+	 *
+	 * \retval 0 on success
+	 * \retval -1 on failure
+	 */
 	int (*create)(struct ast_bridge *bridge);
 	/*! Callback for when a bridge is being destroyed */
 	void (*destroy)(struct ast_bridge *bridge);
-	/*! Callback for when a channel is being added to a bridge */
+	/*!
+	 * \brief Callback for when a channel is being added to a bridge.
+	 *
+	 * \retval 0 on success
+	 * \retval -1 on failure
+	 */
 	int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
 	/*! Callback for when a channel is leaving a bridge */
 	void (*leave)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
@@ -61,13 +71,26 @@
 	void (*suspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
 	/*! Callback for when a channel is unsuspended from the bridge */
 	void (*unsuspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
-	/*! Callback to see if the bridge is compatible with the bridging technology */
+	/*!
+	 * \brief Callback to see if the bridge is compatible with the bridging technology.
+	 *
+	 * \retval 0 if not compatible
+	 * \retval non-zero if compatible
+	 */
 	int (*compatible)(struct ast_bridge *bridge);
-	/*! Callback for writing a frame into the bridging technology */
-	enum ast_bridge_write_result (*write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridged_channel, struct ast_frame *frame);
-	/*! Callback for when a file descriptor trips */
-	int (*fd)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int fd);
-	/*! Callback for bridge thread loop */
+	/*!
+	 * \brief Callback for writing a frame into the bridging technology.
+	 *
+	 * \retval 0 on success
+	 * \retval -1 on failure
+	 */
+	int (*write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridged_channel, struct ast_frame *frame);
+	/*!
+	 * \brief Callback for bridge thread loop.
+	 *
+	 * \retval 0 on success
+	 * \retval -1 on failure
+	 */
 	int (*thread_loop)(struct ast_bridge *bridge);
 	/*! Callback for poking a bridge channel thread */
 	void (*poke_channel)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
@@ -166,12 +189,11 @@
  * \param bridge The bridge that the notification should influence
  * \param bridge_channel Bridge channel the notification was received on (if known)
  * \param chan Channel the notification was received on (if known)
- * \param outfd File descriptor that the notification was received on (if known)
- *
- * Example usage:
- *
- * \code
- * ast_bridge_handle_trip(bridge, NULL, chan, -1);
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_bridge_handle_trip(bridge, NULL, chan);
  * \endcode
  *
  * This tells the bridging core that a frame has been received on
@@ -179,7 +201,7 @@
  *
  * \note This should only be used by bridging technologies.
  */
-void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd);
+void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan);
 
 /*!
  * \brief Lets the bridging indicate when a bridge channel has stopped or started talking.

Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=382665&r1=382664&r2=382665
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Thu Mar  7 17:50:21 2013
@@ -664,7 +664,7 @@
 	ast_bridge_channel_queue_action(bridge_channel, &action);
 }
 
-void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd)
+void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan)
 {
 	struct ast_timer *interval_timer;
 
@@ -735,12 +735,6 @@
 		return;
 	}
 
-	/* If a file descriptor actually tripped pass it off to the bridge technology */
-	if (outfd > -1 && bridge->technology->fd) {
-		bridge->technology->fd(bridge, bridge_channel, outfd);
-		return;
-	}
-
 	/* If all else fails just poke the bridge channel */
 	if (bridge->technology->poke_channel && bridge_channel) {
 		bridge->technology->poke_channel(bridge, bridge_channel);
@@ -776,7 +770,7 @@
 		}
 
 		/* Process whatever they did */
-		ast_bridge_handle_trip(bridge, NULL, winner, -1);
+		ast_bridge_handle_trip(bridge, NULL, winner);
 	}
 }
 
@@ -1311,21 +1305,8 @@
 /*! \brief Run in a multithreaded model. Each joined channel does writing/reading in their own thread. TODO: Improve */
 static void bridge_channel_join_multithreaded(struct ast_bridge_channel *bridge_channel)
 {
-	int fds[4] = { -1, };
-	int nfds = 0;
-	int outfd = -1;
 	int ms = -1;
-	int i;
 	struct ast_channel *chan;
-
-	/* Add any file descriptors we may want to monitor */
-	if (bridge_channel->bridge->technology->fd) {
-		for (i = 0; i < 4; ++i) {
-			if (bridge_channel->fds[i] >= 0) {
-				fds[nfds++] = bridge_channel->fds[i];
-			}
-		}
-	}
 
 	ao2_unlock(bridge_channel->bridge);
 
@@ -1343,10 +1324,10 @@
 			bridge_channel, ast_channel_name(bridge_channel->chan),
 			bridge_channel->bridge);
 		ao2_unlock(bridge_channel);
-		chan = ast_waitfor_nandfds(&bridge_channel->chan, 1, fds, nfds, NULL, &outfd, &ms);
+		chan = ast_waitfor_n(&bridge_channel->chan, 1, &ms);
 		ao2_lock(bridge_channel->bridge);
 		if (!bridge_channel->suspended) {
-			ast_bridge_handle_trip(bridge_channel->bridge, bridge_channel, chan, outfd);
+			ast_bridge_handle_trip(bridge_channel->bridge, bridge_channel, chan);
 		}
 		ao2_lock(bridge_channel);
 		bridge_channel->poked = 0;




More information about the asterisk-commits mailing list