Index: apps/app_confbridge.c =================================================================== --- apps/app_confbridge.c (revision 359977) +++ apps/app_confbridge.c (working copy) @@ -801,7 +801,7 @@ */ static int post_join_unmarked(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user) { - /* Play back audio prompt and start MOH if need be if we are the first participant */ + /* Play back audio prompt if we are the first participant */ if (conference_bridge->users == 1) { /* If audio prompts have not been quieted or this prompt quieted play it on out */ if (!ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_QUIET | USER_OPT_NOONLYPERSON)) { @@ -812,16 +812,38 @@ return -1; } } - /* If we need to start music on hold on the channel do so now */ - /* We need to re-check the number of users in the conference bridge here because another conference bridge - * participant could have joined while the above prompt was playing for the first user. - */ - 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 0; } + + /* If there are any other users without WAITMARKED set, but with MUSICONHOLD, take them off-hold + * now. */ + int nonwaiting_participants = 0; /* The number of other participants free of marked-user restrictions */ + struct conference_bridge_user *other_conference_bridge_user = NULL; + AST_LIST_TRAVERSE(&conference_bridge->users_list, other_conference_bridge_user, list) { + if (other_conference_bridge_user == conference_bridge_user) { + continue; + } + if (!ast_test_flag(&other_conference_bridge_user->u_profile, USER_OPT_WAITMARKED) || + ast_test_flag(&other_conference_bridge_user->u_profile, USER_OPT_MARKEDUSER) + ) { + nonwaiting_participants += 1; + if ( + other_conference_bridge_user->playing_moh && + ast_test_flag(&other_conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD) && + !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); + } + } + } + /* If there are no other unblocked users and if this user has MUSICONHOLD, turn on MoH. */ + if (!nonwaiting_participants && 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 0; /* No point in announcing participant-count if the user is on hold */ + } + /* Announce number of users if need be */ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ANNOUNCEUSERCOUNT)) { @@ -833,18 +855,6 @@ ao2_lock(conference_bridge); } - /* If we are the second participant we may need to stop music on hold on the first */ - if (conference_bridge->users == 2) { - struct conference_bridge_user *first_participant = AST_LIST_FIRST(&conference_bridge->users_list); - - /* 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); - } - } - if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ANNOUNCEUSERCOUNTALL) && (conference_bridge->users > conference_bridge_user->u_profile.announce_user_count_all_after)) { ao2_unlock(conference_bridge);