[svn-commits] jrose: branch jrose/bridge_projects r381468 - in /team/jrose/bridge_projects:...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 14 13:46:58 CST 2013


Author: jrose
Date: Thu Feb 14 13:46:55 2013
New Revision: 381468

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381468
Log:
bridge_construction: Interval Hooks - address Feb 14 review by rmudgett

Modified:
    team/jrose/bridge_projects/bridges/bridge_builtin_interval_features.c
    team/jrose/bridge_projects/include/asterisk/bridging.h
    team/jrose/bridge_projects/main/bridging.c
    team/jrose/bridge_projects/main/features.c

Modified: team/jrose/bridge_projects/bridges/bridge_builtin_interval_features.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/bridges/bridge_builtin_interval_features.c?view=diff&rev=381468&r1=381467&r2=381468
==============================================================================
--- team/jrose/bridge_projects/bridges/bridge_builtin_interval_features.c (original)
+++ team/jrose/bridge_projects/bridges/bridge_builtin_interval_features.c Thu Feb 14 13:46:55 2013
@@ -61,53 +61,54 @@
 	ao2_lock(bridge_channel);
 	switch (bridge_channel->state) {
 	case AST_BRIDGE_CHANNEL_STATE_WAIT:
-		ao2_unlock(bridge_channel);
-		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+		ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 		break;
 	default:
-		ao2_unlock(bridge_channel);
 		break;
 	}
 
 	ast_test_suite_event_notify("BRIDGE_TIMELIMIT", "Channel1: %s", ast_channel_name(bridge_channel->chan));
 
