AMLOGIC-2372: avsynclib fix phase adjustment bug
Reason for change: phase will accumulate
Test Procedure: clear phase when sync is lost
Risks: none
Change-Id: I49583f0a527dfaae606c1788664a6f82e0a33529
Signed-off-by: Song Zhao <song.zhao@amlogic.com>
diff --git a/src/avsync.c b/src/avsync.c
index 9833028..d02ef13 100644
--- a/src/avsync.c
+++ b/src/avsync.c
@@ -599,6 +599,7 @@
avsync->fps_interval = interval;
avsync->vsync_interval = interval;
avsync->phase_set = false;
+ avsync->phase = 0;
reset_pattern(avsync->pattern_detector);
}
while (!peek_item(avsync->frame_q, (void **)&frame, 0)) {
@@ -774,6 +775,7 @@
avsync->outlier_cnt = 0;
avsync->state = AV_SYNC_STAT_SYNC_LOST;
avsync->phase_set = false;
+ avsync->phase = 0;
reset_pattern(avsync->pattern_detector);
if (LIVE_MODE(avsync->mode) && avsync->last_disc_pts != fpts) {
@@ -853,7 +855,7 @@
uint32_t phase_thres = interval / 4;
if ( systime > fpts && (systime - fpts) < phase_thres) {
/* too aligned to current VSYNC, separate them to 1/4 VSYNC */
- avsync->phase += phase_thres - (systime - fpts);
+ avsync->phase = phase_thres - (systime - fpts);
avsync->phase_set = true;
log_info("[%d]adjust phase to %d", avsync->session_id, avsync->phase);
}
@@ -861,7 +863,7 @@
systime < (fpts + interval) &&
(systime - fpts) > interval - phase_thres) {
/* too aligned to previous VSYNC, separate them to 1/4 VSYNC */
- avsync->phase += phase_thres + fpts + interval - systime;
+ avsync->phase = phase_thres + fpts + interval - systime;
avsync->phase_set = true;
log_info("[%d]adjust phase to %d", avsync->session_id, avsync->phase);
}