- Fix crash in __pkgmgr_status_cb
- Add a timer handle to notify error
Change-Id: Ie74e81db928273e88d81dd1a901eef6ee1e99852
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
static int g_max_text_size = -1;
static Ecore_Timer* g_check_state_timer = NULL;
static int g_max_text_size = -1;
static Ecore_Timer* g_check_state_timer = NULL;
+static Ecore_Timer* g_notify_error_timer = NULL;
/* for repetition */
static char* g_language = NULL;
/* for repetition */
static char* g_language = NULL;
static int __pkgmgr_status_cb(uid_t target_uid, int req_id, const char *type, const char *pkgname, const char *key, const char *val, const void *pmsg, void *data)
{
static int __pkgmgr_status_cb(uid_t target_uid, int req_id, const char *type, const char *pkgname, const char *key, const char *val, const void *pmsg, void *data)
{
+ // type (the type of the pkgname)
SLOG(LOG_INFO, TAG_TTSC, "[INFO] pkgmgr status cb is invoked. pkgname(%s), type(%s), key(%s), val(%s)", pkgname, type, key, val);
SLOG(LOG_INFO, TAG_TTSC, "[INFO] pkgmgr status cb is invoked. pkgname(%s), type(%s), key(%s), val(%s)", pkgname, type, key, val);
+ if (NULL == g_engine_name) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] engine name is NULL");
+ return 0;
+ }
+
if (0 != strncmp(g_engine_name, pkgname, strlen(g_engine_name))) {
SLOG(LOG_DEBUG, TAG_TTSC, "[WARN] this is not tts engine");
return 0;
} else {
if (0 != strncmp(g_engine_name, pkgname, strlen(g_engine_name))) {
SLOG(LOG_DEBUG, TAG_TTSC, "[WARN] this is not tts engine");
return 0;
} else {
- if (key && 0 == strncmp(key, "start", strlen(key))) {
+ if (key) {
+ if (0 == strncmp(key, "start", strlen(key))) {
if (NULL != g_pkgmgr_status) {
free(g_pkgmgr_status);
g_pkgmgr_status = NULL;
if (NULL != g_pkgmgr_status) {
free(g_pkgmgr_status);
g_pkgmgr_status = NULL;
g_engine_update_status = 1;
}
}
g_engine_update_status = 1;
}
}
- } else if (key && 0 == strncmp(g_pkgmgr_status, "install", strlen(g_pkgmgr_status)) && 0 == strncmp(key, "end", strlen(key))) {
+ } else if (0 == strncmp(key, "end", strlen(key)) && val && 0 == strncmp(val, "ok", strlen(val))) {
+ if (g_pkgmgr_status) {
+ if (0 == strncmp(g_pkgmgr_status, "install", strlen(g_pkgmgr_status)) || 0 == strncmp(g_pkgmgr_status, "update", strlen(g_pkgmgr_status))) {
SLOG(LOG_ERROR, TAG_TTSC, "[INFO] finish to install");
g_engine_update_status = 0;
SLOG(LOG_ERROR, TAG_TTSC, "[INFO] finish to install");
g_engine_update_status = 0;
+
+ free(g_pkgmgr_status);
+ g_pkgmgr_status = NULL;
+ }
+ }
+ }
ecore_timer_del(g_check_state_timer);
g_check_state_timer = NULL;
}
ecore_timer_del(g_check_state_timer);
g_check_state_timer = NULL;
}
+ /* Delete error timer before destroying handle */
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
client->utt_id = -1;
client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
client->utt_id = -1;
- ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+
if (client->conn_timer) {
ecore_timer_del(client->conn_timer);
client->conn_timer = NULL;
if (client->conn_timer) {
ecore_timer_del(client->conn_timer);
client->conn_timer = NULL;
client->reason = TTS_ERROR_PERMISSION_DENIED;
client->utt_id = -1;
client->reason = TTS_ERROR_PERMISSION_DENIED;
client->utt_id = -1;
- ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+
if (client->conn_timer) {
ecore_timer_del(client->conn_timer);
client->conn_timer = NULL;
if (client->conn_timer) {
ecore_timer_del(client->conn_timer);
client->conn_timer = NULL;
client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
client->utt_id = -1;
client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
client->utt_id = -1;
- ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+
return TTS_ERROR_OPERATION_FAILED;
} else if (TTS_ERROR_PERMISSION_DENIED == ret) {
return TTS_ERROR_OPERATION_FAILED;
} else if (TTS_ERROR_PERMISSION_DENIED == ret) {
client->reason = TTS_ERROR_PERMISSION_DENIED;
client->utt_id = -1;
client->reason = TTS_ERROR_PERMISSION_DENIED;
client->utt_id = -1;
- ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+
return TTS_ERROR_PERMISSION_DENIED;
} else if (TTS_ERROR_NONE != ret) {
return TTS_ERROR_PERMISSION_DENIED;
} else if (TTS_ERROR_NONE != ret) {
client->before_state = client->current_state;
client->current_state = TTS_STATE_READY;
client->before_state = client->current_state;
client->current_state = TTS_STATE_READY;
- ecore_timer_add(0.0, __tts_notify_state_changed, client->tts);
+ if (NULL != g_check_state_timer) {
+ ecore_timer_del(g_check_state_timer);
+ g_check_state_timer = NULL;
+ }
+ g_check_state_timer = ecore_timer_add(0.0, __tts_notify_state_changed, client->tts);
SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
return TTS_ERROR_NONE;
SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
return TTS_ERROR_NONE;
client->reason = ret;
client->utt_id = -1;
client->reason = ret;
client->utt_id = -1;
- ecore_timer_add(0, __tts_notify_error, client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, client->tts);
client->reason = ret;
client->utt_id = -1;
client->reason = ret;
client->utt_id = -1;
- ecore_timer_add(0, __tts_notify_error, client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, client->tts);
client->reason = ret;
client->utt_id = -1;
client->reason = ret;
client->utt_id = -1;
- ecore_timer_add(0, __tts_notify_error, client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, client->tts);
/* check handle */
if (NULL == client) {
SLOG(LOG_WARN, TAG_TTSC, "Fail to notify error msg : A handle is not valid");
/* check handle */
if (NULL == client) {
SLOG(LOG_WARN, TAG_TTSC, "Fail to notify error msg : A handle is not valid");
+ g_notify_error_timer = NULL;
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
}
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
}
+ g_notify_error_timer = NULL;
+
/* call callback function */
if (NULL != data->error_cb) {
/* call callback function */
if (NULL != data->error_cb) {
- ecore_timer_add(0, __tts_notify_error, data->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, data->tts);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
}
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
}
/* call callback function */
if (NULL != client->error_cb) {
/* call callback function */
if (NULL != client->error_cb) {
- ecore_timer_add(0, __tts_notify_error, client->tts);
+ if (NULL != g_notify_error_timer) {
+ ecore_timer_del(g_notify_error_timer);
+ g_notify_error_timer = NULL;
+ }
+ g_notify_error_timer = ecore_timer_add(0, __tts_notify_error, client->tts);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
}
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
}
#define SND_MGR_DUCKING_DURATION 500
#define SND_MGR_DUCKING_DURATION 500
-static int g_focus_watch_id;
+static int g_focus_watch_id = -1;
static double g_bg_volume_ratio;
static double g_bg_volume_ratio;
if (SOUND_MANAGER_ERROR_NONE != ret) {
SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to add sound focus watch callback");
sound_manager_destroy_stream_information(g_stream_info_h);
if (SOUND_MANAGER_ERROR_NONE != ret) {
SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to add sound focus watch callback");
sound_manager_destroy_stream_information(g_stream_info_h);
+ g_stream_info_h = NULL;
return -1;
} else {
SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Add sound focus watch callback");
return -1;
} else {
SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Add sound focus watch callback");
if (0 != ret) {
sound_manager_destroy_stream_information(g_stream_info_h);
sound_manager_remove_focus_state_watch_cb(g_focus_watch_id);
if (0 != ret) {
sound_manager_destroy_stream_information(g_stream_info_h);
sound_manager_remove_focus_state_watch_cb(g_focus_watch_id);
+ g_stream_info_h = NULL;
+ g_focus_watch_id = -1;
+
g_playing_info = NULL;
g_player_init = false;
g_playing_info = NULL;
g_player_init = false;
+ g_stream_info_h = NULL;
+ g_focus_watch_id = -1;
+