Skip to content
Snippets Groups Projects
Commit 17563e29 authored by Mark Spencer's avatar Mark Spencer
Browse files

Handle transitions in delivery time and non-delivery time

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2739 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 12bcd395
Branches
Tags
No related merge requests found
......@@ -122,8 +122,9 @@ int ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f)
}
}
memcpy(s->data + s->len, f->data, f->datalen);
/* If we're empty, reset delivery time */
if (!s->len)
/* If either side is empty, reset the delivery time */
if (!s->len || (!f->delivery.tv_sec && !f->delivery.tv_usec) ||
(!s->delivery.tv_sec && !s->delivery.tv_usec))
s->delivery = f->delivery;
s->len += f->datalen;
return 0;
......@@ -166,11 +167,14 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s)
/* In principle this should all be fine because if we are sending
G.729 VAD, the next timestamp will take over anyawy */
memmove(s->data, s->data + len, s->len);
s->delivery.tv_sec += (len * s->samplesperbyte) / 8000.0;
s->delivery.tv_usec += (((int)(len * s->samplesperbyte)) % 8000) * 125;
if (s->delivery.tv_usec > 1000000) {
s->delivery.tv_usec -= 1000000;
s->delivery.tv_sec += 1;
if (s->delivery.tv_sec || s->delivery.tv_usec) {
/* If we have delivery time, increment it, otherwise, leave it at 0 */
s->delivery.tv_sec += (len * s->samplesperbyte) / 8000.0;
s->delivery.tv_usec += (((int)(len * s->samplesperbyte)) % 8000) * 125;
if (s->delivery.tv_usec > 1000000) {
s->delivery.tv_usec -= 1000000;
s->delivery.tv_sec += 1;
}
}
}
/* Return frame */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment