[asterisk-commits] kmoore: trunk r323107 - in /trunk/apps: ./ confbridge/include/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 13 09:39:02 CDT 2011


Author: kmoore
Date: Mon Jun 13 09:38:57 2011
New Revision: 323107

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=323107
Log:
MOH for only user not working with ConfBridge

This adds the playing_moh flag to the conference_bridge_user struct that
signifies when MOH should be playing so code doesn't have to guess whether
MOH is playing.

This change also adds the necessary checking to ensure that MOH continues
playing for a single user in a conference after the join sound is played when
configured to do so.

(closes ASTERISK-17988)
Review: https://reviewboard.asterisk.org/r/1263/

Modified:
    trunk/apps/app_confbridge.c
    trunk/apps/confbridge/include/confbridge.h

Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=323107&r1=323106&r2=323107
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Mon Jun 13 09:38:57 2011
@@ -618,7 +618,8 @@
 			if (other_conference_bridge_user == conference_bridge_user) {
 				continue;
 			}
-			if (ast_test_flag(&other_conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, other_conference_bridge_user->chan)) {
+			if (other_conference_bridge_user->playing_moh && !ast_bridge_suspend(conference_bridge->bridge, other_conference_bridge_user->chan)) {
+				other_conference_bridge_user->playing_moh = 0;
 				ast_moh_stop(other_conference_bridge_user->chan);
 				ast_bridge_unsuspend(conference_bridge->bridge, other_conference_bridge_user->chan);
 			}
@@ -664,6 +665,7 @@
 		 */
 		if (!conference_bridge->markedusers && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
 			ast_moh_start(conference_bridge_user->chan, conference_bridge_user->u_profile.moh_class, NULL);
+			conference_bridge_user->playing_moh = 1;
 		}
 	}
 }
@@ -692,6 +694,7 @@
 		 */
 		if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
 			ast_moh_start(conference_bridge_user->chan, conference_bridge_user->u_profile.moh_class, NULL);
+			conference_bridge_user->playing_moh = 1;
 		}
 		return;
 	}
@@ -709,6 +712,7 @@
 
 		/* Temporarily suspend the above participant from the bridge so we have control to stop MOH if needed */
 		if (ast_test_flag(&first_participant->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, first_participant->chan)) {
+			first_participant->playing_moh = 0;
 			ast_moh_stop(first_participant->chan);
 			ast_bridge_unsuspend(conference_bridge->bridge, first_participant->chan);
 		}
@@ -924,6 +928,7 @@
 					ast_bridge_remove(conference_bridge->bridge, other_participant->chan);
 				} else if (ast_test_flag(&other_participant->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, other_participant->chan)) {
 					ast_moh_start(other_participant->chan, other_participant->u_profile.moh_class, NULL);
+					other_participant->playing_moh = 1;
 					ast_bridge_unsuspend(conference_bridge->bridge, other_participant->chan);
 				}
 			}
@@ -933,6 +938,7 @@
 
 			if (ast_test_flag(&first_participant->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, first_participant->chan)) {
 				ast_moh_start(first_participant->chan, first_participant->u_profile.moh_class, NULL);
+				first_participant->playing_moh = 1;
 				ast_bridge_unsuspend(conference_bridge->bridge, first_participant->chan);
 			}
 		}
@@ -1309,7 +1315,13 @@
 	/* Play the Join sound to both the conference and the user entering. */
 	if (!quiet) {
 		const char *join_sound = conf_get_sound(CONF_SOUND_JOIN, conference_bridge_user.b_profile.sounds);
+		if (conference_bridge_user.playing_moh) {
+			ast_moh_stop(chan);
+		}
 		ast_stream_and_wait(chan, join_sound, "");
+		if (conference_bridge_user.playing_moh) {
+			ast_moh_start(chan, conference_bridge_user.u_profile.moh_class, NULL);
+		}
 		ast_autoservice_start(chan);
 		play_sound_file(conference_bridge, join_sound);
 		ast_autoservice_stop(chan);
@@ -1643,8 +1655,8 @@
 
 	/* See if music on hold is playing */
 	ao2_lock(conference_bridge);
-	if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
-		/* Just us so MOH is probably indeed going, let's stop it */
+	if (conference_bridge_user->playing_moh) {
+		/* MOH is going, let's stop it */
 		ast_moh_stop(bridge_channel->chan);
 	}
 	ao2_unlock(conference_bridge);
@@ -1654,7 +1666,7 @@
 
 	/* See if music on hold needs to be started back up again */
 	ao2_lock(conference_bridge);
-	if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
+	if (conference_bridge_user->playing_moh) {
 		ast_moh_start(bridge_channel->chan, conference_bridge_user->u_profile.moh_class, NULL);
 	}
 	ao2_unlock(conference_bridge);

Modified: trunk/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/include/confbridge.h?view=diff&rev=323107&r1=323106&r2=323107
==============================================================================
--- trunk/apps/confbridge/include/confbridge.h (original)
+++ trunk/apps/confbridge/include/confbridge.h Mon Jun 13 09:38:57 2011
@@ -215,6 +215,7 @@
 	struct ast_bridge_features features;         /*!< Bridge features structure */
 	struct ast_bridge_tech_optimizations tech_args; /*!< Bridge technology optimizations for talk detection */
 	unsigned int kicked:1;                       /*!< User has been kicked from the conference */
+	unsigned int playing_moh:1;                  /*!< MOH is currently being played to the user */
 	AST_LIST_ENTRY(conference_bridge_user) list; /*!< Linked list information */
 };
 




More information about the asterisk-commits mailing list