<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8392">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">apps/app_amd.c: Fixed total time and silence calculations<br><br>Between Asterisk 11 and Asterisk 13 there was a significant increase<br>in the number of AST_FRAME_NULL frames being processed by app_amd.c's<br>main loop. Each AST_FRAME_NULL frame was being counted as 100ms<br>towards the total time and silence. This may have been accurate<br>when app_amd.c was orginally added, but it is not in Asterisk 13.<br>As such the total analysis time and silence calculations were way<br>off effectively breaking app_amd.c<br><br>* Additional debug messages were added<br>* AST_FRAME_NULL are now ignored<br><br>ASTERISK-27610<br><br>Change-Id: I18aca01af98f87c1e168e6ae0d85c136d1df5ea9<br>---<br>M apps/app_amd.c<br>1 file changed, 17 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/apps/app_amd.c b/apps/app_amd.c<br>index e10f2cc..3f805bb 100644<br>--- a/apps/app_amd.c<br>+++ b/apps/app_amd.c<br>@@ -277,6 +277,12 @@<br> <br>       /* Now we go into a loop waiting for frames from the channel */<br>       while ((res = ast_waitfor(chan, 2 * maxWaitTimeForFrame)) > -1) {<br>+         int ms = 0;<br>+<br>+               /* Figure out how long we waited */<br>+          if (res > 0) {<br>+                    ms = 2 * maxWaitTimeForFrame - res;<br>+          }<br> <br>          /* If we fail to read in a frame, that means they hung up */<br>          if (!(f = ast_read(chan))) {<br>@@ -287,15 +293,22 @@<br>                   break;<br>                }<br> <br>-         if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_NULL || f->frametype == AST_FRAME_CNG) {<br>-                   /* If the total time exceeds the analysis time then give up as we are not too sure */<br>+                if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_CNG) {<br>+                        /* Figure out how long the frame is in milliseconds */<br>                        if (f->frametype == AST_FRAME_VOICE) {<br>                             framelength = (ast_codec_samples_count(f) / DEFAULT_SAMPLES_PER_MS);<br>                  } else {<br>-                             framelength = 2 * maxWaitTimeForFrame;<br>+                               framelength = ms;<br>                     }<br> <br>                  iTotalTime += framelength;<br>+<br>+                        ast_debug(1, "AMD: Channel [%s] frametype [%s] iTotalTime [%d] framelength [%d] totalAnalysisTime [%d]\n",<br>+                                   ast_channel_name(chan),<br>+                                      f->frametype == AST_FRAME_VOICE ? "AST_FRAME_VOICE" : "AST_FRAME_CNG",<br>+                                        iTotalTime, framelength, totalAnalysisTime);<br>+<br>+                    /* If the total time exceeds the analysis time then give up as we are not too sure */<br>                         if (iTotalTime >= totalAnalysisTime) {<br>                             ast_verb(3, "AMD: Channel [%s]. Too long...\n", ast_channel_name(chan));<br>                            ast_frfree(f);<br>@@ -306,7 +319,7 @@<br> <br>                        /* Feed the frame of audio into the silence detector and see if we get a result */<br>                    if (f->frametype != AST_FRAME_VOICE)<br>-                              dspsilence += 2 * maxWaitTimeForFrame;<br>+                               dspsilence += framelength;<br>                    else {<br>                                dspsilence = 0;<br>                               ast_dsp_silence(silenceDetector, f, &dspsilence);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8392">change 8392</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/8392"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I18aca01af98f87c1e168e6ae0d85c136d1df5ea9 </div>
<div style="display:none"> Gerrit-Change-Number: 8392 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Michael Cargile <mikec@vicidial.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>