summaryrefslogtreecommitdiff
path: root/apps/confbridge
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2016-08-10 15:14:09 -0500
committerMark Michelson <mmichelson@digium.com>2016-09-01 13:38:58 -0500
commit63feffa126628e1a49e930f8fc9e7dfafc51422d (patch)
treed3982dbff8499f118da0039e0821ee2435ee7b14 /apps/confbridge
parent1bd571ef75900c78f98b047659de9d2d6c0c51b5 (diff)
ConfBridge: Make some announcements asynchronous.
Confbridge announcements tend to block a channel while they are being played. In some circumstances, this is warranted since you want that particular channel not to hear the announcement (Example: "John Doe has entered the conference"). For others it makes less sense. This change first introduces methods for playing sounds asynchronously into the conference. This is very similar to how synchronous sounds are played, except the channel initiating the playback does not wait for the sound to complete before moving on. Asynchronous announcements are used for two circumstances: * Sounds played for a user after they have left the bridge * Sounds that play first to a single user and then the rest of the conference (if the channel and conference use the same language) ASTERISK-26289 #close Reported by Mark Michelson Change-Id: Ie486bb3de1646d50894489030326a423e594ab0a
Diffstat (limited to 'apps/confbridge')
-rw-r--r--apps/confbridge/conf_state_multi_marked.c9
-rw-r--r--apps/confbridge/include/confbridge.h31
2 files changed, 34 insertions, 6 deletions
diff --git a/apps/confbridge/conf_state_multi_marked.c b/apps/confbridge/conf_state_multi_marked.c
index fabe99b90..17ca65cc2 100644
--- a/apps/confbridge/conf_state_multi_marked.c
+++ b/apps/confbridge/conf_state_multi_marked.c
@@ -160,12 +160,9 @@ static void leave_marked(struct confbridge_user *user)
if (need_prompt) {
/* Play back the audio prompt saying the leader has left the conference */
if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET)) {
- ao2_unlock(user->conference);
- ast_autoservice_start(user->chan);
- play_sound_file(user->conference,
- conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, user->conference->b_profile.sounds));
- ast_autoservice_stop(user->chan);
- ao2_lock(user->conference);
+ async_play_sound_file(user->conference,
+ conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, user->conference->b_profile.sounds),
+ NULL);
}
AST_LIST_TRAVERSE(&user->conference->waiting_list, user_iter, list) {
diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h
index 451d81098..5ea3b4527 100644
--- a/apps/confbridge/include/confbridge.h
+++ b/apps/confbridge/include/confbridge.h
@@ -386,6 +386,37 @@ int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data
*/
int play_sound_file(struct confbridge_conference *conference, const char *filename);
+/*!
+ * \brief Play sound file into conference bridge asynchronously
+ *
+ * If the initiator parameter is non-NULL, then the playback will wait for
+ * that initiator channel to get back in the bridge before playing the sound
+ * file. This way, the initiator has no danger of hearing a "clipped" file.
+ *
+ * \param conference The conference bridge to play sound file into
+ * \param filename Sound file to play
+ * \param initiator Channel that initiated playback.
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int async_play_sound_file(struct confbridge_conference *conference, const char *filename,
+ struct ast_channel *initiator);
+
+/*!
+ * \brief Indicate the initiator of an async sound file is ready for it to play.
+ *
+ * When playing an async sound file, the initiator is typically either out of the bridge
+ * or not in a position to hear the queued announcement. This function lets the announcement
+ * thread know that the initiator is now ready for the sound to play.
+ *
+ * If an async announcement was queued and no initiator channel was provided, then this is
+ * a no-op
+ *
+ * \param chan The channel that initiated the async announcement
+ */
+void async_play_sound_ready(struct ast_channel *chan);
+
/*! \brief Callback to be called when the conference has become empty
* \param conference The conference bridge
*/