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 60ec594..08c4457 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 3b9f39f..0b0d8ad 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 a665ea5..4dbfc95 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;
 }