From: Suyeon Hwang Date: Thu, 19 Jan 2023 06:01:08 +0000 (+0900) Subject: Fix coding convention about member variables and static functions X-Git-Tag: accepted/tizen/unified/20230215.100739~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1a794dc9d9e4927738967e9f730557a3bafedbb;p=platform%2Fcore%2Fuifw%2Ftts.git Fix coding convention about member variables and static functions - Issue: Using two underscores(__) as name of variables or functions is reserved by C and CPP compilers, so it may occur name colision. - Solution: Previously, most of the code followed old tizen coding convention. However, in case of name, the convention conflicts with C and CPP standard, because two underscore is already reserved as an identifier by C and CPP standard. Thus, using two underscores may cause some problems. To resolve this collision, this patch fixes the name of member variables and static functions to match C and CPP standard. Through this patch, CPP files in the project do not use two underscore as name of variables and functions anymore. Change-Id: I0ab5030b018d0d28c9cf2927ddbdf8711ecb788b Signed-off-by: Suyeon Hwang --- diff --git a/server/ActivatedModes.cpp b/server/ActivatedModes.cpp index 1d03a25f..e55fac1e 100644 --- a/server/ActivatedModes.cpp +++ b/server/ActivatedModes.cpp @@ -14,16 +14,17 @@ #include "ActivatedModes.h" + ActivatedModes::ActivatedModes() { - for (int i = 0; i < __numOfModes; i++) { - __modeCounts[i] = 0; + for (int i = 0; i < mNumOfModes; i++) { + mModeCounts[i] = 0; } - __modeFlags[0] = TTSE_MODE_MASK_DEFAULT; - __modeFlags[1] = TTSE_MODE_MASK_NOTIFICATION; - __modeFlags[2] = TTSE_MODE_MASK_SCREEN_READER; - __modeFlags[3] = TTSE_MODE_MASK_INTERRUPT; + mModeFlags[0] = TTSE_MODE_MASK_DEFAULT; + mModeFlags[1] = TTSE_MODE_MASK_NOTIFICATION; + mModeFlags[2] = TTSE_MODE_MASK_SCREEN_READER; + mModeFlags[3] = TTSE_MODE_MASK_INTERRUPT; } ActivatedModes::~ActivatedModes() @@ -33,21 +34,21 @@ ActivatedModes::~ActivatedModes() void ActivatedModes::addMode(ttsd_mode_e mode) { int index = getIndex(mode); - __modeCounts[index]++; + mModeCounts[index]++; } void ActivatedModes::removeMode(ttsd_mode_e mode) { int index = getIndex(mode); - __modeCounts[index]--; + mModeCounts[index]--; } int ActivatedModes::getModes() { int result = 0; - for (int i = 0; i < __numOfModes; i++) { - if (__modeCounts[i] > 0) { - result |= __modeFlags[i]; + for (int i = 0; i < mNumOfModes; i++) { + if (mModeCounts[i] > 0) { + result |= mModeFlags[i]; } } diff --git a/server/ActivatedModes.h b/server/ActivatedModes.h index 030e0efc..0fbf16ee 100644 --- a/server/ActivatedModes.h +++ b/server/ActivatedModes.h @@ -30,10 +30,10 @@ private: int getIndex(ttsd_mode_e mode); private: - static const int __numOfModes = 4; - ttse_mode_mask_e __modeFlags[__numOfModes]; + static const int mNumOfModes = 4; + ttse_mode_mask_e mModeFlags[mNumOfModes]; - int __modeCounts[__numOfModes]; + int mModeCounts[mNumOfModes]; }; diff --git a/server/AudioStream.cpp b/server/AudioStream.cpp index 5dd41c17..5ea3ab7a 100644 --- a/server/AudioStream.cpp +++ b/server/AudioStream.cpp @@ -24,21 +24,21 @@ static const char* FOCUS_SERVER_READY = "/tmp/.focus_server_ready"; AudioStream::AudioStream(): - __audioHandle(nullptr), - __audioType(TTSE_AUDIO_TYPE_RAW_S16), - __audioRate(16000), - __prepared(false), - __streamInfo(nullptr), - __focusAquired(false), - __state(AUDIO_STATE_NONE) + mAudioHandle(nullptr), + mAudioType(TTSE_AUDIO_TYPE_RAW_S16), + mAudioRate(16000), + mPrepared(false), + mStreamInfo(nullptr), + mFocusAquired(false), + mState(AUDIO_STATE_NONE) { createSoundStreamInfo(); - createAudioHandle(__audioType, __audioRate); + createAudioHandle(mAudioType, mAudioRate); } AudioStream::~AudioStream() { - __focusAquired = false; + mFocusAquired = false; unprepareAudioOut(); destroyAudioHandle(); @@ -47,40 +47,40 @@ AudioStream::~AudioStream() void AudioStream::destroySoundStreamInfo() { - int ret = sound_manager_destroy_stream_information(__streamInfo); + int ret = sound_manager_destroy_stream_information(mStreamInfo); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to destroy stream info"); } - __streamInfo = nullptr; - __focusAquired = false; + mStreamInfo = nullptr; + mFocusAquired = false; } int AudioStream::setAudioFormat(ttse_audio_type_e type, int rate) { - if (__audioType == type && __audioRate == rate) { + if (mAudioType == type && mAudioRate == rate) { return TTSD_ERROR_NONE; } SLOG(LOG_INFO, tts_tag(), "[AudioStream] Audio info is different. type:(%d)/(%d), rate:(%d)/(%d)", - __audioType, type, __audioRate, rate); + mAudioType, type, mAudioRate, rate); destroyAudioHandle(); if (TTSD_ERROR_NONE != createAudioHandle(type, rate)) { return TTSD_ERROR_OPERATION_FAILED; } - if (__focusAquired) { + if (mFocusAquired) { acquireSoundFocus(); } - __state = AUDIO_STATE_READY; + mState = AUDIO_STATE_READY; return TTSD_ERROR_NONE; } int AudioStream::acquireSoundFocus() { if (isAudioHandleValid() == false) { - int ret = createAudioHandle(__audioType, __audioRate); + int ret = createAudioHandle(mAudioType, mAudioRate); if (TTSD_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to create the audio handle. ret(%s)", get_error_message(ret)); return TTSD_ERROR_OPERATION_FAILED; @@ -95,20 +95,20 @@ int AudioStream::acquireSoundFocus() } } - int ret = sound_manager_acquire_focus(__streamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); + int ret = sound_manager_acquire_focus(mStreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to acquire focus. ret(%s)", get_error_message(ret)); } else { SLOG(LOG_DEBUG, tts_tag(), "[AudioStream] Success to acquire focus"); } - ret = audio_out_set_sound_stream_info(__audioHandle, __streamInfo); + ret = audio_out_set_sound_stream_info(mAudioHandle, mStreamInfo); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to set stream info. ret(%s)", get_error_message(ret)); return TTSD_ERROR_OPERATION_FAILED; } - __focusAquired = true; + mFocusAquired = true; return TTSD_ERROR_NONE; } @@ -120,7 +120,7 @@ int AudioStream::releaseSoundFocus() } sound_stream_focus_state_e focusState = SOUND_STREAM_FOCUS_STATE_RELEASED; - int ret = sound_manager_get_focus_state(__streamInfo, &focusState, nullptr); + int ret = sound_manager_get_focus_state(mStreamInfo, &focusState, nullptr); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to get focus state: %d", ret); } @@ -130,45 +130,45 @@ int AudioStream::releaseSoundFocus() return TTSD_ERROR_NONE; } - ret = sound_manager_release_focus(__streamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); + ret = sound_manager_release_focus(mStreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to release focus"); return TTSD_ERROR_OPERATION_FAILED; } - __focusAquired = false; + mFocusAquired = false; return TTSD_ERROR_NONE; } int AudioStream::prepareAudioOut() { - if (__prepared) { + if (mPrepared) { SLOG(LOG_DEBUG, tts_tag(), "[AudioStream] Audio is already prepared"); return TTSD_ERROR_NONE; } if (isAudioHandleValid() == false) { - int ret = createAudioHandle(__audioType, __audioRate); + int ret = createAudioHandle(mAudioType, mAudioRate); if (TTSD_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to create the audio handle. ret(%s)", get_error_message(ret)); return TTSD_ERROR_OPERATION_FAILED; } } - int ret = audio_out_prepare(__audioHandle); + int ret = audio_out_prepare(mAudioHandle); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to prepare audio : %d", ret); return TTSD_ERROR_OPERATION_FAILED; } - __prepared = true; - __state = AUDIO_STATE_PLAY; + mPrepared = true; + mState = AUDIO_STATE_PLAY; return TTSD_ERROR_NONE; } int AudioStream::playAudioData(char* buffer, unsigned int length) { - if (false == __prepared) { + if (false == mPrepared) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Audio is not prepared"); return TTSD_ERROR_OPERATION_FAILED; } @@ -178,7 +178,7 @@ int AudioStream::playAudioData(char* buffer, unsigned int length) return TTSD_ERROR_OPERATION_FAILED; } - int ret = audio_out_write(__audioHandle, static_cast(buffer), length); + int ret = audio_out_write(mAudioHandle, static_cast(buffer), length); if (0 > ret) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to audio write - %d", ret); return TTSD_ERROR_OPERATION_FAILED; @@ -189,7 +189,7 @@ int AudioStream::playAudioData(char* buffer, unsigned int length) int AudioStream::unprepareAudioOut() { - if (false == __prepared) { + if (false == mPrepared) { SLOG(LOG_DEBUG, tts_tag(), "[AudioStream] Audio is not prepared"); return TTSD_ERROR_NONE; } @@ -199,20 +199,20 @@ int AudioStream::unprepareAudioOut() return TTSD_ERROR_NONE; } - int ret = audio_out_unprepare(__audioHandle); + int ret = audio_out_unprepare(mAudioHandle); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to prepare audio : %d", ret); return TTSD_ERROR_OPERATION_FAILED; } - __prepared = false; - __state = AUDIO_STATE_READY; + mPrepared = false; + mState = AUDIO_STATE_READY; return TTSD_ERROR_NONE; } bool AudioStream::isAudioHandleValid() { - if (__audioHandle == nullptr) { + if (mAudioHandle == nullptr) { return false; } @@ -221,7 +221,7 @@ bool AudioStream::isAudioHandleValid() bool AudioStream::isStreamInfoValid() { - if (__streamInfo == nullptr) { + if (mStreamInfo == nullptr) { return false; } @@ -230,12 +230,12 @@ bool AudioStream::isStreamInfoValid() void AudioStream::waitForPlay() { - __state = AUDIO_STATE_WAIT_FOR_PLAYING; + mState = AUDIO_STATE_WAIT_FOR_PLAYING; } AudioStream::AudioState AudioStream::getState() { - return __state; + return mState; } int AudioStream::createAudioHandle(ttse_audio_type_e type, int rate) @@ -247,15 +247,15 @@ int AudioStream::createAudioHandle(ttse_audio_type_e type, int rate) sample_type = AUDIO_SAMPLE_TYPE_U8; } - int ret = audio_out_create_new(rate, AUDIO_CHANNEL_MONO, sample_type, &__audioHandle); + int ret = audio_out_create_new(rate, AUDIO_CHANNEL_MONO, sample_type, &mAudioHandle); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to create audio out handle. ret(%s)", get_error_message(ret)); return TTSD_ERROR_OPERATION_FAILED; } - __audioType = type; - __audioRate = rate; - __state = AUDIO_STATE_READY; + mAudioType = type; + mAudioRate = rate; + mState = AUDIO_STATE_READY; SLOG(LOG_INFO, tts_tag(), "[AudioStream] Create audio"); return TTSD_ERROR_NONE; @@ -263,19 +263,19 @@ int AudioStream::createAudioHandle(ttse_audio_type_e type, int rate) void AudioStream::destroyAudioHandle() { - if (nullptr == __audioHandle) { + if (nullptr == mAudioHandle) { SLOG(LOG_INFO, tts_tag(), "[AudioStream] Audio handle is not exist"); return; } - int ret = audio_out_destroy(__audioHandle); + int ret = audio_out_destroy(mAudioHandle); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to destroy audio out handle. ret(%s)", get_error_message(ret)); } else { SLOG(LOG_INFO, tts_tag(), "[AudioStream] Destroy audio"); } - __state = AUDIO_STATE_NONE; + mState = AUDIO_STATE_NONE; } int AudioStream::createSoundStreamInfo() @@ -292,19 +292,19 @@ int AudioStream::createSoundStreamInfo() } } - int ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_INFORMATION, __focusStateChangedCallback, this, &__streamInfo); - if (SOUND_MANAGER_ERROR_NONE != ret || __streamInfo == nullptr) { + int ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_INFORMATION, focusStateChangedCallback, this, &mStreamInfo); + if (SOUND_MANAGER_ERROR_NONE != ret || mStreamInfo == nullptr) { SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to create stream info(%d/%s)", ret, get_error_message(ret)); - __streamInfo = nullptr; + mStreamInfo = nullptr; return TTSD_ERROR_OPERATION_FAILED; } - __focusAquired = false; + mFocusAquired = false; SLOG(LOG_DEBUG, tts_tag(), "[AudioStream] Create stream info"); return TTSD_ERROR_NONE; } -void AudioStream::__focusStateChangedCallback(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, +void AudioStream::focusStateChangedCallback(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason_for_change, int sound_behavior, const char *extra_info, void *user_data) { diff --git a/server/AudioStream.h b/server/AudioStream.h index 8ae0a079..7c61f372 100644 --- a/server/AudioStream.h +++ b/server/AudioStream.h @@ -44,7 +44,7 @@ public: int playAudioData(char* buffer, unsigned int length); private: - static void __focusStateChangedCallback(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, + static void focusStateChangedCallback(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason_for_change, int sound_behavior, const char *extra_info, void *user_data); @@ -58,15 +58,15 @@ private: void destroySoundStreamInfo(); private: - audio_out_h __audioHandle; - ttse_audio_type_e __audioType; - int __audioRate; - bool __prepared; + audio_out_h mAudioHandle; + ttse_audio_type_e mAudioType; + int mAudioRate; + bool mPrepared; - sound_stream_info_h __streamInfo; - bool __focusAquired; + sound_stream_info_h mStreamInfo; + bool mFocusAquired; - AudioState __state; + AudioState mState; }; diff --git a/server/BackgroundVolume.cpp b/server/BackgroundVolume.cpp index fd7f6a9b..fc8990ca 100644 --- a/server/BackgroundVolume.cpp +++ b/server/BackgroundVolume.cpp @@ -18,7 +18,8 @@ using namespace std; -static const char* __get_ducking_stream(sound_stream_type_e stream_type) + +static const char* get_ducking_stream(sound_stream_type_e stream_type) { switch (stream_type) { @@ -37,22 +38,22 @@ static const char* __get_ducking_stream(sound_stream_type_e stream_type) return "Non matched stream"; } -static void __sound_stream_ducking_state_changed_cb(sound_stream_ducking_h stream_ducking, bool is_ducked, void *user_data) +static void ducking_state_changed_cb(sound_stream_ducking_h stream_ducking, bool is_ducked, void *user_data) { SLOG(LOG_DEBUG, tts_tag(), "[BackgroundVolume] is ducked : %d", is_ducked); return; } BackgroundVolume::BackgroundVolume(long long int duckingDuration): - __duckingDuration(duckingDuration), - __mediaStream(nullptr), - __notificationStream(nullptr), - __alarmStream(nullptr), - __volumeRatio(0.0), - __isVolumeDucked(false), - __changeVolumeTime(chrono::steady_clock::now()), - __postponedRecoverTimer(nullptr), - __postponedModifyTimer(nullptr) + mDuckingDuration(duckingDuration), + mMediaStream(nullptr), + mNotificationStream(nullptr), + mAlarmStream(nullptr), + mVolumeRatio(0.0), + mVolumeDucked(false), + mChangeVolumeTime(chrono::steady_clock::now()), + mPostponedRecoverTimer(nullptr), + mPostponedModifyTimer(nullptr) { int ret = createHandles(); if (TTSD_ERROR_NONE != ret) { @@ -63,47 +64,47 @@ BackgroundVolume::BackgroundVolume(long long int duckingDuration): BackgroundVolume::~BackgroundVolume() { long long int diff = getDurationAfterDucking(); - if (diff < __duckingDuration) { - usleep(__duckingDuration * 1000); + if (diff < mDuckingDuration) { + usleep(mDuckingDuration * 1000); } deactivateDuckingAll(); - if (nullptr != __postponedModifyTimer) { - void* result = ecore_timer_del(__postponedModifyTimer); - __postponedModifyTimer = nullptr; + if (nullptr != mPostponedModifyTimer) { + void* result = ecore_timer_del(mPostponedModifyTimer); + mPostponedModifyTimer = nullptr; SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Remove modification timer. result(%p)", result); } - if (nullptr != __postponedRecoverTimer) { - void* result = ecore_timer_del(__postponedRecoverTimer); - __postponedRecoverTimer = nullptr; + if (nullptr != mPostponedRecoverTimer) { + void* result = ecore_timer_del(mPostponedRecoverTimer); + mPostponedRecoverTimer = nullptr; SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Remove recover timer. result(%p)", result); } - if (__mediaStream) { - int ret = sound_manager_destroy_stream_ducking(__mediaStream); + if (mMediaStream) { + int ret = sound_manager_destroy_stream_ducking(mMediaStream); if (SOUND_MANAGER_ERROR_NONE != ret) SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to destroy media stream ducking, ret(%d)", ret); - __mediaStream = nullptr; + mMediaStream = nullptr; } else { SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Ducking handle for media stream is already destroyed"); } - if (__notificationStream) { - int ret = sound_manager_destroy_stream_ducking(__notificationStream); + if (mNotificationStream) { + int ret = sound_manager_destroy_stream_ducking(mNotificationStream); if (SOUND_MANAGER_ERROR_NONE != ret) SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to destroy notification stream ducking, ret(%d)", ret); - __notificationStream = nullptr; + mNotificationStream = nullptr; } else { SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Ducking handle for notification stream is already destroyed"); } - if (__alarmStream) { - int ret = sound_manager_destroy_stream_ducking(__alarmStream); + if (mAlarmStream) { + int ret = sound_manager_destroy_stream_ducking(mAlarmStream); if (SOUND_MANAGER_ERROR_NONE != ret) SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to destroy alarm stream ducking, ret(%d)", ret); - __alarmStream = nullptr; + mAlarmStream = nullptr; } else { SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Ducking handle for alarm stream is already destroyed"); } @@ -111,8 +112,8 @@ BackgroundVolume::~BackgroundVolume() void BackgroundVolume::setVolumeRatio(double ratio) { - SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Volume is changed from (%lf) to (%lf).", __volumeRatio.load(), ratio); - __volumeRatio = ratio; + SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Volume is changed from (%lf) to (%lf).", mVolumeRatio.load(), ratio); + mVolumeRatio = ratio; ecore_main_loop_thread_safe_call_async(modifyVolumeOnMainThread, static_cast(this)); } @@ -124,27 +125,27 @@ void BackgroundVolume::modifyVolumeOnMainThread(void* data) } BackgroundVolume* backgroundVolume = static_cast(data); - if (!backgroundVolume->__isVolumeDucked.load()) { + if (!backgroundVolume->mVolumeDucked.load()) { SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Volume is not changed yet."); return; } - if (backgroundVolume->__postponedModifyTimer != nullptr) { - SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Reserved volume modification exist. (%p)", backgroundVolume->__postponedModifyTimer); + if (backgroundVolume->mPostponedModifyTimer != nullptr) { + SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Reserved volume modification exist. (%p)", backgroundVolume->mPostponedModifyTimer); return; } long long int diff = backgroundVolume->getDurationAfterDucking(); - if (diff >= backgroundVolume->__duckingDuration) { - double ratio = backgroundVolume->__volumeRatio.load(); + if (diff >= backgroundVolume->mDuckingDuration) { + double ratio = backgroundVolume->mVolumeRatio.load(); SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Modify volume ratio(%lf) directly", ratio); backgroundVolume->deactivateDuckingAll(); backgroundVolume->activateDuckingAll(0, ratio); } else { - double delay = static_cast(backgroundVolume->__duckingDuration - diff) / 1000.0; - backgroundVolume->__postponedModifyTimer = ecore_timer_add(delay, postponedModifyTimerCb, data); - SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delay volume modification (%p), delay(%lf)", backgroundVolume->__postponedModifyTimer, delay); + double delay = static_cast(backgroundVolume->mDuckingDuration - diff) / 1000.0; + backgroundVolume->mPostponedModifyTimer = ecore_timer_add(delay, postponedModifyTimerCb, data); + SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delay volume modification (%p), delay(%lf)", backgroundVolume->mPostponedModifyTimer, delay); } } @@ -156,23 +157,23 @@ Eina_Bool BackgroundVolume::postponedModifyTimerCb(void* data) } BackgroundVolume* backgroundVolume = static_cast(data); - double ratio = backgroundVolume->__volumeRatio.load(); + double ratio = backgroundVolume->mVolumeRatio.load(); backgroundVolume->deactivateDuckingAll(); backgroundVolume->activateDuckingAll(0, ratio); SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delayed volume modification success. ratio(%lf)", ratio); - backgroundVolume->__postponedModifyTimer = nullptr; + backgroundVolume->mPostponedModifyTimer = nullptr; return EINA_FALSE; } double BackgroundVolume::getVolumeRatio() { - return __volumeRatio.load(); + return mVolumeRatio.load(); } void BackgroundVolume::applyVolumeRatio() { - __isVolumeDucked = true; + mVolumeDucked = true; ecore_main_loop_thread_safe_call_async(changeVolumeOnMainThread, static_cast(this)); } @@ -184,20 +185,20 @@ void BackgroundVolume::changeVolumeOnMainThread(void* data) } BackgroundVolume* backgroundVolume = static_cast(data); - if (nullptr != backgroundVolume->__postponedRecoverTimer) { - void* result = ecore_timer_del(backgroundVolume->__postponedRecoverTimer); - backgroundVolume->__postponedRecoverTimer = nullptr; + if (nullptr != backgroundVolume->mPostponedRecoverTimer) { + void* result = ecore_timer_del(backgroundVolume->mPostponedRecoverTimer); + backgroundVolume->mPostponedRecoverTimer = nullptr; SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Remove recover timer. result(%p)", result); } - double ratio = backgroundVolume->__volumeRatio.load(); + double ratio = backgroundVolume->mVolumeRatio.load(); SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Volume ratio(%lf)", ratio); if (0.0 > ratio || 1.0 < ratio) { SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Invalid ratio(%lf)", ratio); return; } - backgroundVolume->activateDuckingAll(backgroundVolume->__duckingDuration, ratio); + backgroundVolume->activateDuckingAll(backgroundVolume->mDuckingDuration, ratio); } void BackgroundVolume::activateDuckingAll(unsigned int duration, double ratio) @@ -215,7 +216,7 @@ void BackgroundVolume::activateDuckingAll(unsigned int duration, double ratio) activateDucking(SOUND_STREAM_TYPE_NOTIFICATION, duration, ratio); activateDucking(SOUND_STREAM_TYPE_ALARM, duration, ratio); - __changeVolumeTime = chrono::steady_clock::now(); + mChangeVolumeTime = chrono::steady_clock::now(); } bool BackgroundVolume::activateDucking(sound_stream_type_e type, unsigned int duration, double ratio) @@ -224,22 +225,22 @@ bool BackgroundVolume::activateDucking(sound_stream_type_e type, unsigned int du sound_stream_ducking_h handle = getStreamDuckingHandle(type); sound_manager_is_ducked(handle, &isDucked); if (isDucked) { - SLOG(LOG_DEBUG, tts_tag(), "[BackgroundVolume] The %s is already ducked", __get_ducking_stream(type)); + SLOG(LOG_DEBUG, tts_tag(), "[BackgroundVolume] The %s is already ducked", get_ducking_stream(type)); return false; } if (SOUND_MANAGER_ERROR_NONE != sound_manager_activate_ducking(handle, duration, ratio)) { - SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to activate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to activate ducking for %s", get_ducking_stream(type)); return false; } - SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Activate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Activate ducking for %s", get_ducking_stream(type)); return true; } void BackgroundVolume::recoverVolumeRatio() { - __isVolumeDucked = false; + mVolumeDucked = false; ecore_main_loop_thread_safe_call_async(recoverVolumeOnMainThread, static_cast(this)); } @@ -251,33 +252,33 @@ void BackgroundVolume::recoverVolumeOnMainThread(void* data) } BackgroundVolume* backgroundVolume = static_cast(data); - if (nullptr != backgroundVolume->__postponedRecoverTimer) { - SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Reserved volume recover exist. (%p)", backgroundVolume->__postponedRecoverTimer); + if (nullptr != backgroundVolume->mPostponedRecoverTimer) { + SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Reserved volume recover exist. (%p)", backgroundVolume->mPostponedRecoverTimer); return; } - if (nullptr != backgroundVolume->__postponedModifyTimer) { - void* result = ecore_timer_del(backgroundVolume->__postponedModifyTimer); - backgroundVolume->__postponedModifyTimer = nullptr; + if (nullptr != backgroundVolume->mPostponedModifyTimer) { + void* result = ecore_timer_del(backgroundVolume->mPostponedModifyTimer); + backgroundVolume->mPostponedModifyTimer = nullptr; SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Remove modification timer. result(%p)", result); } long long int diff = backgroundVolume->getDurationAfterDucking(); - if (diff >= backgroundVolume->__duckingDuration) { + if (diff >= backgroundVolume->mDuckingDuration) { SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Direct deactivate ducking"); backgroundVolume->deactivateDuckingAll(); } else { - double delay = static_cast(backgroundVolume->__duckingDuration - diff) / 1000.0; - backgroundVolume->__postponedRecoverTimer = ecore_timer_add(delay, postponedRecoverTimerCb, data); - SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delay deactivate ducking (%p), delay(%f)", backgroundVolume->__postponedRecoverTimer, delay); + double delay = static_cast(backgroundVolume->mDuckingDuration - diff) / 1000.0; + backgroundVolume->mPostponedRecoverTimer = ecore_timer_add(delay, postponedRecoverTimerCb, data); + SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delay deactivate ducking (%p), delay(%f)", backgroundVolume->mPostponedRecoverTimer, delay); } } long long int BackgroundVolume::getDurationAfterDucking() { auto currentTime = chrono::steady_clock::now(); - chrono::milliseconds diff = chrono::duration_cast(currentTime - __changeVolumeTime); + chrono::milliseconds diff = chrono::duration_cast(currentTime - mChangeVolumeTime); return diff.count(); } @@ -303,7 +304,7 @@ Eina_Bool BackgroundVolume::postponedRecoverTimerCb(void* data) BackgroundVolume* backgroundVolume = static_cast(data); backgroundVolume->deactivateDuckingAll(); - backgroundVolume->__postponedRecoverTimer = nullptr; + backgroundVolume->mPostponedRecoverTimer = nullptr; SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delayed unset policy success"); return EINA_FALSE; @@ -315,14 +316,14 @@ void BackgroundVolume::deactivateDucking(sound_stream_type_e type) sound_stream_ducking_h handle = getStreamDuckingHandle(type); sound_manager_is_ducked(handle, &isDucked); if (!isDucked) { - SLOG(LOG_DEBUG, tts_tag(), "[BackgroundVolume] The %s is already recovered from ducking", __get_ducking_stream(type)); + SLOG(LOG_DEBUG, tts_tag(), "[BackgroundVolume] The %s is already recovered from ducking", get_ducking_stream(type)); return; } if (SOUND_MANAGER_ERROR_NONE != sound_manager_deactivate_ducking(handle)) { - SLOG(LOG_WARN, tts_tag(), "[BackgroundVolume] Fail to deactivate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_WARN, tts_tag(), "[BackgroundVolume] Fail to deactivate ducking for %s", get_ducking_stream(type)); } else { - SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Deactivate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Deactivate ducking for %s", get_ducking_stream(type)); } } @@ -330,29 +331,32 @@ int BackgroundVolume::createHandles() { SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Create ducking handles"); - if (nullptr == __mediaStream) { - int ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_MEDIA, __sound_stream_ducking_state_changed_cb, nullptr, &__mediaStream); + if (nullptr == mMediaStream) { + int ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_MEDIA, + ducking_state_changed_cb, nullptr, &mMediaStream); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to create stream ducking for type media, ret(%d/%s)", ret, get_error_message(ret)); - __mediaStream = nullptr; + mMediaStream = nullptr; return TTSD_ERROR_OPERATION_FAILED; } } - if (nullptr == __notificationStream) { - int ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_NOTIFICATION, __sound_stream_ducking_state_changed_cb, nullptr, &__notificationStream); + if (nullptr == mNotificationStream) { + int ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_NOTIFICATION, + ducking_state_changed_cb, nullptr, &mNotificationStream); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to create stream ducking for notification type, ret(%d/%s)", ret, get_error_message(ret)); - __notificationStream = nullptr; + mNotificationStream = nullptr; return TTSD_ERROR_OPERATION_FAILED; } } - if (nullptr == __alarmStream) { - int ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_ALARM, __sound_stream_ducking_state_changed_cb, nullptr, &__alarmStream); + if (nullptr == mAlarmStream) { + int ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_ALARM, + ducking_state_changed_cb, nullptr, &mAlarmStream); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to create stream ducking for alarm type, ret(%d/%s)", ret, get_error_message(ret)); - __alarmStream = nullptr; + mAlarmStream = nullptr; return TTSD_ERROR_OPERATION_FAILED; } } @@ -362,7 +366,7 @@ int BackgroundVolume::createHandles() bool BackgroundVolume::isDuckingHandleValid() { - if (__mediaStream == nullptr || __notificationStream == nullptr || __alarmStream == nullptr) { + if (mMediaStream == nullptr || mNotificationStream == nullptr || mAlarmStream == nullptr) { return false; } @@ -374,11 +378,11 @@ sound_stream_ducking_h BackgroundVolume::getStreamDuckingHandle(sound_stream_typ switch (type) { case SOUND_STREAM_TYPE_MEDIA: - return __mediaStream; + return mMediaStream; case SOUND_STREAM_TYPE_NOTIFICATION: - return __notificationStream; + return mNotificationStream; case SOUND_STREAM_TYPE_ALARM: - return __alarmStream; + return mAlarmStream; default: SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Invalid stream type (%d)", type); diff --git a/server/BackgroundVolume.h b/server/BackgroundVolume.h index 1a3ff7a9..0bb2e97b 100644 --- a/server/BackgroundVolume.h +++ b/server/BackgroundVolume.h @@ -52,16 +52,16 @@ private: void deactivateDucking(sound_stream_type_e type); private: - const long long int __duckingDuration; - sound_stream_ducking_h __mediaStream; - sound_stream_ducking_h __notificationStream; - sound_stream_ducking_h __alarmStream; - std::atomic __volumeRatio; - std::atomic __isVolumeDucked; + const long long int mDuckingDuration; + sound_stream_ducking_h mMediaStream; + sound_stream_ducking_h mNotificationStream; + sound_stream_ducking_h mAlarmStream; + std::atomic mVolumeRatio; + std::atomic mVolumeDucked; - std::chrono::time_point __changeVolumeTime; - Ecore_Timer* __postponedRecoverTimer; - Ecore_Timer* __postponedModifyTimer; + std::chrono::time_point mChangeVolumeTime; + Ecore_Timer* mPostponedRecoverTimer; + Ecore_Timer* mPostponedModifyTimer; }; diff --git a/server/PlayerThread.cpp b/server/PlayerThread.cpp index ed584116..9b09ef19 100644 --- a/server/PlayerThread.cpp +++ b/server/PlayerThread.cpp @@ -18,6 +18,7 @@ using namespace std; + void PlayerThread::runThread(PlayerThread* player) { SLOG(LOG_INFO, tts_tag(), "[Player] Run player thread"); @@ -28,35 +29,35 @@ void PlayerThread::runThread(PlayerThread* player) PlayerThread::PlayerThread(PlayUtteranceCallback threadFucntion) { SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Constructor"); - __currentUid = TTS_INVALID_UID; - __playerAvailable = true; - __playUtterance = threadFucntion; + mCurrentUid = TTS_INVALID_UID; + mPlayerAvailable = true; + mPlayUtterance = threadFucntion; SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Start thread"); - __playerThread = thread(runThread, this); + mPlayerThread = thread(runThread, this); } PlayerThread::~PlayerThread() { SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Destructor"); - unique_lock controlLock(__controlMutex); - __playerAvailable = false; - __playUtterance = nullptr; + unique_lock controlLock(mControlMutex); + mPlayerAvailable = false; + mPlayUtterance = nullptr; tryToStopPlayer(); SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Thread is stopped or waiting"); - __threadCond.notify_all(); - __playerThread.join(); + mThreadCond.notify_all(); + mPlayerThread.join(); SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Finish thread"); } void PlayerThread::tryToStopPlayer() { - __currentUid = TTS_INVALID_UID; + mCurrentUid = TTS_INVALID_UID; - unique_lock stopCheckLock(__stopCheckMutex); - cv_status ret = __stopCheckCond.wait_for(stopCheckLock, chrono::milliseconds(500)); + unique_lock stopCheckLock(mStopCheckMutex); + cv_status ret = mStopCheckCond.wait_for(stopCheckLock, chrono::milliseconds(500)); if (ret == cv_status::timeout) { SLOG(LOG_WARN, tts_tag(), "[PlayerThread] Timeout stop request"); } @@ -64,12 +65,12 @@ void PlayerThread::tryToStopPlayer() bool PlayerThread::isPlayerAvailable() { - return __playerAvailable.load(); + return mPlayerAvailable.load(); } unsigned int PlayerThread::getCurrentUid() { - return __currentUid.load(); + return mCurrentUid.load(); } bool PlayerThread::isCurrentUid(unsigned int uid) @@ -78,7 +79,7 @@ bool PlayerThread::isCurrentUid(unsigned int uid) return false; } - if (uid != __currentUid.load()) { + if (uid != mCurrentUid.load()) { return false; } @@ -87,26 +88,26 @@ bool PlayerThread::isCurrentUid(unsigned int uid) void PlayerThread::requestPlay(unsigned int uid) { - lock_guard lock(__controlMutex); + lock_guard lock(mControlMutex); if (false == isPlayerAvailable()) { SLOG(LOG_ERROR, tts_tag(), "[PlayerThread] Player is already finished."); return; } SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Play request. uid(%u)", uid); - __currentUid = uid; - __threadCond.notify_all(); + mCurrentUid = uid; + mThreadCond.notify_all(); } void PlayerThread::requestStop() { - lock_guard lock(__controlMutex); + lock_guard lock(mControlMutex); if (false == isPlayerAvailable()) { SLOG(LOG_ERROR, tts_tag(), "[PlayerThread] Player is already finished."); return; } - unsigned int uid = __currentUid.load(); + unsigned int uid = mCurrentUid.load(); if (uid == TTS_INVALID_UID) { SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Thread is already stopped"); return; @@ -119,8 +120,8 @@ void PlayerThread::requestStop() void PlayerThread::runPlayer() { - unique_lock lock(__threadMutex); - if (nullptr == __playUtterance) { + unique_lock lock(mThreadMutex); + if (nullptr == mPlayUtterance) { SLOG(LOG_ERROR, tts_tag(), "[PlayerThread] Play utterance callback is not set"); return; } @@ -128,21 +129,21 @@ void PlayerThread::runPlayer() while (isPlayerAvailable()) { SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Wait playing"); if (isThreadStopped()) { - __threadCond.wait(lock); + mThreadCond.wait(lock); } while (false == isThreadStopped()) { unsigned int uid = getCurrentUid(); SLOG(LOG_INFO, tts_tag(), "[Player] Current player uid(%u)", uid); - __playUtterance(this, uid); + mPlayUtterance(this, uid); } - __stopCheckCond.notify_all(); + mStopCheckCond.notify_all(); } } bool PlayerThread::isThreadStopped() { - bool isStopped = (TTS_INVALID_UID == __currentUid.load()) || (false == isPlayerAvailable()); + bool isStopped = (TTS_INVALID_UID == mCurrentUid.load()) || (false == isPlayerAvailable()); return isStopped; } diff --git a/server/PlayerThread.h b/server/PlayerThread.h index 8fee3bb1..bf4fab85 100644 --- a/server/PlayerThread.h +++ b/server/PlayerThread.h @@ -43,17 +43,17 @@ private: bool isThreadStopped(); private: - std::atomic __currentUid; - std::atomic __playerAvailable; + std::atomic mCurrentUid; + std::atomic mPlayerAvailable; - std::thread __playerThread; - std::mutex __threadMutex; - std::mutex __controlMutex; - std::mutex __stopCheckMutex; - std::condition_variable __threadCond; - std::condition_variable __stopCheckCond; + std::thread mPlayerThread; + std::mutex mThreadMutex; + std::mutex mControlMutex; + std::mutex mStopCheckMutex; + std::condition_variable mThreadCond; + std::condition_variable mStopCheckCond; - PlayUtteranceCallback __playUtterance; + PlayUtteranceCallback mPlayUtterance; }; diff --git a/server/StateManager.h b/server/StateManager.h index eb8ddf2f..9f7243c9 100644 --- a/server/StateManager.h +++ b/server/StateManager.h @@ -34,11 +34,11 @@ private: static void notifyStateChangeOnMainThread(void* data); private: - ttsd_state_e __beforeState; - ttsd_state_e __currentState; - std::mutex __stateMutex; + ttsd_state_e mBeforeState; + ttsd_state_e mCurrentState; + std::mutex mStateMutex; - ttsd_state_changed_cb __callback; + ttsd_state_changed_cb mCallback; }; #endif /* __TTSD_STATE_MANAGER_H_ */ diff --git a/server/ttsd_data.cpp b/server/ttsd_data.cpp index 08c4457f..c8c55039 100644 --- a/server/ttsd_data.cpp +++ b/server/ttsd_data.cpp @@ -23,6 +23,7 @@ using namespace std; + typedef struct { char* lang; @@ -60,7 +61,7 @@ static atomic g_synth_control; static ActivatedModes g_activated_modes; #ifdef DATA_DEBUG -static void __data_show_list() +static void show_client_list() { SLOG(LOG_DEBUG, tts_tag(), "----- client list -----"); @@ -77,7 +78,7 @@ static void __data_show_list() SLOG(LOG_DEBUG, tts_tag(), "-----------------------"); } -static void __data_show_sound_list(app_data_s& app_data) +static void show_sound_list(app_data_s& app_data) { SLOG(LOG_DEBUG, tts_tag(), "----- Sound list -----"); @@ -95,7 +96,7 @@ static void __data_show_sound_list(app_data_s& app_data) SLOG(LOG_DEBUG, tts_tag(), "----------------------"); } -static void __data_show_text_list(app_data_s& app_data) +static void show_text_list(app_data_s& app_data) { SLOG(LOG_DEBUG, tts_tag(), "----- Text list -----"); @@ -113,7 +114,7 @@ static void __data_show_text_list(app_data_s& app_data) SLOG(LOG_DEBUG, tts_tag(), "---------------------"); } -static void __data_show_used_voice_list(app_data_s& app_data) +static void show_used_voice_list(app_data_s& app_data) { SLOG(LOG_DEBUG, tts_tag(), "----- Used voice list -----"); @@ -147,7 +148,7 @@ ttsd_synthesis_control_e ttsd_data_get_synth_control() return g_synth_control.load(); } -static app_data_s* __get_client_app_data(unsigned int uid) +static app_data_s* get_client_app_data(unsigned int uid) { for (auto& app_data : g_app_list) { if (app_data.uid == uid) { @@ -161,7 +162,7 @@ static app_data_s* __get_client_app_data(unsigned int uid) int ttsd_data_new_client(int pid, unsigned int uid, ttsd_mode_e mode, int registered_event_mask, tts_ipc_method_e method) { lock_guard lock(g_app_data_mutex); - if(nullptr != __get_client_app_data(uid) ) { + if(nullptr != get_client_app_data(uid) ) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is already registered (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -183,7 +184,7 @@ int ttsd_data_new_client(int pid, unsigned int uid, ttsd_mode_e mode, int regist g_activated_modes.addMode(mode); #ifdef DATA_DEBUG - __data_show_list(); + show_client_list(); #endif SLOG(LOG_INFO, tts_tag(), "[DATA INFO] New client. pid(%d), uid(%u)", app.pid, app.uid); @@ -191,7 +192,7 @@ int ttsd_data_new_client(int pid, unsigned int uid, ttsd_mode_e mode, int regist return TTSD_ERROR_NONE; } -static inline void __destroy_speak_data(speak_data_s* speak_data) +static inline void destroy_speak_data(speak_data_s* speak_data) { SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] utt(%d), text(%s), lang(%s), vctype(%d) speed(%d)", speak_data->utt_id, speak_data->text, speak_data->lang, speak_data->vctype, speak_data->speed); @@ -202,7 +203,7 @@ static inline void __destroy_speak_data(speak_data_s* speak_data) delete speak_data; } -static inline void __destroy_sound_data(sound_data_s* sound_data) +static inline void destroy_sound_data(sound_data_s* sound_data) { SLOG(LOG_ERROR, tts_tag(), "[DEBUG][%p] event(%d) data(%p) size(%d) rate(%d) utt(%d)", sound_data, sound_data->event, sound_data->data, sound_data->data_size, sound_data->rate, sound_data->utt_id); @@ -211,7 +212,7 @@ static inline void __destroy_sound_data(sound_data_s* sound_data) delete sound_data; } -static void __clean_data(app_data_s& app_data) +static void clean_data(app_data_s& app_data) { SLOG(LOG_ERROR, tts_tag(), "[INFO] Clean data. uid(%u)", app_data.uid); @@ -223,7 +224,7 @@ static void __clean_data(app_data_s& app_data) removed_last_uttid = speak_data->utt_id; - __destroy_speak_data(speak_data); + destroy_speak_data(speak_data); speak_data = nullptr; } @@ -236,7 +237,7 @@ static void __clean_data(app_data_s& app_data) continue; } - __destroy_sound_data(sound_data); + destroy_sound_data(sound_data); sound_data = nullptr; } @@ -261,14 +262,14 @@ int ttsd_data_delete_client(unsigned int uid) return TTSD_ERROR_INVALID_PARAMETER; } - __clean_data(g_app_list[index]); + clean_data(g_app_list[index]); ttsd_mode_e mode = g_app_list[index].mode; g_app_list.erase(g_app_list.begin() + index); g_activated_modes.removeMode(mode); #ifdef DATA_DEBUG - __data_show_list(); + show_client_list(); #endif SLOG(LOG_INFO, tts_tag(), "[DATA INFO] Client is deleted. uid(%u), index(%d)", uid, index); @@ -302,7 +303,7 @@ int ttsd_data_get_client_count() int ttsd_data_get_pid(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return -1; @@ -316,7 +317,7 @@ int ttsd_data_get_pid(unsigned int uid) tts_ipc_method_e ttsd_data_get_ipc_method(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTS_IPC_METHOD_UNDEFINED; @@ -328,7 +329,7 @@ tts_ipc_method_e ttsd_data_get_ipc_method(unsigned int uid) ttsd_mode_e ttsd_data_get_mode(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_MODE_DEFAULT; @@ -340,7 +341,7 @@ ttsd_mode_e ttsd_data_get_mode(unsigned int uid) int ttsd_data_set_credential(unsigned int uid, const char* credential) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -359,7 +360,7 @@ int ttsd_data_set_credential(unsigned int uid, const char* credential) char* ttsd_data_get_credential(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return nullptr; @@ -375,7 +376,7 @@ char* ttsd_data_get_credential(unsigned int uid) int ttsd_data_get_speak_data_size(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -387,7 +388,7 @@ int ttsd_data_get_speak_data_size(unsigned int uid) int ttsd_data_set_used_voice(unsigned int uid, const char* lang, int type) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -416,7 +417,7 @@ int ttsd_data_set_used_voice(unsigned int uid, const char* lang, int type) SLOG(LOG_ERROR, tts_tag(), "[DATA] lang(%s), vctype(%d)", used_voice.lang, used_voice.vctype); #ifdef DATA_DEBUG - __data_show_used_voice_list(*app_data); + show_used_voice_list(*app_data); #endif return -1; /* Need to load voice*/ @@ -425,7 +426,7 @@ int ttsd_data_set_used_voice(unsigned int uid, const char* lang, int type) int ttsd_data_reset_used_voice(unsigned int uid, ttsd_used_voice_cb callback) { unique_lock lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -452,7 +453,7 @@ int ttsd_data_reset_used_voice(unsigned int uid, ttsd_used_voice_cb callback) usedVoices.clear(); #ifdef DATA_DEBUG - __data_show_used_voice_list(*app_data); + show_used_voice_list(*app_data); #endif return TTSD_ERROR_NONE; @@ -482,13 +483,13 @@ void ttsd_data_destroy_speak_data(speak_data_s* speak_data) SECURE_SLOG(LOG_ERROR, tts_tag(), "[ERROR] data is nullptr"); return; } - __destroy_speak_data(speak_data); + destroy_speak_data(speak_data); } int ttsd_data_add_speak_data(unsigned int uid, speak_data_s* data) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -512,13 +513,13 @@ int ttsd_data_add_speak_data(unsigned int uid, speak_data_s* data) app_data->utt_id_stopped = 0; #ifdef DATA_DEBUG - __data_show_text_list(*app_data); + show_text_list(*app_data); #endif return TTSD_ERROR_NONE; } -static speak_data_s* __get_speak_data(app_data_s* app_data) +static speak_data_s* get_speak_data(app_data_s* app_data) { if (app_data->m_speak_data.empty()) { #ifdef DATA_DEBUG @@ -528,7 +529,7 @@ static speak_data_s* __get_speak_data(app_data_s* app_data) } #ifdef DATA_DEBUG - __data_show_text_list(*app_data); + show_text_list(*app_data); #endif return app_data->m_speak_data.front(); @@ -537,13 +538,13 @@ static speak_data_s* __get_speak_data(app_data_s* app_data) int ttsd_data_get_speak_data(unsigned int uid, speak_data_s** data) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; } - speak_data_s* speakData = __get_speak_data(app_data); + speak_data_s* speakData = get_speak_data(app_data); if (nullptr == speakData) { SLOG(LOG_WARN, tts_tag(), "[DATA WARNING] There is no speak data"); return TTSD_ERROR_OPERATION_FAILED; @@ -599,13 +600,13 @@ void ttsd_data_destroy_sound_data(sound_data_s* sound_data) return; } - __destroy_sound_data(sound_data); + destroy_sound_data(sound_data); } int ttsd_data_add_sound_data(unsigned int uid, sound_data_s* data) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -630,7 +631,7 @@ int ttsd_data_add_sound_data(unsigned int uid, sound_data_s* data) data, data->utt_id, data->data, data->data_size, data->audio_type); #ifdef DATA_DEBUG - __data_show_sound_list(*app_data); + show_sound_list(*app_data); #endif return TTSD_ERROR_NONE; @@ -646,7 +647,7 @@ static sound_data_s* __get_sound_data(app_data_s* app_data) } #ifdef DATA_DEBUG - __data_show_sound_list(*app_data); + show_sound_list(*app_data); #endif return app_data->m_wav_data.front(); @@ -655,7 +656,7 @@ static sound_data_s* __get_sound_data(app_data_s* app_data) sound_data_s* ttsd_data_get_first_sound_data(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return nullptr; @@ -674,7 +675,7 @@ sound_data_s* ttsd_data_get_first_sound_data(unsigned int uid) int ttsd_data_get_sound_data_size(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return -1; @@ -686,7 +687,7 @@ int ttsd_data_get_sound_data_size(unsigned int uid) int ttsd_data_set_last_sound_result_event(unsigned int uid, ttse_result_event_e event) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSE_ERROR_INVALID_PARAMETER; @@ -699,7 +700,7 @@ int ttsd_data_set_last_sound_result_event(unsigned int uid, ttse_result_event_e ttse_result_event_e ttsd_data_get_last_sound_result_event(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSE_RESULT_EVENT_FAIL; @@ -711,13 +712,13 @@ ttse_result_event_e ttsd_data_get_last_sound_result_event(unsigned int uid) int ttsd_data_clear_data(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; } - __clean_data(*app_data); + clean_data(*app_data); return TTSD_ERROR_NONE; } @@ -725,7 +726,7 @@ int ttsd_data_clear_data(unsigned int uid) app_tts_state_e ttsd_data_get_client_state(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return APP_STATE_NONE; @@ -748,7 +749,7 @@ static unsigned int __get_playing_app_uid() int ttsd_data_set_client_state(unsigned int uid, app_tts_state_e state) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -774,7 +775,7 @@ int ttsd_data_set_client_state(unsigned int uid, app_tts_state_e state) tts_app_play_type_e ttsd_data_get_play_type(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTS_APP_PLAY_TYPE_SYNTH; @@ -786,7 +787,7 @@ tts_app_play_type_e ttsd_data_get_play_type(unsigned int uid) int ttsd_data_set_play_type(unsigned int uid, tts_app_play_type_e type) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -800,7 +801,7 @@ int ttsd_data_set_play_type(unsigned int uid, tts_app_play_type_e type) int ttsd_data_set_paused_data(unsigned int uid, sound_data_s* sound_data) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return TTSD_ERROR_INVALID_PARAMETER; @@ -819,7 +820,7 @@ int ttsd_data_set_paused_data(unsigned int uid, sound_data_s* sound_data) bool ttsd_data_is_paused_data_existing(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return false; @@ -831,7 +832,7 @@ bool ttsd_data_is_paused_data_existing(unsigned int uid) bool ttsd_data_is_service_state_changed_cb_set(unsigned int uid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return false; @@ -859,7 +860,7 @@ int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data) } #ifdef DATA_DEBUG - __data_show_list(); + show_client_list(); #endif /* Copy app info */ @@ -891,7 +892,7 @@ int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data) bool ttsd_data_is_uttid_valid(unsigned int uid, int uttid) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); return false; @@ -924,7 +925,7 @@ int ttsd_data_get_activated_mode() int ttsd_data_save_error_log(unsigned int uid, FILE* fp) { lock_guard lock(g_app_data_mutex); - app_data_s* app_data = __get_client_app_data(uid); + app_data_s* app_data = get_client_app_data(uid); if (nullptr == app_data) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid client"); return -1; diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index a2198d4e..c55a461c 100644 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -25,7 +25,7 @@ #define SOUND_BUFFER_LENGTH 2048 /* CAUTION! -If you change this constant value. Please check the function '__set_timer_for_delay_recover()'. +If you change this constant value. Please check the function 'set_timer_for_delay_recover()'. If you choose too big value, it may cause integer overflow issue. */ static const int SND_MGR_DUCKING_DURATION = 500; @@ -56,7 +56,7 @@ static PlayerThread* g_player_thread = nullptr; /* * Internal Interfaces */ -static void __set_playing_status(bool is_playing) +static void set_playing_status(bool is_playing) { int ret = vconf_set_bool(TTS_PLAYING_STATUS_KEY, is_playing ? 1 : 0); SLOG(LOG_INFO, tts_tag(), "[Player] Set playing status (%s). ret(%d)", is_playing ? "True" : "False", ret); @@ -73,7 +73,7 @@ static void __set_playing_status(bool is_playing) } #ifdef BUF_SAVE_MODE -static void __open_buffer_dump_file() +static void open_buffer_dump_file() { pthread_mutex_lock(&g_buf_save_mutex); if (g_pFile) { @@ -111,7 +111,7 @@ static void __open_buffer_dump_file() pthread_mutex_unlock(&g_buf_save_mutex); } -static void __close_buffer_dump_file() +static void close_buffer_dump_file() { pthread_mutex_lock(&g_buf_save_mutex); @@ -123,7 +123,7 @@ static void __close_buffer_dump_file() pthread_mutex_unlock(&g_buf_save_mutex); } -static void __write_buffer_dump_file(const void* buffer, size_t length) +static void write_buffer_dump_file(const void* buffer, size_t length) { pthread_mutex_lock(&g_buf_save_mutex); @@ -138,7 +138,7 @@ static void __write_buffer_dump_file(const void* buffer, size_t length) } #endif -static void __set_policy_for_playing(void) +static void set_policy_for_playing(void) { g_audio_stream->acquireSoundFocus(); g_background_volume->applyVolumeRatio(); @@ -147,7 +147,7 @@ static void __set_policy_for_playing(void) SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] set policy for playing"); } -static void __unset_policy_for_playing() +static void unset_policy_for_playing() { g_audio_stream->releaseSoundFocus(); g_background_volume->recoverVolumeRatio(); @@ -156,7 +156,7 @@ static void __unset_policy_for_playing() SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] unset policy for playing"); } -static int __notify_utterance_started_event(unsigned int uid, int utt_id) +static int notify_utterance_started_event(unsigned int uid, int utt_id) { int pid = ttsd_data_get_pid(uid); if (pid <= 0) { @@ -165,9 +165,9 @@ static int __notify_utterance_started_event(unsigned int uid, int utt_id) } #ifdef BUF_SAVE_MODE - __open_buffer_dump_file(); + open_buffer_dump_file(); #endif - __set_playing_status(true); + set_playing_status(true); if (0 != ttsdc_ipc_send_utt_start_message(pid, uid, utt_id)) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to send Utterance Started Signal : pid(%d), uid(%u), utt_id(%d)", @@ -179,7 +179,7 @@ static int __notify_utterance_started_event(unsigned int uid, int utt_id) return TTSD_ERROR_NONE; } -static int __notify_utterance_completed_event(unsigned int uid, int utt_id) +static int notify_utterance_completed_event(unsigned int uid, int utt_id) { int pid = ttsd_data_get_pid(uid); if (pid <= 0) { @@ -188,9 +188,9 @@ static int __notify_utterance_completed_event(unsigned int uid, int utt_id) } #ifdef BUF_SAVE_MODE - __close_buffer_dump_file(); + close_buffer_dump_file(); #endif - __set_playing_status(false); + set_playing_status(false); if (0 != ttsdc_ipc_send_utt_finish_message(pid, uid, utt_id)) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%u), utt_id(%d)", @@ -202,7 +202,7 @@ static int __notify_utterance_completed_event(unsigned int uid, int utt_id) return TTSD_ERROR_NONE; } -static int __play_sound_data(PlayerThread* player, unsigned int uid, sound_data_s* sound_data) +static int play_sound_data(PlayerThread* player, unsigned int uid, sound_data_s* sound_data) { if (TTSD_ERROR_NONE != g_audio_stream->setAudioFormat(sound_data->audio_type, sound_data->rate)) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create audio out"); @@ -212,7 +212,7 @@ static int __play_sound_data(PlayerThread* player, unsigned int uid, sound_data_ // Check whether set_policy is done or not if (false == g_is_set_policy.load()) { SLOG(LOG_INFO, tts_tag(), "[Player INFO] Set policy"); - __set_policy_for_playing(); + set_policy_for_playing(); } if (TTSD_ERROR_NONE != g_audio_stream->prepareAudioOut()) { @@ -239,7 +239,7 @@ static int __play_sound_data(PlayerThread* player, unsigned int uid, sound_data_ temp_data, idx, &temp_data[idx], uid, sound_data->utt_id, len); #ifdef BUF_SAVE_MODE - __write_buffer_dump_file(&temp_data[idx], len); + write_buffer_dump_file(&temp_data[idx], len); #endif if (TTSD_ERROR_NONE != g_audio_stream->playAudioData(&temp_data[idx], len)) { @@ -262,7 +262,7 @@ static int __play_sound_data(PlayerThread* player, unsigned int uid, sound_data_ return TTSD_ERROR_NONE; } -static void __wait_sound_data(PlayerThread* player, unsigned int uid) +static void wait_sound_data(PlayerThread* player, unsigned int uid) { ttsd_synthesis_control_e prev_synth_control = TTSD_SYNTHESIS_CONTROL_EXPIRED; while (0 >= ttsd_data_get_sound_data_size(uid)) { @@ -278,21 +278,21 @@ static void __wait_sound_data(PlayerThread* player, unsigned int uid) if (TTSD_SYNTHESIS_CONTROL_DOING != synth_control) { if (AudioStream::AUDIO_STATE_PLAY == g_audio_stream->getState()) { g_audio_stream->unprepareAudioOut(); - __unset_policy_for_playing(); + unset_policy_for_playing(); } } prev_synth_control = synth_control; } } -static void __set_paused_data(unsigned int uid, sound_data_s* sound_data) { +static void set_paused_data(unsigned int uid, sound_data_s* sound_data) { int ret = ttsd_data_set_paused_data(uid, sound_data); if (TTSD_ERROR_NONE != ret) { ttsd_data_destroy_sound_data(sound_data); } } -static void __play_utterance_cb(PlayerThread* player, unsigned int uid) +static void play_utterance_cb(PlayerThread* player, unsigned int uid) { SLOG(LOG_DEBUG, tts_tag(), "[PLAYER] Start play utterance. uid(%u)", uid); @@ -304,7 +304,7 @@ static void __play_utterance_cb(PlayerThread* player, unsigned int uid) if (nullptr == sound_data) { break; } - __set_playing_status(true); + set_playing_status(true); 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); @@ -312,7 +312,7 @@ static void __play_utterance_cb(PlayerThread* player, unsigned int uid) if (nullptr == sound_data) { SLOG(LOG_ERROR, tts_tag(), "[Player] No sound data. Waiting mode"); - __wait_sound_data(player, uid); + wait_sound_data(player, uid); if (false == player->isCurrentUid(uid)) { SLOG(LOG_INFO, tts_tag(), "[Player] Finish thread"); break; @@ -329,7 +329,7 @@ static void __play_utterance_cb(PlayerThread* player, unsigned int uid) */ ttse_result_event_e last_event = ttsd_data_get_last_sound_result_event(uid); if (TTSE_RESULT_EVENT_START == sound_data->event || (TTSE_RESULT_EVENT_FINISH == last_event && TTSE_RESULT_EVENT_FINISH == sound_data->event)) { - int ret = __notify_utterance_started_event(uid, sound_data->utt_id); + int ret = notify_utterance_started_event(uid, sound_data->utt_id); if (TTSD_ERROR_INVALID_PARAMETER == ret) { break; } @@ -347,8 +347,8 @@ static void __play_utterance_cb(PlayerThread* player, unsigned int uid) SLOG(LOG_INFO, tts_tag(), "[Player] No Sound data. Event(%d), uid(%u), uttid(%d)", event, uid, utt_id); if (TTSE_RESULT_EVENT_FINISH == event) { - __unset_policy_for_playing(); - if (TTSD_ERROR_INVALID_PARAMETER == __notify_utterance_completed_event(uid, utt_id)) { + unset_policy_for_playing(); + if (TTSD_ERROR_INVALID_PARAMETER == notify_utterance_completed_event(uid, utt_id)) { break; } } @@ -357,10 +357,10 @@ static void __play_utterance_cb(PlayerThread* player, unsigned int uid) } } - int ret = __play_sound_data(player, uid, sound_data); + int ret = play_sound_data(player, uid, sound_data); if (TTSD_ERROR_INVALID_STATE == ret) { SLOG(LOG_DEBUG, tts_tag(), "[Player] Uid(%u) is paused", uid); - __set_paused_data(uid, sound_data); + set_paused_data(uid, sound_data); break; } else if (TTSD_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[Player] Fail to play audio data. uid(%u)", uid); @@ -376,8 +376,8 @@ static void __play_utterance_cb(PlayerThread* player, unsigned int uid) sound_data = nullptr; if (TTSE_RESULT_EVENT_FINISH == event) { - __unset_policy_for_playing(); - if (TTSD_ERROR_NONE != __notify_utterance_completed_event(uid, utt_id)) { + unset_policy_for_playing(); + if (TTSD_ERROR_NONE != notify_utterance_completed_event(uid, utt_id)) { break; } } @@ -391,10 +391,10 @@ static void __play_utterance_cb(PlayerThread* player, unsigned int uid) } g_audio_stream->unprepareAudioOut(); - __unset_policy_for_playing(); + unset_policy_for_playing(); #ifdef BUF_SAVE_MODE - __close_buffer_dump_file(); + close_buffer_dump_file(); #endif SLOG(LOG_DEBUG, tts_tag(), "[PLAYER] Finish play utterance. uid(%u)", uid); @@ -407,7 +407,7 @@ int ttsd_player_init() { g_background_volume = new BackgroundVolume(SND_MGR_DUCKING_DURATION); g_audio_stream = new AudioStream(); - g_player_thread = new PlayerThread(__play_utterance_cb); + g_player_thread = new PlayerThread(play_utterance_cb); g_is_set_policy = false; g_player_init = true; @@ -418,10 +418,10 @@ int ttsd_player_init() int ttsd_player_release(void) { #ifdef BUF_SAVE_MODE - __close_buffer_dump_file(); + close_buffer_dump_file(); #endif - __set_playing_status(false); + set_playing_status(false); if (false == g_player_init) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized"); return TTSD_ERROR_OPERATION_FAILED; @@ -482,10 +482,10 @@ int ttsd_player_stop(unsigned int uid) } #ifdef BUF_SAVE_MODE - __close_buffer_dump_file(); + close_buffer_dump_file(); #endif - __set_playing_status(false); + set_playing_status(false); ttsd_data_set_last_sound_result_event(uid, TTSE_RESULT_EVENT_FINISH); ttsd_data_set_paused_data(uid, nullptr); @@ -514,15 +514,15 @@ int ttsd_player_pause(unsigned int uid) } #ifdef BUF_SAVE_MODE - __close_buffer_dump_file(); + close_buffer_dump_file(); #endif - __set_playing_status(false); + set_playing_status(false); SLOG(LOG_INFO, tts_tag(), "[Player SUCCESS] Pause player : uid(%u)", uid); return 0; } -bool __stop_all_client_callback(int pid, unsigned int uid, app_tts_state_e state, void* user_data) +static bool stop_all_client_callback(int pid, unsigned int uid, app_tts_state_e state, void* user_data) { if (0 > ttsd_data_is_client(uid)) { SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%u) is not valid", uid); @@ -545,7 +545,7 @@ int ttsd_player_all_stop() } g_player_thread->requestStop(); - ttsd_data_foreach_clients(__stop_all_client_callback, nullptr); + ttsd_data_foreach_clients(stop_all_client_callback, nullptr); SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] player all stop!!"); return TTSD_ERROR_NONE; diff --git a/server/ttsd_state.cpp b/server/ttsd_state.cpp index 14e9f4c6..e83f6215 100644 --- a/server/ttsd_state.cpp +++ b/server/ttsd_state.cpp @@ -24,7 +24,9 @@ using namespace std; static StateManager* g_stateManager = nullptr; StateManager::StateManager(ttsd_state_changed_cb callback) : - __beforeState(TTSD_STATE_READY), __currentState(TTSD_STATE_READY), __callback(callback) + mBeforeState(TTSD_STATE_READY), + mCurrentState(TTSD_STATE_READY), + mCallback(callback) { SLOG(LOG_INFO, tts_tag(), "[StateManager] Constructor"); } @@ -32,28 +34,28 @@ StateManager::StateManager(ttsd_state_changed_cb callback) : StateManager::~StateManager() { SLOG(LOG_INFO, tts_tag(), "[StateManager] Destructor"); - __beforeState = TTSD_STATE_READY; - __currentState = TTSD_STATE_READY; - __callback = nullptr; + mBeforeState = TTSD_STATE_READY; + mCurrentState = TTSD_STATE_READY; + mCallback = nullptr; } ttsd_state_e StateManager::getState() { - lock_guard lock(__stateMutex); - return __currentState; + lock_guard lock(mStateMutex); + return mCurrentState; } void StateManager::setState(ttsd_state_e state) { - unique_lock lock(__stateMutex); - __beforeState = __currentState; - __currentState = state; + unique_lock lock(mStateMutex); + mBeforeState = mCurrentState; + mCurrentState = state; - if (__beforeState == __currentState) { + if (mBeforeState == mCurrentState) { return; } - SLOG(LOG_INFO, tts_tag(), "[StateManager] StateManager is changed. (%d) -> (%d)", __beforeState, __currentState); + SLOG(LOG_INFO, tts_tag(), "[StateManager] StateManager is changed. (%d) -> (%d)", mBeforeState, mCurrentState); lock.unlock(); ecore_main_loop_thread_safe_call_async(notifyStateChangeOnMainThread, static_cast(this)); } @@ -67,13 +69,13 @@ void StateManager::notifyStateChangeOnMainThread(void* data) StateManager* stateManager = static_cast(data); - unique_lock lock(stateManager->__stateMutex); - ttsd_state_e before = stateManager->__beforeState; - ttsd_state_e current = stateManager->__currentState; + unique_lock lock(stateManager->mStateMutex); + ttsd_state_e before = stateManager->mBeforeState; + ttsd_state_e current = stateManager->mCurrentState; lock.unlock(); - if (stateManager->__callback) { - stateManager->__callback(before, current); + if (stateManager->mCallback) { + stateManager->mCallback(before, current); } }