mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge "translate: generic plc not filled in after translation" into 13
This commit is contained in:
@@ -56,6 +56,12 @@ static struct ast_frame *generic_read(struct ast_filestream *s, int *whennext, u
|
|||||||
static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
|
static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
/* Don't try to write an interpolated frame */
|
||||||
|
if (f->datalen == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
|
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
|
||||||
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
|
ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -526,6 +526,34 @@ struct ast_trans_pvt *ast_translator_build_path(struct ast_format *dst, struct a
|
|||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct ast_frame *generate_interpolated_slin(struct ast_trans_pvt *p, struct ast_frame *f)
|
||||||
|
{
|
||||||
|
struct ast_frame res = { AST_FRAME_VOICE };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we've gotten here then we should have an interpolated frame that was not handled
|
||||||
|
* by the translation codec. So create an interpolated frame in the appropriate format
|
||||||
|
* that was going to be written. This frame might be handled later by other resources.
|
||||||
|
* For instance, generic plc.
|
||||||
|
*
|
||||||
|
* Note, generic plc is currently only available for the format type 'slin' (8KHz only -
|
||||||
|
* The generic plc code appears to have been based around that). Generic plc is filled
|
||||||
|
* in later on frame write.
|
||||||
|
*/
|
||||||
|
if (!ast_opt_generic_plc || f->datalen != 0 ||
|
||||||
|
ast_format_cmp(p->explicit_dst, ast_format_slin) == AST_FORMAT_CMP_NOT_EQUAL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.subclass.format = ast_format_cache_get_slin_by_rate(8000); /* ref bumped on dup */
|
||||||
|
res.samples = f->samples;
|
||||||
|
res.datalen = 0;
|
||||||
|
res.data.ptr = NULL;
|
||||||
|
res.offset = AST_FRIENDLY_OFFSET;
|
||||||
|
|
||||||
|
return ast_frdup(&res);
|
||||||
|
}
|
||||||
|
|
||||||
/*! \brief do the actual translation */
|
/*! \brief do the actual translation */
|
||||||
struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, int consume)
|
struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, int consume)
|
||||||
{
|
{
|
||||||
@@ -577,6 +605,11 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f,
|
|||||||
}
|
}
|
||||||
out = p->t->frameout(p);
|
out = p->t->frameout(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!out) {
|
||||||
|
out = generate_interpolated_slin(path, f);
|
||||||
|
}
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
/* we have a frame, play with times */
|
/* we have a frame, play with times */
|
||||||
if (!ast_tvzero(delivery)) {
|
if (!ast_tvzero(delivery)) {
|
||||||
|
Reference in New Issue
Block a user