Send callback message to clients which set callback 73/280673/4
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 2 Sep 2022 02:11:14 +0000 (11:11 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 3 Nov 2022 04:44:20 +0000 (13:44 +0900)
- Requirements:
Server wants to send required IPC message when service state is changed.

- Solution:
Through previous commit, callback registration information was added.
Using this new information, server can decide whether the client require
to receive service state changed event. This patch adds checker for
deciding whether client regists callback.

Change-Id: I3ea1cc9e61626f393dc49a9bceff6c4b05a4a77c
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/ttsd_data.cpp
server/ttsd_data.h
server/ttsd_server.c

index 60ec5949544ad2606e21c825b209c28d3653b6b3..08c4457fdcd7444f3f46abbd0dc1c52ba412bf2a 100644 (file)
@@ -828,6 +828,19 @@ bool ttsd_data_is_paused_data_existing(unsigned int uid)
        return app_data->paused_data_existing;
 }
 
+bool ttsd_data_is_service_state_changed_cb_set(unsigned int uid)
+{
+       lock_guard<mutex> lock(g_app_data_mutex);
+       app_data_s* app_data = __get_client_app_data(uid);
+       if (nullptr == app_data) {
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid);
+               return false;
+       }
+
+       bool is_service_state_changed_cb_set = ((app_data->registered_event_mask & TTS_EVENT_MASK_SERVICE_STATE_CHANGED) != 0);
+       return is_service_state_changed_cb_set;
+}
+
 unsigned int ttsd_data_get_current_playing()
 {
        lock_guard<mutex> lock(g_app_data_mutex);
index 3b9f39f82ef2e6e006dc78a1a06007eb43541463..0b0d8ad137d1792b1a93640241a936e5815282d5 100644 (file)
@@ -134,6 +134,8 @@ int ttsd_data_set_paused_data(unsigned int uid, sound_data_s* sound_data);
 
 bool ttsd_data_is_paused_data_existing(unsigned int uid);
 
+bool ttsd_data_is_service_state_changed_cb_set(unsigned int uid);
+
 
 unsigned int ttsd_data_get_current_playing();
 
index a665ea513052f9098e8843f67cb23536d778bd84..4dbfc955377887d0b2155099fd9ba7597d7ccf2d 100644 (file)
@@ -562,7 +562,10 @@ static bool __notify_state_changed_event(int pid, unsigned int uid, app_tts_stat
                return false;
        }
 
-       ttsdc_ipc_send_set_service_state_message(pid, uid, args->before, args->current);
+       if (ttsd_data_is_service_state_changed_cb_set(uid)) {
+               ttsdc_ipc_send_set_service_state_message(pid, uid, args->before, args->current);
+       }
+
        return true;
 }