Consider processing state as no error 14/290314/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 20 Mar 2023 12:37:51 +0000 (21:37 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Wed, 19 Apr 2023 08:44:59 +0000 (08:44 +0000)
- Issue:
When stt_stop() is invoked while silence detection is enabled, sometimes
the framework makes error.

- Solution:
stt_stop() function works asynchronously and silence detection also has
asynchronous behavior. So, these two logic can conflict with each other.
To avoid this situation, this patch skip the remained logic if the state
is already changes to processing. Through this patch, even if the two
logic is invoked at once, one of the logic will properly stop the
recording and another one will pass the logic with no error.
Post condition of these two process is same, so it is fine to skip the
logic with no error handling.

Change-Id: I7d5e143153b7167f742ec64daf50f73041491fab
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/sttd_client_data.c
server/sttd_server.c

index 21b6d05..a47427a 100644 (file)
@@ -12,6 +12,8 @@
 */
 
 
+#include <stdatomic.h>
+
 #include "sttd_main.h"
 #include "stt_defs.h"
 #include "sttd_client_data.h"
@@ -19,7 +21,7 @@
 /* Client list */
 static GSList *g_client_list = NULL;
 
-static unsigned int g_cur_recog_uid = 0;
+static atomic_uint g_cur_recog_uid = 0;
 
 int client_show_list()
 {
index 3464518..c5abc1e 100644 (file)
@@ -1416,6 +1416,11 @@ int sttd_server_stop(unsigned int uid)
        }
 
        /* check uid state */
+       if (APP_STATE_PROCESSING == state) {
+               SLOG(LOG_INFO, TAG_STTD, "[Server] State is already processing. Skip stop behavior");
+               return STTD_ERROR_NONE;
+       }
+
        if (APP_STATE_RECORDING != state) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not recording");
                return STTD_ERROR_INVALID_STATE;