<p>Jean Aunis - Prescom has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15832">View Change</a></p><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;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/15832/1</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/+/15832">change 15832</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/+/15832"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I9aebe2f8788e00321a7f5c47aa97c617f39e9055 </div>
<div style="display:none"> Gerrit-Change-Number: 15832 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Jean Aunis - Prescom <jean.aunis@prescom.fr> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>