[svn-commits] mmichelson: branch mmichelson/atxfer_features r394757 - /team/mmichelson/atxf...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 18 13:53:33 CDT 2013


Author: mmichelson
Date: Thu Jul 18 13:53:31 2013
New Revision: 394757

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394757
Log:
Ensure hooks are added back to bridge channels when bridge changes personality.

This adds an on_personality_change callback to personality details so that when the
bridge changes personality back to normal, the appropriate hooks may be added back
to the involved bridge channels.


Modified:
    team/mmichelson/atxfer_features/main/bridging_basic.c

Modified: team/mmichelson/atxfer_features/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_basic.c?view=diff&rev=394757&r1=394756&r2=394757
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Thu Jul 18 13:53:31 2013
@@ -163,6 +163,8 @@
 	unsigned int bridge_flags;
 	/*! User data for this personality. If used, must be an ao2 object */
 	void *pvt;
+	/*! Callback to be called when changing to the personality */
+	void (*on_personality_change)(struct ast_bridge *bridge);
 };
 
 /*!
@@ -2665,7 +2667,9 @@
 	SCOPED_LOCK(lock, bridge, ast_bridge_lock, ast_bridge_unlock);
 
 	ao2_cleanup(personality->details[personality->current].pvt);
+	personality->details[personality->current].pvt = NULL;
 	ast_clear_flag(&bridge->feature_flags, AST_FLAGS_ALL);
+	remove_hooks_on_personality_change(bridge);
 
 	personality->current = type;
 	if (user_data) {
@@ -2673,7 +2677,9 @@
 	}
 	personality->details[personality->current].pvt = user_data;
 	ast_set_flag(&bridge->feature_flags, personality->details[personality->current].bridge_flags);
-	remove_hooks_on_personality_change(bridge);
+	if (personality->details[personality->current].on_personality_change) {
+		personality->details[personality->current].on_personality_change(bridge);
+	}
 }
 
 static void personality_destructor(void *obj)
@@ -2683,6 +2689,20 @@
 
 	for (i = 0; i < BRIDGE_BASIC_PERSONALITY_END; ++i) {
 		ao2_cleanup(personality->details[i].pvt);
+	}
+}
+
+static void on_personality_change_normal(struct ast_bridge *bridge)
+{
+	struct ast_bridge_channel *iter;
+
+	AST_LIST_TRAVERSE(&bridge->channels, iter, entry) {
+		if (ast_bridge_hangup_hook(iter->features, basic_hangup_hook, NULL,
+				NULL, AST_BRIDGE_HOOK_REMOVE_ON_PULL) ||
+				ast_bridge_channel_setup_features(iter)) {
+			ast_log(LOG_WARNING, "Unable to set up bridge hooks for channel %s. Features may not work properly\n",
+					ast_channel_name(iter->chan));
+		}
 	}
 }
 
@@ -2693,6 +2713,7 @@
 	case BRIDGE_BASIC_PERSONALITY_NORMAL:
 		details->v_table = &personality_normal_v_table;
 		details->bridge_flags = NORMAL_FLAGS;
+		details->on_personality_change = on_personality_change_normal;
 		break;
 	case BRIDGE_BASIC_PERSONALITY_ATXFER:
 		details->v_table = &personality_atxfer_v_table;




More information about the svn-commits mailing list