Enhance validation check for current player 19/246019/1 accepted/tizen/unified/20201029.124841 submit/tizen/20201028.060707
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 22 Oct 2020 06:31:44 +0000 (15:31 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 22 Oct 2020 06:31:44 +0000 (15:31 +0900)
Change-Id: Ibc7258394faec26456f639f14a39dd330ca196e6
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/ttsd_player.c

index 68677e6..9c16c39 100644 (file)
@@ -101,6 +101,21 @@ static double g_bg_volume_ratio;
 * Internal Interfaces
 */
 
+static bool __is_player_valid(player_s* player)
+{
+       if (NULL == player || NULL == g_playing_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] player is NULL");
+               return false;
+       }
+
+       if (g_playing_info != player || g_playing_info->uid != player->uid) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] player is not current player");
+               return false;
+       }
+
+       return true;
+}
+
 player_s* __player_get_item(int uid)
 {
        GList *iter = NULL;
@@ -544,8 +559,8 @@ static void __play_thread(void *data, Ecore_Thread *thread)
        __set_policy_for_playing(40);
        while (1) { // 1st while(1)
                /* check g_playing_info one more time */
-               if (NULL == g_playing_info) {
-                       SLOG(LOG_INFO, tts_tag(), "[Player INFO] No current player");
+               if (false == __is_player_valid(player)) {
+                       SLOG(LOG_INFO, tts_tag(), "[Player INFO] Player is not valid");
                        g_audio_state = AUDIO_STATE_READY;
                        ret = audio_out_unprepare(g_audio_h);
                        if (AUDIO_IO_ERROR_NONE != ret) {
@@ -606,7 +621,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                __unset_policy_for_playing();
                                return;
                        }
-                       SLOG(LOG_INFO, tts_tag(), "[Player] Sound info : id(%d) data(%p) size(%d) audiotype(%d) rate(%d) event(%d)", 
+                       SLOG(LOG_INFO, tts_tag(), "[Player] Sound info : id(%d) data(%p) size(%d) audiotype(%d) rate(%d) event(%d)",
                                sound_data->utt_id, sound_data->data, sound_data->data_size, sound_data->audio_type, sound_data->rate, sound_data->event);
                } else { // NO player->is_paused_data
                        sound_data = NULL;
@@ -690,7 +705,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                }
 
                                if (0 != ttsdc_send_utt_start_message(pid, player->uid, sound_data->utt_id)) {
-                                       SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", 
+                                       SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)",
                                                pid, player->uid, sound_data->utt_id);
                                }
                                SLOG(LOG_INFO, tts_tag(), "[Player] Start utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
@@ -717,7 +732,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                        __unset_policy_for_playing();
 
                                        if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
-                                               SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", 
+                                               SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)",
                                                        pid, player->uid, sound_data->utt_id);
                                        } else {
                                                SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
@@ -873,7 +888,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                        }
 
                        if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
-                               SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", 
+                               SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)",
                                        pid, player->uid, sound_data->utt_id);
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
@@ -1304,7 +1319,7 @@ int ttsd_player_clear(int uid)
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SECURE_SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid); 
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid);
                return -1;
        }