From cf73a4203f8a4a84e186dae525694250762c946a Mon Sep 17 00:00:00 2001 From: Kevin Harwell Date: Tue, 20 Mar 2018 15:28:12 -0500 Subject: bridge_softmix: Clear "talking" when a channel is put on hold This patch clears the talking flag from the channel (if already set), and notifies listeners when that channel is put on hold. Note however, if the endpoint continues to send audio frames and these are received by the bridge then that channel will be put back into a "talking" state even though they are on hold. ASTERISK-27755 #close Change-Id: I930e16c4662810f9f02043d69062f88173c5e2ef --- bridges/bridge_softmix.c | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c index 9986d9c73..16e1fb897 100644 --- a/bridges/bridge_softmix.c +++ b/bridges/bridge_softmix.c @@ -954,6 +954,30 @@ static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bri } } +/*! + * \internal + * \brief Clear talking flag, stop contributing to mixing and notify handlers. + * \since 13.21.0, 15.4.0 + * + * \param bridge_channel Which channel's talking to clear + * + * \return Nothing + */ +static void clear_talking(struct ast_bridge_channel *bridge_channel) +{ + struct softmix_channel *sc = bridge_channel->tech_pvt; + + if (sc->talking) { + ast_mutex_lock(&sc->lock); + ast_slinfactory_flush(&sc->factory); + sc->talking = 0; + ast_mutex_unlock(&sc->lock); + + /* Notify that we are no longer talking. */ + ast_bridge_channel_notify_talking(bridge_channel, 0); + } +} + /*! * \internal * \brief Check for voice status updates. @@ -966,23 +990,14 @@ static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bri */ static void softmix_bridge_check_voice(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel) { - struct softmix_channel *sc = bridge_channel->tech_pvt; - - if (sc->talking - && bridge_channel->features->mute) { + if (bridge_channel->features->mute) { /* * We were muted while we were talking. * * Immediately stop contributing to mixing * and report no longer talking. */ - ast_mutex_lock(&sc->lock); - ast_slinfactory_flush(&sc->factory); - sc->talking = 0; - ast_mutex_unlock(&sc->lock); - - /* Notify that we are no longer talking. */ - ast_bridge_channel_notify_talking(bridge_channel, 0); + clear_talking(bridge_channel); } } @@ -1113,6 +1128,17 @@ static int softmix_bridge_write_control(struct ast_bridge *bridge, struct ast_br */ switch (frame->subclass.integer) { + case AST_CONTROL_HOLD: + /* + * Doing anything for holds in a conference bridge could be considered a bit + * odd. That being said, in most cases one would probably want the talking + * flag cleared when 'hold' is pressed by the remote endpoint, so go ahead + * and do that here. However, that is all we'll do. Meaning if for some reason + * the endpoint continues to send audio frames despite pressing 'hold' talking + * will once again be detected for that channel. + */ + clear_talking(bridge_channel); + break; case AST_CONTROL_VIDUPDATE: if (!bridge->softmix.video_mode.video_update_discard || ast_tvdiff_ms(ast_tvnow(), softmix_data->last_video_update) > bridge->softmix.video_mode.video_update_discard) { -- cgit v1.2.3