Change clock system from 'system_clock' to 'steady_clock' 68/227868/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 17 Mar 2020 02:11:14 +0000 (11:11 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 17 Mar 2020 02:11:18 +0000 (11:11 +0900)
system_clock can get the accurate current time, but it is not monotonic clock system.
So the time from system_clock can be jumped if initializing system_clock is delayed.

Therefore, system_clock is not good to check exact time delay.
However, this module use time for checking expired time of audio data.
Thus, monotonic clock system is better to meet this purpose.

Because of this reason, this patch changes time system from system_clock to steady_clock.

Change-Id: I3860646c0fe4fc814eeea907597363a17951e8ce
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp
plugins/wakeup-manager/src/wakeup_audio_manager.cpp
plugins/wakeup-manager/src/wakeup_manager.cpp

index ef515c7..ed4ab66 100644 (file)
@@ -29,7 +29,7 @@ static atomic_bool g_stop_recorder_thread{false};
 
 static long long get_current_milliseconds_after_epoch()
 {
-       auto now = chrono::system_clock::now();
+       auto now = chrono::steady_clock::now();
        auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);
        /* number of milliseconds since the epoch of system_clock */
        auto value = now_ms.time_since_epoch();
index b907293..a69e567 100644 (file)
@@ -17,7 +17,7 @@ static int g_speech_pcm_wait_count = 800;
 
 static long long get_current_milliseconds_after_epoch()
 {
-       auto now = chrono::system_clock::now();
+       auto now = chrono::steady_clock::now();
        auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);
        /* number of milliseconds since the epoch of system_clock */
        auto value = now_ms.time_since_epoch();
index fcd239b..38d5cbe 100644 (file)
@@ -480,7 +480,7 @@ bool CWakeupManager::update_recognition_result(string appid, int result)
 
 static long long get_current_milliseconds_after_epoch()
 {
-       auto now = chrono::system_clock::now();
+       auto now = chrono::steady_clock::now();
        auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);
        /* number of milliseconds since the epoch of system_clock */
        auto value = now_ms.time_since_epoch();