<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8119">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bridge_softmix.c: Report not talking immediately when muted.<br><br>Currently in app_confbridge if someone mutes a channel while that channel<br>is talking, the talk detection code is suspended while the channel is<br>muted. As far an an external observer is concerned, the muted channel's<br>talk status is still "talking" even though the channel is not contributing<br>audio to the conference bridge. When the channel is later unmuted, it<br>takes the usual 'dsp_silence_threshold' option time to clear the talking<br>status even though the channel may have stopped talking while the channel<br>was muted.<br><br>* In bridge_softmix.c, clear the talking status and report talking stopped<br>if the channel was talking when the channel is muted. When the channel is<br>unmuted and the channel is still talking then report the channel as<br>talking since it is contributing audio to the bridge again.<br><br>ASTERISK-27647<br><br>Change-Id: Ie4fdbc05a0bc7343c2972bab012e2567917b3d4e<br>---<br>M bridges/bridge_softmix.c<br>1 file changed, 46 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/19/8119/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c<br>index 1ff92ad..461b6e5 100644<br>--- a/bridges/bridge_softmix.c<br>+++ b/bridges/bridge_softmix.c<br>@@ -860,12 +860,17 @@<br> {<br> struct softmix_channel *sc = bridge_channel->tech_pvt;<br> struct softmix_bridge_data *softmix_data = bridge->tech_pvt;<br>+ int silent = 0;<br> int totalsilence = 0;<br> int cur_energy = 0;<br> int silence_threshold = bridge_channel->tech_args.silence_threshold ?<br> bridge_channel->tech_args.silence_threshold :<br> DEFAULT_SOFTMIX_SILENCE_THRESHOLD;<br>- char update_talking = -1; /* if this is set to 0 or 1, tell the bridge that the channel has started or stopped talking. */<br>+ /*<br>+ * If update_talking is set to 0 or 1, tell the bridge that the channel<br>+ * has started or stopped talking.<br>+ */<br>+ char update_talking = -1;<br> <br> /* Write the frame into the conference */<br> ast_mutex_lock(&sc->lock);<br>@@ -893,7 +898,7 @@<br> <br> /* The channel will be leaving soon if there is no dsp. */<br> if (sc->dsp) {<br>- ast_dsp_silence_with_energy(sc->dsp, frame, &totalsilence, &cur_energy);<br>+ silent = ast_dsp_silence_with_energy(sc->dsp, frame, &totalsilence, &cur_energy);<br> }<br> <br> if (bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_TALKER_SRC) {<br>@@ -910,15 +915,16 @@<br> }<br> <br> if (totalsilence < silence_threshold) {<br>- if (!sc->talking) {<br>+ if (!sc->talking && !silent) {<br>+ /* Tell the write process we have audio to be mixed out */<br>+ sc->talking = 1;<br> update_talking = 1;<br> }<br>- sc->talking = 1; /* tell the write process we have audio to be mixed out */<br> } else {<br> if (sc->talking) {<br>+ sc->talking = 0;<br> update_talking = 0;<br> }<br>- sc->talking = 0;<br> }<br> <br> /* Before adding audio in, make sure we haven't fallen behind. If audio has fallen<br>@@ -928,9 +934,8 @@<br> ast_slinfactory_flush(&sc->factory);<br> }<br> <br>- /* If a frame was provided add it to the smoother, unless drop silence is enabled and this frame<br>- * is not determined to be talking. */<br>- if (!(bridge_channel->tech_args.drop_silence && !sc->talking)) {<br>+ if (sc->talking || !bridge_channel->tech_args.drop_silence) {<br>+ /* Add frame to the smoother for mixing with other channels. */<br> ast_slinfactory_feed(&sc->factory, frame);<br> }<br> <br>@@ -939,6 +944,38 @@<br> <br> if (update_talking != -1) {<br> ast_bridge_channel_notify_talking(bridge_channel, update_talking);<br>+ }<br>+}<br>+<br>+/*!<br>+ * \internal<br>+ * \brief Check for voice status updates.<br>+ * \since 13.20.0<br>+ *<br>+ * \param bridge Which bridge we are in<br>+ * \param bridge_channel Which channel we are checking<br>+ *<br>+ * \return Nothing<br>+ */<br>+static void softmix_bridge_check_voice(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)<br>+{<br>+ struct softmix_channel *sc = bridge_channel->tech_pvt;<br>+<br>+ if (sc->talking<br>+ && bridge_channel->features->mute) {<br>+ /*<br>+ * We were muted while we were talking.<br>+ *<br>+ * Immediately stop contributing to mixing<br>+ * and report no longer talking.<br>+ */<br>+ ast_mutex_lock(&sc->lock);<br>+ ast_slinfactory_flush(&sc->factory);<br>+ sc->talking = 0;<br>+ ast_mutex_unlock(&sc->lock);<br>+<br>+ /* Notify that we are no longer talking. */<br>+ ast_bridge_channel_notify_talking(bridge_channel, 0);<br> }<br> }<br> <br>@@ -1119,6 +1156,7 @@<br> switch (frame->frametype) {<br> case AST_FRAME_NULL:<br> /* "Accept" the frame and discard it. */<br>+ softmix_bridge_check_voice(bridge, bridge_channel);<br> break;<br> case AST_FRAME_DTMF_BEGIN:<br> case AST_FRAME_DTMF_END:<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8119">change 8119</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8119"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ie4fdbc05a0bc7343c2972bab012e2567917b3d4e </div>
<div style="display:none"> Gerrit-Change-Number: 8119 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>