Add to release memory for sound data
[platform/core/uifw/tts.git] / server / ttsd_player.c
index 529a41d..d6e7be5 100644 (file)
@@ -338,6 +338,13 @@ 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();
+
+                                       if (NULL != sound_data->data) {
+                                               free(sound_data->data);
+                                               sound_data->data = NULL;
+                                       }
+                                       free(sound_data);
+                                       sound_data = NULL;
                                        return;
                                }
 
@@ -362,6 +369,12 @@ 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();
+                                               if (NULL != sound_data->data) {
+                                                       free(sound_data->data);
+                                                       sound_data->data = NULL;
+                                               }
+                                               free(sound_data);
+                                               sound_data = NULL;
                                                return;
                                        }
                                        if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
@@ -384,6 +397,14 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create audio out");
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
+
+                               if (NULL != sound_data->data) {
+                                       free(sound_data->data);
+                                       sound_data->data = NULL;
+                               }
+                               free(sound_data);
+                               sound_data = NULL;
+
                                return;
                        }
                        __set_policy_for_playing(40);
@@ -407,6 +428,15 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                        g_playing_info = NULL;
                                        /* unset volume policy, volume will be 100% */
                                        __unset_policy_for_playing();
+
+                                       if (NULL != sound_data->data) {
+                                               free(sound_data->data);
+                                               sound_data->data = NULL;
+                                       }
+
+                                       free(sound_data);
+                                       sound_data = NULL;
+
                                        return;
                                }
                                SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Prepare audio");
@@ -503,6 +533,13 @@ 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();
+                               if (NULL != sound_data->data) {
+                                       free(sound_data->data);
+                                       sound_data->data = NULL;
+                               }
+
+                               free(sound_data);
+                               sound_data = NULL;
                                return;
                        }
 
@@ -511,6 +548,13 @@ 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();
+                               if (NULL != sound_data->data) {
+                                       free(sound_data->data);
+                                       sound_data->data = NULL;
+                               }
+
+                               free(sound_data);
+                               sound_data = NULL;
                                return;
                        }