[asterisk-commits] jrose: trunk r396189 - /trunk/bridges/bridge_holding.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 5 12:48:08 CDT 2013


Author: jrose
Date: Mon Aug  5 12:48:03 2013
New Revision: 396189

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396189
Log:
bridge_holding: Add suspsend/unsuspend callbacks

Suspend and unsuspend callbacks are added to the holding bridge so
that entertainment can be disabled and re-enabled when operations
would suspend a channel on the bridge (such as playback operations).
This fixes entertainment so that when those operations end, the
entertainment can pick back up and it also serves as an optimization.
Also, this patch fixes a bug caused by triggering ringing frames
immediately instead of pushing them to the queue which created a race
condition where sometimes parking with ringing during attended
transfers would cause the ringing to be interrupted by an unhold
frame.

(closes issue ASTERISK-22006)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2711/

Modified:
    trunk/bridges/bridge_holding.c

Modified: trunk/bridges/bridge_holding.c
URL: http://svnview.digium.com/svn/asterisk/trunk/bridges/bridge_holding.c?view=diff&rev=396189&r1=396188&r2=396189
==============================================================================
--- trunk/bridges/bridge_holding.c (original)
+++ trunk/bridges/bridge_holding.c Mon Aug  5 12:48:03 2013
@@ -81,7 +81,7 @@
 		ast_moh_stop(bridge_channel->chan);
 		break;
 	case IDLE_MODE_RINGING:
-		ast_indicate(bridge_channel->chan, -1);
+		ast_bridge_channel_queue_control_data(bridge_channel, -1, NULL, 0);
 		break;
 	case IDLE_MODE_NONE:
 		break;
@@ -124,7 +124,7 @@
 		ast_moh_start(bridge_channel->chan, ast_strlen_zero(moh_class) ? NULL : moh_class, NULL);
 		break;
 	case IDLE_MODE_RINGING:
-		ast_indicate(bridge_channel->chan, AST_CONTROL_RINGING);
+		ast_bridge_channel_queue_control_data(bridge_channel, AST_CONTROL_RINGING, NULL, 0);
 		break;
 	case IDLE_MODE_NONE:
 		break;
@@ -302,6 +302,44 @@
 	return 0;
 }
 
+static void holding_bridge_suspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	struct holding_channel *hc = bridge_channel ? bridge_channel->tech_pvt : NULL;
+
+	if (!hc) {
+		return;
+	}
+
+	if (!ast_test_flag(&hc->holding_roles, HOLDING_ROLE_PARTICIPANT)) {
+		return;
+	}
+
+	participant_stop_hold_audio(bridge_channel);
+}
+
+static void holding_bridge_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	struct holding_channel *hc = bridge_channel ? bridge_channel->tech_pvt : NULL;
+	struct ast_bridge_channel *announcer_channel = bridge->tech_pvt;
+
+	if (!hc) {
+		return;
+	}
+
+	/* If the bridge channel being unsuspended is not a participant, no need to do anything. */
+	if (!ast_test_flag(&hc->holding_roles, HOLDING_ROLE_PARTICIPANT)) {
+		return;
+	}
+
+	/* If there is currently an announcer channel in the bridge, there is also no need to do anything. */
+	if (announcer_channel) {
+		return;
+	}
+
+	/* Otherwise we need to resume the entertainment. */
+	participant_start_hold_audio(bridge_channel);
+}
+
 static struct ast_bridge_technology holding_bridge = {
 	.name = "holding_bridge",
 	.capabilities = AST_BRIDGE_CAPABILITY_HOLDING,
@@ -309,6 +347,8 @@
 	.write = holding_bridge_write,
 	.join = holding_bridge_join,
 	.leave = holding_bridge_leave,
+	.suspend = holding_bridge_suspend,
+	.unsuspend = holding_bridge_unsuspend,
 };
 
 static int unload_module(void)




More information about the asterisk-commits mailing list