Fix data type from 'long' to 'long long' for time data 13/227113/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 10 Mar 2020 01:25:16 +0000 (10:25 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 10 Mar 2020 01:59:40 +0000 (01:59 +0000)
By specification of std::chrono::milliseconds, it needs at least 45bits memory
to store milliseconds data.
This patch changes data type from 'long' to 'long long' relative with time.

Change-Id: Ie973cb28a2a3ee0f9bd491aaa28afad01f0d7ca2
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
(cherry picked from commit d1bce194ecba74e8d3442a1669dfc6fb1bb2f2a2)

plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp
plugins/wakeup-manager/inc/wakeup_audio_manager.h
plugins/wakeup-manager/src/wakeup_audio_manager.cpp
plugins/wakeup-manager/src/wakeup_manager.cpp

index e1cb9abae46ac9354e92eea38518249c9c4309f7..ef515c7b9ce8ab228546d2a2f827210d010493e1 100644 (file)
@@ -27,7 +27,7 @@ static sound_stream_info_h g_stream_info = NULL;
 static thread g_recorder_thread;
 static atomic_bool g_stop_recorder_thread{false};
 
-static long get_current_milliseconds_after_epoch()
+static long long get_current_milliseconds_after_epoch()
 {
        auto now = chrono::system_clock::now();
        auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);
index 5e179c1c853724ca7696da729b710b6fcaf1f5ff..fdae38222e568ac219ff622a9daf3baff54bb88e 100644 (file)
@@ -79,7 +79,7 @@ public:
        void finalize_audio_data();
        void clear_audio_data();
 
-       void start_streaming_current_utterance_data(long start_time = 0);
+       void start_streaming_current_utterance_data(long long start_time = 0);
        void stop_streaming_current_utterance_data();
 
        void start_streaming_previous_utterance_data();
@@ -90,11 +90,11 @@ public:
 
        void set_background_volume(double ratio);
 private:
-       void add_audio_data(mas_speech_data& data, long time);
+       void add_audio_data(mas_speech_data& data, long long time);
        void notify_audio_data_recording(long time, void* data, int len);
 
        void streaming_previous_audio_data_thread_func();
-       void streaming_audio_data_thread_func(long start_time);
+       void streaming_audio_data_thread_func(long long start_time);
 
        int mSoundFocusWatchId{0};
        bool mRecordingRequired{false};
@@ -108,9 +108,9 @@ private:
        thread mStreamingPreviousThread;
        atomic_bool mStopStreamingPreviousThread{false};
 
-       static constexpr long mAudioRecordingDurationMilliseconds = 10 * 1000;
+       static constexpr long long mAudioRecordingDurationMilliseconds = 10 * 1000;
        typedef struct {
-               long time;
+               long long time;
                mas_speech_data data;
        } mas_speech_data_with_time;
        vector<mas_speech_data_with_time> mPreviousAudioData;
index b7c92888dd04316964d88819e24b54dae9fda763..b907293738bbf0f6666dc6d23dbe463103e34e99 100644 (file)
@@ -15,7 +15,7 @@ namespace wakeup
 /* Need to check whether this value needs to be configurable */
 static int g_speech_pcm_wait_count = 800;
 
-static long get_current_milliseconds_after_epoch()
+static long long get_current_milliseconds_after_epoch()
 {
        auto now = chrono::system_clock::now();
        auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);
@@ -203,7 +203,7 @@ void CAudioManager::streaming_previous_audio_data_thread_func()
        MWR_LOGI("[EXIT]");
 }
 
-void CAudioManager::streaming_audio_data_thread_func(long start_time)
+void CAudioManager::streaming_audio_data_thread_func(long long start_time)
 {
        MWR_LOGI("[ENTER]");
 
@@ -312,9 +312,9 @@ void CAudioManager::streaming_audio_data_thread_func(long start_time)
        MWR_LOGI("[EXIT]");
 }
 
-void CAudioManager::add_audio_data(mas_speech_data& data, long time)
+void CAudioManager::add_audio_data(mas_speech_data& data, long long time)
 {
-       long delta = mAudioRecordingDurationMilliseconds;
+       long long delta = mAudioRecordingDurationMilliseconds;
 
        notify_audio_data_recording(time, data.buffer, data.len);
 
@@ -342,7 +342,7 @@ void CAudioManager::feed_audio_data(mas_speech_streaming_event_e event, void* bu
        mas_speech_data speech_data;
        speech_data.buffer = vm_malloc_simple(len);
        if (speech_data.buffer) {
-               long time = get_current_milliseconds_after_epoch();
+               long long time = get_current_milliseconds_after_epoch();
 
                speech_data.event = event;
                speech_data.len = len;
@@ -359,7 +359,7 @@ void CAudioManager::finalize_audio_data()
        speech_data.len = sizeof(final_buffer);
        speech_data.buffer = vm_malloc_simple(speech_data.len);
        if (speech_data.buffer) {
-               long time = get_current_milliseconds_after_epoch();
+               long long time = get_current_milliseconds_after_epoch();
 
                memcpy(speech_data.buffer, final_buffer, speech_data.len);
                add_audio_data(speech_data, time);
@@ -390,7 +390,7 @@ void CAudioManager::notify_audio_data_recording(long time, void* data, int len)
        }
 }
 
-void CAudioManager::start_streaming_current_utterance_data(long start_time)
+void CAudioManager::start_streaming_current_utterance_data(long long start_time)
 {
        if (mStreamingThread.joinable()) {
                MWR_LOGE("ERROR : mStreamingThread is joinable, will not start a new thread");
index 25e4e60d8995fda88684618d80912f23c7cf8687..0fcf1d64b63845982f6cf18b54942224ac77a766 100644 (file)
@@ -478,7 +478,7 @@ bool CWakeupManager::update_recognition_result(string appid, int result)
        return true;
 }
 
-static long get_current_milliseconds_after_epoch()
+static long long get_current_milliseconds_after_epoch()
 {
        auto now = chrono::system_clock::now();
        auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);