From: Suyeon Hwang Date: Thu, 20 Jan 2022 06:57:51 +0000 (+0900) Subject: Add code to check whether the player is initialized X-Git-Tag: submit/tizen/20220218.073949~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbb6a2b9050b34d9846c84f9699c5fd49c638858;p=platform%2Fcore%2Fuifw%2Ftts.git Add code to check whether the player is initialized Change-Id: Ic651a374b408dd10f0cee033e49c080d678d178f Signed-off-by: Suyeon Hwang --- diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index c792b211..67249650 100644 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -1198,7 +1198,7 @@ int ttsd_player_create_instance(unsigned int uid) { if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); - return -1; + return TTSD_ERROR_OPERATION_FAILED; } /* Check uid is duplicated */ @@ -1233,7 +1233,7 @@ int ttsd_player_destroy_instance(unsigned int uid) if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); pthread_mutex_unlock(&g_player_control_mutex); - return -1; + return TTSD_ERROR_OPERATION_FAILED; } player_s* current; @@ -1289,7 +1289,7 @@ int ttsd_player_play(unsigned int uid) if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); pthread_mutex_unlock(&g_player_control_mutex); - return -1; + return TTSD_ERROR_OPERATION_FAILED; } if (NULL != g_playing_info) { @@ -1329,6 +1329,11 @@ int ttsd_player_play(unsigned int uid) int ttsd_player_stop(unsigned int uid) { pthread_mutex_lock(&g_player_control_mutex); + if (false == g_player_init) { + SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); + pthread_mutex_unlock(&g_player_control_mutex); + return TTSD_ERROR_OPERATION_FAILED; + } /* check whether uid is current playing or not */ if (NULL != g_playing_info) { @@ -1368,7 +1373,7 @@ int ttsd_player_clear(unsigned int uid) { if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); - return -1; + return TTSD_ERROR_OPERATION_FAILED; } /* Check uid */ @@ -1403,7 +1408,7 @@ int ttsd_player_pause(unsigned int uid) if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); pthread_mutex_unlock(&g_player_control_mutex); - return -1; + return TTSD_ERROR_OPERATION_FAILED; } /* Check uid */ @@ -1455,7 +1460,7 @@ int ttsd_player_resume(unsigned int uid) if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); pthread_mutex_unlock(&g_player_control_mutex); - return -1; + return TTSD_ERROR_OPERATION_FAILED; } /* Check id */ @@ -1487,7 +1492,7 @@ int ttsd_player_all_stop() if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); pthread_mutex_unlock(&g_player_control_mutex); - return -1; + return TTSD_ERROR_OPERATION_FAILED; } g_playing_info = NULL; @@ -1540,6 +1545,11 @@ int ttsd_player_all_stop() int ttsd_player_get_background_volume_ratio(double* ratio) { + if (false == g_player_init) { + SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); + return TTSD_ERROR_OPERATION_FAILED; + } + if (NULL == ratio) return -1; else @@ -1585,6 +1595,11 @@ static void __modify_background_volume(void* data) int ttsd_player_set_background_volume_ratio(double ratio) { + if (false == g_player_init) { + SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); + return TTSD_ERROR_OPERATION_FAILED; + } + SLOG(LOG_INFO, tts_tag(), "[Player DEBUG] ttsd_player_set_background_volume_ratio : %lf", ratio); double prev_ratio = g_bg_volume_ratio; @@ -1605,6 +1620,11 @@ int ttsd_player_set_background_volume_ratio(double ratio) int ttsd_player_wait_to_play(unsigned int uid) { + if (false == g_player_init) { + SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); + return TTSD_ERROR_OPERATION_FAILED; + } + SLOG(LOG_INFO, tts_tag(), "[Player INFO] wait to play (%u)", uid); g_audio_state = AUDIO_STATE_WAIT_FOR_PLAYING;