tsplayer: Update audio anthor time with nowUs [1/1]
authorLifeng Cao <lifeng.cao@amlogic.com>
Fri, 25 Dec 2020 15:53:04 +0000 (23:53 +0800)
committerLifeng Cao <lifeng.cao@amlogic.com>
Wed, 30 Dec 2020 12:48:41 +0000 (20:48 +0800)
PD#SWPL-39181

Problem:
When has stc and update anthor system time use sending
from user space. we need use calculate stc diff to
judge if need update anthor.

Solution:
Update audio anthor time with nowUs

Verify:
AH212

Change-Id: Idf2f4dcae1b1c40ec6176e78d3514bef1784506a
Signed-off-by: Lifeng Cao <lifeng.cao@amlogic.com>
drivers/media_sync/media_sync_core.c

index 0bc03bfde54156eb018f35306b558f574d67f460..3651e8ceb564952a77250e9d6bdc626b96f38cca 100644 (file)
@@ -212,14 +212,19 @@ long mediasync_ins_update_mediatime(s32 sSyncInsId,
                        if (diff_mediatime < 0
                                || ((diff_mediatime > 0)
                                && (get_llabs(diff_system_time - diff_mediatime) > MIN_UPDATETIME_THRESHOLD_US ))) {
-                               pr_info("MEDIA_SYNC_PCRMASTER update time\n");
+                               pr_info("MEDIA_SYNC_PCRMASTER update time system diff:%lld media diff:%lld current:%lld\n",
+                                                                                       diff_system_time,
+                                                                                       diff_mediatime,
+                                                                                       current_systemtime);
                                pInstance->mLastMediaTime = lMediaTime;
                                pInstance->mLastRealTime = current_systemtime;
                                pInstance->mLastStc = current_stc;
                        }
                } else {
                        if (current_stc != 0) {
-                               diff_system_time = lSystemTime - pInstance->mLastRealTime;
+                               diff_system_time = (lSystemTime - pInstance->mLastRealTime)
+                                                       * (current_stc - pInstance->mLastStc)
+                                                       / (current_systemtime - pInstance->mLastRealTime);
                                diff_mediatime = lMediaTime - pInstance->mLastMediaTime;
                        } else {
                                diff_system_time = lSystemTime - pInstance->mLastRealTime;
@@ -229,6 +234,10 @@ long mediasync_ins_update_mediatime(s32 sSyncInsId,
                        if (diff_mediatime < 0
                                || ((diff_mediatime > 0)
                                && (get_llabs(diff_system_time - diff_mediatime) > MIN_UPDATETIME_THRESHOLD_US ))) {
+                               pr_info("MEDIA_SYNC_PCRMASTER update time system diff:%lld media diff:%lld current:%lld\n",
+                                                                                       diff_system_time,
+                                                                                       diff_mediatime,
+                                                                                       current_systemtime);
                                pInstance->mLastMediaTime = lMediaTime;
                                pInstance->mLastRealTime = lSystemTime;
                                pInstance->mLastStc = current_stc + lSystemTime - current_systemtime;