<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19919">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_iax2: Fix jitterbuffer regression prior to receiving audio.<br><br>ASTERISK_29392 (a security fix) introduced a regression by<br>not processing frames when we don't have an audio format.<br><br>Currently, chan_iax2 only calls jb_get to read frames from<br>the jitterbuffer when the voiceformat has been set on the pvt.<br>However, this only happens when we receive a voice frame, which<br>means that prior to receiving voice frames, other types of frames<br>get stalled completely in the jitterbuffer.<br><br>To fix this, we now fallback to using the format negotiated during<br>call setup until we've actually received a voice frame with a format.<br>This ensures we're always able to read from the jitterbuffer.<br><br>ASTERISK-30354 #close<br>ASTERISK-30162 #close<br><br>Change-Id: Ie4fd1e8e088a145ad89e0427c2100a530e964fe9<br>---<br>M channels/chan_iax2.c<br>1 file changed, 39 insertions(+), 3 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c</span><br><span>index ab6bd61..5b3caf0 100644</span><br><span>--- a/channels/chan_iax2.c</span><br><span>+++ b/channels/chan_iax2.c</span><br><span>@@ -4158,9 +4158,19 @@</span><br><span>        now.tv_usec += 1000;</span><br><span> </span><br><span>     ms = ast_tvdiff_ms(now, pvt->rxcore);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        voicefmt = ast_format_compatibility_bitfield2format(pvt->voiceformat);</span><br><span style="color: hsl(0, 100%, 40%);">-       if (voicefmt && ms >= (next = jb_next(pvt->jb))) {</span><br><span style="color: hsl(120, 100%, 40%);">+      if (ms >= (next = jb_next(pvt->jb))) {</span><br><span style="color: hsl(120, 100%, 40%);">+          voicefmt = ast_format_compatibility_bitfield2format(pvt->voiceformat);</span><br><span style="color: hsl(120, 100%, 40%);">+             if (!voicefmt) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* pvt->voiceformat won't be set if we haven't received any voice frames yet.</span><br><span style="color: hsl(120, 100%, 40%);">+                       * In this case, fall back to using the format negotiated during call setup,</span><br><span style="color: hsl(120, 100%, 40%);">+                   * so we don't stall the jitterbuffer completely. */</span><br><span style="color: hsl(120, 100%, 40%);">+                      voicefmt = ast_format_compatibility_bitfield2format(pvt->peerformat);</span><br><span style="color: hsl(120, 100%, 40%);">+              }</span><br><span style="color: hsl(120, 100%, 40%);">+             if (!voicefmt) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* Really shouldn't happen, but if it does, should be looked into */</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_log(LOG_WARNING, "No voice format and no peer format available on %s, backlogging frame\n", ast_channel_name(pvt->owner));</span><br><span style="color: hsl(120, 100%, 40%);">+                   goto cleanup; /* Don't crash if there's no voice format */</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span>            ret = jb_get(pvt->jb, &frame, ms, ast_format_get_default_ms(voicefmt));</span><br><span>               switch(ret) {</span><br><span>                case JB_OK:</span><br><span>@@ -4202,6 +4212,7 @@</span><br><span>                  break;</span><br><span>               }</span><br><span>    }</span><br><span style="color: hsl(120, 100%, 40%);">+cleanup:</span><br><span>  if (pvt)</span><br><span>             update_jbsched(pvt);</span><br><span>         ast_mutex_unlock(&iaxsl[callno]);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19919">change 19919</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/+/19919"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Ie4fd1e8e088a145ad89e0427c2100a530e964fe9 </div>
<div style="display:none"> Gerrit-Change-Number: 19919 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <asterisk@phreaknet.org> </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-MessageType: merged </div>