<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8821">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">translate: generic plc not filled in after translation<br><br>If during translation a codec could not handle a given frame the translation<br>core would return NULL, thus not passing along the "missing" frame. Due to this<br>there was no frame to apply generic plc to, thus rendering it useless.<br><br>This patch makes it so the translation core produces an interpolated slin frame<br>in the cases where an attempt was made to translate to slin, but failed. This<br>interpolated frame is then passed along and can be used by the generic plc<br>algorithms to fill in the frame.<br><br>ASTERISK-27814 #close<br><br>Change-Id: I133d084da87adef913bf2ecc9c9240e3eaf4f40a<br>---<br>M formats/format_sln.c<br>M main/translate.c<br>2 files changed, 39 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/formats/format_sln.c b/formats/format_sln.c<br>index 6ad8c38..80d3484 100644<br>--- a/formats/format_sln.c<br>+++ b/formats/format_sln.c<br>@@ -54,6 +54,12 @@<br> static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)<br> {<br> int res;<br>+<br>+ /* Don't try to write an interpolated frame */<br>+ if (f->datalen == 0) {<br>+ return 0;<br>+ }<br>+<br> if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {<br> ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));<br> return -1;<br>diff --git a/main/translate.c b/main/translate.c<br>index 396c552..26f9c9b 100644<br>--- a/main/translate.c<br>+++ b/main/translate.c<br>@@ -524,6 +524,34 @@<br> return head;<br> }<br> <br>+static struct ast_frame *generate_interpolated_slin(struct ast_trans_pvt *p, struct ast_frame *f)<br>+{<br>+ struct ast_frame res = { AST_FRAME_VOICE };<br>+<br>+ /*<br>+ * If we've gotten here then we should have an interpolated frame that was not handled<br>+ * by the translation codec. So create an interpolated frame in the appropriate format<br>+ * that was going to be written. This frame might be handled later by other resources.<br>+ * For instance, generic plc.<br>+ *<br>+ * Note, generic plc is currently only available for the format type 'slin' (8KHz only -<br>+ * The generic plc code appears to have been based around that). Generic plc is filled<br>+ * in later on frame write.<br>+ */<br>+ if (!ast_opt_generic_plc || f->datalen != 0 ||<br>+ ast_format_cmp(p->explicit_dst, ast_format_slin) == AST_FORMAT_CMP_NOT_EQUAL) {<br>+ return NULL;<br>+ }<br>+<br>+ res.subclass.format = ast_format_cache_get_slin_by_rate(8000); /* ref bumped on dup */<br>+ res.samples = f->samples;<br>+ res.datalen = 0;<br>+ res.data.ptr = NULL;<br>+ res.offset = AST_FRIENDLY_OFFSET;<br>+<br>+ return ast_frdup(&res);<br>+}<br>+<br> /*! \brief do the actual translation */<br> struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, int consume)<br> {<br>@@ -586,6 +614,11 @@<br> }<br> out = p->t->frameout(p);<br> }<br>+<br>+ if (!out) {<br>+ out = generate_interpolated_slin(path, f);<br>+ }<br>+<br> if (out) {<br> /* we have a frame, play with times */<br> if (!ast_tvzero(delivery)) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8821">change 8821</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/8821"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: I133d084da87adef913bf2ecc9c9240e3eaf4f40a </div>
<div style="display:none"> Gerrit-Change-Number: 8821 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>