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
This commit is contained in:
parent
f8d8bad957
commit
d4e10d5278
|
@ -797,6 +797,30 @@ static int stfu_n_find_frame(stfu_instance_t *in, stfu_queue_t *queue, uint32_t
|
|||
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)
|
||||
{
|
||||
uint32_t y;
|
||||
|
@ -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 *rframe = NULL;
|
||||
|
@ -888,12 +911,25 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)
|
|||
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) {
|
||||
int32_t delay = i->cur_ts - i->last_rd_ts;
|
||||
uint32_t need = abs(delay) / i->samples_per_packet;
|
||||
|
||||
|
||||
i->period_missing_count++;
|
||||
i->session_missing_count++;
|
||||
i->period_need_range += need;
|
||||
|
|
Loading…
Reference in New Issue