Send mode to server after prepare success 77/266377/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 11 Nov 2021 07:19:48 +0000 (16:19 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 11 Nov 2021 07:48:15 +0000 (16:48 +0900)
Current code, request set mode message by tidl is trasmitted before prepare is finished. This
behavior makes server stores proper mode information of client, so the policy works wrong way.

This patch makes client request set mode after prepare is finished. And also, this patch unify the
logic to request set mode from both tidl and dbus.

Change-Id: Ifa7201b26c6b6ad9cc206f7e9a4f259757e04702
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts_core.c
client/tts_dbus.c
client/tts_ipc.c
client/tts_ipc.h
client/tts_tidl.c
client/tts_tidl.h

index 3ed28a40b7eaff70bf692eb0a04dfb845c7e59e0..d529b86aa54b543b86483893dc442145e8b36e5f 100644 (file)
@@ -539,6 +539,8 @@ static Eina_Bool __prepare_sync_cb(tts_client_s* client)
        }
        // TODO: make function duplicated block
 
+       tts_ipc_request_set_mode(uid, tts_client_get_mode(client));
+
        tts_core_notify_state_changed(client, TTS_STATE_READY);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
@@ -1027,6 +1029,8 @@ int tts_core_receive_hello(int uid, int ret, int credential_needed)
                return TTS_ERROR_OPERATION_FAILED;
        }
 
+       tts_ipc_request_set_mode(uid, tts_client_get_mode(client));
+
        tts_core_notify_state_changed_async(client, TTS_STATE_READY);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
index 8519d29c73379fb17851338f0bb5406928043345..2a6c37ed529b7f5d142c9c332411f2cd0fe0a1ab 100644 (file)
@@ -152,11 +152,6 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                                        __tts_dbus_add_match(uid);
                                }
                                tts_core_receive_hello(uid, ret, credential_needed);
-
-                               tts_client_s* client = tts_client_get_by_uid(uid);
-                               if (client) {
-                                       tts_dbus_request_set_mode(uid, tts_client_get_mode(client));
-                               }
                        }
 
                        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
index c102982ddcb00e17959a7d10b961b04b02a68587..394b5deeb18ec6fdc14fd426991f7d29becd243d 100644 (file)
@@ -31,7 +31,8 @@ typedef enum {
        REQUEST_GET_PRIVATE_DATA,
        REQUEST_PLAY_PCM,
        REQUEST_STOP_PCM,
-       REQUEST_ADD_PCM
+       REQUEST_ADD_PCM,
+       REQUEST_SET_MODE
 } tts_ipc_vtable_e;
 
 
@@ -39,13 +40,13 @@ int(*ttsc_dbus_vtable[])() = { &tts_dbus_open_connection, &tts_dbus_close_connec
                                                &tts_dbus_request_hello, &tts_dbus_request_hello_sync, &tts_dbus_request_initialize,
                                                &tts_dbus_request_finalize, &tts_dbus_request_add_text, &tts_dbus_request_play, &tts_dbus_request_stop,
                                                &tts_dbus_request_pause, &tts_dbus_request_set_private_data, &tts_dbus_request_get_private_data,
-                                               &tts_dbus_request_play_pcm, &tts_dbus_request_stop_pcm, &tts_dbus_request_add_pcm };
+                                               &tts_dbus_request_play_pcm, &tts_dbus_request_stop_pcm, &tts_dbus_request_add_pcm, &tts_dbus_request_set_mode };
 
 int(*ttsc_tidl_vtable[])() = { &tts_tidl_open_connection, &tts_tidl_close_connection, &tts_tidl_stop_listening,
                                                &tts_tidl_request_hello, &tts_tidl_request_hello_sync, &tts_tidl_request_initialize,
                                                &tts_tidl_request_finalize, &tts_tidl_request_add_text, &tts_tidl_request_play, &tts_tidl_request_stop,
                                                &tts_tidl_request_pause, &tts_tidl_request_set_private_data, &tts_tidl_request_get_private_data,
-                                               &tts_tidl_request_play_pcm, &tts_tidl_request_stop_pcm, &tts_tidl_request_add_pcm };
+                                               &tts_tidl_request_play_pcm, &tts_tidl_request_stop_pcm, &tts_tidl_request_add_pcm, &tts_tidl_request_set_mode };
 
 static int (**g_vtable)();
 static tts_ipc_method_e g_ipc_method = TTS_IPC_METHOD_UNDEFINED;
@@ -373,3 +374,21 @@ int tts_ipc_request_add_pcm(int uid, int event, const char* data, int data_size,
        return g_vtable[REQUEST_ADD_PCM](uid, event, data, data_size, audio_type, rate);
 }
 // LCOV_EXCL_STOP
+
+int tts_ipc_request_set_mode(int uid, tts_mode_e mode)
+{
+       SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_set_mode");
+
+       tts_client_s* client = tts_client_get_by_uid(uid);
+       if (!client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == g_vtable) {
+               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       return g_vtable[REQUEST_SET_MODE](uid, mode);
+}
index a8af0b70416515a34e49b2ea411613bc399f312f..4900e772e5cf1113aac0fc0d6daf6d6290c3efaf 100644 (file)
@@ -58,6 +58,8 @@ int tts_ipc_request_stop_pcm(int uid);
 
 int tts_ipc_request_add_pcm(int uid, int event, const char* data, int data_size, int audio_type, int rate);
 
+int tts_ipc_request_set_mode(int uid, tts_mode_e mode);
+
 #ifdef __cplusplus
 }
 #endif
index 969ab39008a6f58f5fac8bc9ebd781fdb772c122..ef2ad4cd4be3f703ee86ac2b77af7470ad83feb8 100644 (file)
@@ -161,10 +161,6 @@ static void __on_connected(rpc_port_proxy_tts_h h, void *user_data)
        info->connected = true;
        info->connection_requesting = false;
        info->register_callback_invoked = false;
-       if (0 != rpc_port_proxy_tts_invoke_set_mode(info->rpc_h, uid, tts_client_get_mode(client))) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Failed to set mode");
-               return;
-       }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "Connected to server");
 }
@@ -884,3 +880,32 @@ int tts_tidl_request_add_pcm(int uid, int event, const char* data, int data_size
        return TTS_ERROR_NONE;
 }
 // LCOV_EXCL_STOP
+
+int tts_tidl_request_set_mode(int uid, tts_mode_e mode)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_set_mode");
+
+       tts_client_s* client = tts_client_get_by_uid(uid);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       tts_tidl_info_s* info = __get_tidl_info_s(uid);
+       if (NULL == info) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get tidl info");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!info->connected) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not Connected");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       if (0 != rpc_port_proxy_tts_invoke_set_mode(info->rpc_h, uid, mode)) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request set private data : Fail to invoke message");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       return TTS_ERROR_NONE;
+}
index 5bc88e832767a5a1fe6b420b0bcfcff28e5513a2..6af4168ba8bee5213962c3c3cf0330310c83e35e 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef __TTS_TIDL_H_
 #define __TTS_TIDL_H_
 
+#include <tts.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -50,6 +52,8 @@ int tts_tidl_request_stop_pcm(int uid);
 
 int tts_tidl_request_add_pcm(int uid, int event, const char* data, int data_size, int audio_type, int rate);
 
+int tts_tidl_request_set_mode(int uid, tts_mode_e mode);
+
 #ifdef __cplusplus
 }
 #endif