+	ao2_unlock(bridge_channel);
+
 	return -1;
 }
 
 static void limits_interval_playback(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_bridge_features_limits *limits, const char *file)
 {
 	if (!strcasecmp(file, "timeleft")) {
-
 		unsigned int remaining = ast_tvdiff_ms(limits->quitting_time, ast_tvnow()) / 1000;
-
-		if (remaining > 0) {
-			unsigned int min;
-			unsigned int sec;
-
-			if ((remaining / 60) > 1) {
-				min = remaining / 60;
-				sec = remaining % 60;
-			} else {
-				min = 0;
-				sec = remaining;
-			}
-
-			ast_stream_and_wait(bridge_channel->chan, "vm-youhave", AST_DIGIT_NONE);
-			if (min) {
-				ast_say_number(bridge_channel->chan, min, AST_DIGIT_NONE,
-					ast_channel_language(bridge_channel->chan), NULL);
-				ast_stream_and_wait(bridge_channel->chan, "queue-minutes", AST_DIGIT_NONE);
-			}
-			if (sec) {
-				ast_say_number(bridge_channel->chan, sec, AST_DIGIT_NONE,
-					ast_channel_language(bridge_channel->chan), NULL);
-				ast_stream_and_wait(bridge_channel->chan, "queue-seconds", AST_DIGIT_NONE);
-			}
-
-			/* It may be necessary to resume music on hold after we finish playing the announcment. */
-			if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
-				ast_moh_start(bridge_channel->chan, NULL, NULL);
-			}
+		unsigned int min;
+		unsigned int sec;
+
+		if (remaining <= 0) {
+			return;
+		}
+
+		if ((remaining / 60) > 1) {
+			min = remaining / 60;
+			sec = remaining % 60;
+		} else {
+			min = 0;
+			sec = remaining;
+		}
+
+		ast_stream_and_wait(bridge_channel->chan, "vm-youhave", AST_DIGIT_NONE);
+		if (min) {
+			ast_say_number(bridge_channel->chan, min, AST_DIGIT_NONE,
+				ast_channel_language(bridge_channel->chan), NULL);
+			ast_stream_and_wait(bridge_channel->chan, "queue-minutes", AST_DIGIT_NONE);
+		}
+
+		if (sec) {
+			ast_say_number(bridge_channel->chan, sec, AST_DIGIT_NONE,
+				ast_channel_language(bridge_channel->chan), NULL);
+			ast_stream_and_wait(bridge_channel->chan, "queue-seconds", AST_DIGIT_NONE);
+		}
+
+		/* It may be necessary to resume music on hold after we finish playing the announcment. */
+		if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
+			ast_moh_start(bridge_channel->chan, NULL, NULL);
 		}
 	} else {
 		ast_stream_and_wait(bridge_channel->chan, file, AST_DIGIT_NONE);
@@ -123,7 +124,7 @@
 {
 	struct ast_bridge_features_limits *limits = hook_pvt;
 
-	if ((bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_WAIT)) {
+	if (bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_WAIT) {
 		return -1;
 	}
 
@@ -135,7 +136,7 @@
 {
 	struct ast_bridge_features_limits *limits = hook_pvt;
 
-	if ((bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT)) {
+	if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
 		/* If we aren't in the wait state, something more important than this warning is happening and we should skip it. */
 		limits_interval_playback(bridge, bridge_channel, limits, limits->warning_sound);
 	}
@@ -224,4 +225,4 @@
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Builting bridging interval features");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Built in bridging interval features");

Modified: team/jrose/bridge_projects/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/bridging.h?view=diff&rev=381468&r1=381467&r2=381468
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/bridging.h (original)
+++ team/jrose/bridge_projects/include/asterisk/bridging.h Thu Feb 14 13:46:55 2013
@@ -544,6 +544,17 @@
 int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
 
 /*!
+ * \brief Change the state of a bridged channel without taking and releasing the bridge channel lock
+ *
+ * \param bridge_channel Channel to change the state on
+ * \param new_state The new state to place the channel into
+ *
+ * \note Do not use this call outside the context of either interval hook callbacks or bridging core.
+ *       This function assumes the bridge_channel is locked.
+ */
+void ast_bridge_change_state_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
+
+/*!
  * \brief Change the state of a bridged channel
  *
  * \param bridge_channel Channel to change the state on

Modified: team/jrose/bridge_projects/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/bridging.c?view=diff&rev=381468&r1=381467&r2=381468
==============================================================================
--- team/jrose/bridge_projects/main/bridging.c (original)
+++ team/jrose/bridge_projects/main/bridging.c Thu Feb 14 13:46:55 2013
@@ -135,8 +135,7 @@
 	ao2_unlock(bridge_channel);
 }
 
-/*! \note This function assumes the bridge_channel is locked. */
-static void ast_bridge_change_state_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
+void ast_bridge_change_state_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
 {
 	ast_debug(1, "BUGBUG Setting bridge channel %p state from:%d to:%d\n",
 		bridge_channel, bridge_channel->state, new_state);
@@ -2043,6 +2042,8 @@
 
 int ast_bridge_features_limits_construct(struct ast_bridge_features_limits *limits)
 {
+	memset(limits, 0, sizeof(limits));
+
 	if (ast_string_field_init(limits, 256)) {
 		ast_free(limits);
 		return -1;

Modified: team/jrose/bridge_projects/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/features.c?view=diff&rev=381468&r1=381467&r2=381468
==============================================================================
--- team/jrose/bridge_projects/main/features.c (original)
+++ team/jrose/bridge_projects/main/features.c Thu Feb 14 13:46:55 2013
@@ -4646,7 +4646,7 @@
 	if (config->timelimit) {
 		struct ast_bridge_features_limits call_duration_limits_chan = {0};
 		struct ast_bridge_features_limits call_duration_limits_peer = {0};
-		int abandon_call = 0; /* Flag raised if set limits fails sow e can abandon the call. */
+		int abandon_call = 0; /* Flag raised if set limits fails so we can abandon the call. */
 
 		if (ast_bridge_features_limits_construct(&call_duration_limits_chan)) {
 			ast_log(LOG_ERROR, "Could not construct caller duration limits. Bridge canceled.\n");




More information about the svn-commits mailing list