提交 d4e10d52 authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Michael Jerris

FS-8029: [jitterbuffer] fix robotic sound when using jitterbuffer when buffer…

FS-8029: [jitterbuffer] fix robotic sound when using jitterbuffer when buffer timestamps get behind that of the packet timestamps, such as when the source clock is out of sync with our clock
上级 f8d8bad9
...@@ -797,6 +797,30 @@ static int stfu_n_find_frame(stfu_instance_t *in, stfu_queue_t *queue, uint32_t ...@@ -797,6 +797,30 @@ static int stfu_n_find_frame(stfu_instance_t *in, stfu_queue_t *queue, uint32_t
return 0; return 0;
} }
static stfu_frame_t *stfu_n_find_least_unread_frame(stfu_instance_t *i)
{
uint32_t y, least = 0;
stfu_frame_t *frame = NULL, *lframe = NULL;
for (y = 0; y < i->out_queue->array_len; y++) {
frame = &i->out_queue->array[y];
if (!frame->was_read && (frame->ts < least || least == 0)) {
lframe = frame;
least = frame->ts;
}
}
for (y = 0; y < i->in_queue->array_len; y++) {
frame = &i->in_queue->array[y];
if (!frame->was_read && (frame->ts < least || least == 0)) {
least = frame->ts;
lframe = frame;
}
}
return lframe;
}
void stfu_n_dump(stfu_instance_t *i) void stfu_n_dump(stfu_instance_t *i)
{ {
uint32_t y; uint32_t y;
...@@ -818,7 +842,6 @@ void stfu_n_dump(stfu_instance_t *i) ...@@ -818,7 +842,6 @@ void stfu_n_dump(stfu_instance_t *i)
} }
} }
stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)
{ {
stfu_frame_t *rframe = NULL; stfu_frame_t *rframe = NULL;
...@@ -888,12 +911,25 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) ...@@ -888,12 +911,25 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)
return NULL; return NULL;
} }
if (!found && i->samples_per_packet) {
stfu_frame_t *least = stfu_n_find_least_unread_frame(i);
if (least && least->ts > i->cur_ts) {
if (stfu_log != null_logger && i->debug) {
stfu_log(STFU_LOG_EMERG, "%s SLIPPED BEHIND %d packets, RESYNCRONIZING\n", i->name, (least->ts - i->cur_ts) / i->samples_per_packet);
}
found = 1;
i->cur_ts = least->ts;
i->cur_seq = least->seq;
rframe = least;
}
}
if (!found && i->samples_per_packet) { if (!found && i->samples_per_packet) {
int32_t delay = i->cur_ts - i->last_rd_ts; int32_t delay = i->cur_ts - i->last_rd_ts;
uint32_t need = abs(delay) / i->samples_per_packet; uint32_t need = abs(delay) / i->samples_per_packet;
i->period_missing_count++; i->period_missing_count++;
i->session_missing_count++; i->session_missing_count++;
i->period_need_range += need; i->period_need_range += need;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论