change codes to function such as ttsd_player_clear
[platform/core/uifw/tts.git] / server / ttsd_player.c
index a3b0bee..c96ed44 100644 (file)
@@ -628,7 +628,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                        SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
                                        /* unset volume policy, volume will be 100% */
                                        __unset_policy_for_playing();
-
+                                       ttsd_data_clear_sound_data(&sound_data);
                                        return;
                                }
 
@@ -653,6 +653,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                                SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
                                                /* unset volume policy, volume will be 100% */
                                                __unset_policy_for_playing();
+                                               ttsd_data_clear_sound_data(&sound_data);
                                                return;
                                        }
 
@@ -666,7 +667,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                        }
                                }
                                SLOG(LOG_INFO, tts_tag(), "[Player] Event(%d) utterance : uid(%d), uttid(%d)", sound_data->event, player->uid, sound_data->utt_id);
-                               ttsd_data_clear_sound_data(player->uid, &sound_data);
+                               ttsd_data_clear_sound_data(&sound_data);
                                continue;
                        }
                }
@@ -682,7 +683,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
 
-                               ttsd_data_clear_sound_data(player->uid, &sound_data);
+                               ttsd_data_clear_sound_data(&sound_data);
 
                                return;
                        }
@@ -710,7 +711,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                        /* unset volume policy, volume will be 100% */
                                        __unset_policy_for_playing();
 
-                                       ttsd_data_clear_sound_data(player->uid, &sound_data);
+                                       ttsd_data_clear_sound_data(&sound_data);
 
                                        return;
                                }
@@ -743,7 +744,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
 
-                               ttsd_data_clear_sound_data(player->uid, &sound_data);
+                               ttsd_data_clear_sound_data(&sound_data);
 
                                return;
                        }
@@ -786,9 +787,9 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
                        }
 
-                       ttsd_data_clear_sound_data(player->uid, &sound_data);
                        /* unset volume policy, volume will be 100% */
                        __unset_policy_for_playing();
+                       ttsd_data_clear_sound_data(&sound_data);
                        return;
                }
 
@@ -801,7 +802,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
-
+                               ttsd_data_clear_sound_data(&sound_data);
                                return;
                        }
 
@@ -810,15 +811,14 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                        pid, player->uid, sound_data->utt_id);
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
-
-                               ttsd_data_clear_sound_data(player->uid, &sound_data);
+                               ttsd_data_clear_sound_data(&sound_data);
                                return;
                        }
 
                        SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
                }
 
-               ttsd_data_clear_sound_data(player->uid, &sound_data);
+               ttsd_data_clear_sound_data(&sound_data);
 
                if (NULL == g_playing_info) {
                        SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Current player is NULL");
@@ -829,7 +829,7 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                        }
                        /* unset volume policy, volume will be 100% */
                        __unset_policy_for_playing();
-
+                       ttsd_data_clear_sound_data(&sound_data);
                        return;
                }
        }
@@ -1172,17 +1172,10 @@ int ttsd_player_play(int uid)
 
 int ttsd_player_stop(int uid)
 {
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
-               return -1;
-       }
-
-       /* Check uid */
-       player_s* current;
-       current = __player_get_item(uid);
-       if (NULL == current) {
-               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid);
-               return -1;
+       int ret = ttsd_player_clear(uid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to stop player, ret(%d)", ret);
+               return ret;
        }
 
        /* check whether uid is current playing or not */
@@ -1195,23 +1188,6 @@ int ttsd_player_stop(int uid)
                SLOG(LOG_DEBUG, tts_tag(), "[Player] No current playing");
        }
 
-       if (true == current->is_paused_data) {
-               if (NULL != current->paused_data) {
-                       if (NULL != current->paused_data->data) {
-                               free(current->paused_data->data);
-                               current->paused_data->data = NULL;
-                       }
-
-                       free(current->paused_data);
-                       current->paused_data = NULL;
-               }
-       }
-
-       current->event = TTSE_RESULT_EVENT_FINISH;
-       current->state = APP_STATE_READY;
-       current->is_paused_data = false;
-       current->idx = 0;
-
        if (NULL == g_playing_info) {
                SLOG(LOG_DEBUG, tts_tag(), "[Player] @@@@@");
                SLOG(LOG_ERROR, tts_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());