<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15801">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">translate.c: Take sampling rate into account when checking codec's buffer size<br><br>Up/down sampling changes the number of samples produced by a translation.<br>This must be taken into account when checking the codec's buffer size.<br><br>ASTERISK-29328<br><br>Change-Id: I9aebe2f8788e00321a7f5c47aa97c617f39e9055<br>---<br>M main/translate.c<br>1 file changed, 7 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/translate.c b/main/translate.c</span><br><span>index a9665ae..6604d14 100644</span><br><span>--- a/main/translate.c</span><br><span>+++ b/main/translate.c</span><br><span>@@ -408,12 +408,18 @@</span><br><span>                 }</span><br><span>    }</span><br><span>    if (pvt->t->buffer_samples) {     /* do not pass empty frames to callback */</span><br><span style="color: hsl(120, 100%, 40%);">+            int src_srate = pvt->t->src_codec.sample_rate;</span><br><span style="color: hsl(120, 100%, 40%);">+          int dst_srate = pvt->t->dst_codec.sample_rate;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                ast_assert(src_srate > 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>              if (f->datalen == 0) { /* perform native PLC if available */</span><br><span>                      /* If the codec has native PLC, then do that */</span><br><span>                      if (!pvt->t->native_plc)</span><br><span>                               return 0;</span><br><span>            }</span><br><span style="color: hsl(0, 100%, 40%);">-               if (pvt->samples + f->samples > pvt->t->buffer_samples) {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+            if (pvt->samples + (f->samples * dst_srate / src_srate) > pvt->t->buffer_samples) {</span><br><span>                   ast_log(LOG_WARNING, "Out of buffer space\n");</span><br><span>                     return -1;</span><br><span>           }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15801">change 15801</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/15801"/><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-Change-Id: I9aebe2f8788e00321a7f5c47aa97c617f39e9055 </div>
<div style="display:none"> Gerrit-Change-Number: 15801 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Jean Aunis - Prescom <jean.aunis@prescom.fr> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-CC: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>