Provide additional time information when feeding audio data 00/200800/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 4 Mar 2019 06:18:04 +0000 (15:18 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 13 Mar 2019 06:11:52 +0000 (15:11 +0900)
Change-Id: I3ef109cd59bc8525a2da5ccce3691faf21d25a3c

plugins/wakeup-manager/inc/wakeup_manager.h
plugins/wakeup-manager/src/wakeup_manager.cpp

index 22619cc98d7384733324980e244fad0eda3fefb2..6fce65ded5f1452441a148fd31b5dfb1b0d0e1a2 100644 (file)
@@ -162,7 +162,7 @@ typedef int (*wakeup_engine_set_audio_format)(int rate, int channel, int audio_t
 #define MA_WAKEUP_ENGINE_FUNC_GET_AUDIO_FORMAT "wakeup_engine_get_audio_format"
 typedef int (*wakeup_engine_get_audio_format)(int* rate, int* channel, int* audio_type);
 #define MA_WAKEUP_ENGINE_FUNC_FEED_AUDIO_DATA "wakeup_engine_feed_audio_data"
-typedef int (*wakeup_engine_feed_audio_data)(void* data, int len);
+typedef int (*wakeup_engine_feed_audio_data)(long time, void* data, int len);
 #define MA_WAKEUP_ENGINE_FUNC_GET_UTTERANCE_DATA_COUNT "wakeup_engine_get_utterance_data_count"
 typedef int (*wakeup_engine_get_utterance_data_count)(void);
 #define MA_WAKEUP_ENGINE_FUNC_GET_UTTERANCE_DATA "wakeup_engine_get_utterance_data"
index 620379cdec61e6525b4dc8c95a78df261812ecd3..2d234c80a059964a14bcb561d8053d97ab248d2e 100644 (file)
@@ -152,9 +152,21 @@ static void recorder_thread_func()
        static int buffer_count = 0;
 
        while (!(g_recorder_thread_should_stop.load())) {
-               char buffer[BUFFER_LENGTH + 10];
+               unsigned char buffer[BUFFER_LENGTH];
                int ret;
-               memset(buffer, '\0', BUFFER_LENGTH + 10);
+               memset(buffer, '\0', BUFFER_LENGTH);
+
+               auto now = std::chrono::system_clock::now();
+               auto now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(now);
+               /* number of milliseconds since the epoch of system_clock */
+               auto value = now_ms.time_since_epoch();
+
+               static long time = 0;
+               if (time == value.count()) {
+                       LOGE("[Recorder WARNING] Time value duplicated : %lu", time);
+               }
+               time = value.count();
+
                int read_bytes = audio_in_read(g_audio_h, buffer, BUFFER_LENGTH);
                if (0 > read_bytes) {
                        LOGE("[Recorder WARNING] Fail to read audio : %d", read_bytes);
@@ -165,7 +177,7 @@ static void recorder_thread_func()
                for (int loop = 0;loop < g_engine_count;loop++) {
                        if (g_wakeup_engine_info[loop].audio_data_require_status &&
                                g_wakeup_engine_info[loop].interface.feed_audio_data) {
-                               ret = g_wakeup_engine_info[loop].interface.feed_audio_data(buffer, read_bytes);
+                               ret = g_wakeup_engine_info[loop].interface.feed_audio_data(time, buffer, read_bytes);
                                if (0 == ret) {
                                        LOGE("[ERROR] Fail to feed speech data, ret(%d)", ret);
                                }