<p>Kevin Harwell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8821">View Change</a></p><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, 33 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/21/8821/1</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..e016e7b 100644<br>--- a/formats/format_sln.c<br>+++ b/formats/format_sln.c<br>@@ -54,6 +54,11 @@<br> static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)<br> {<br> int res;<br>+<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..436501b 100644<br>--- a/main/translate.c<br>+++ b/main/translate.c<br>@@ -524,6 +524,29 @@<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 iterpolated frame that was not handled<br>+ * by the translation codec. Generic plc is currently only available for the format<br>+ * type 'slin'. The generic plc is filled 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 +609,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: newchange </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: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>