}
long long int diff = backgroundVolume->getDurationAfterDucking();
- if (diff >= backgroundVolume->mDuckingDuration) {
+ if (diff > backgroundVolume->mDuckingDuration) {
double ratio = backgroundVolume->mVolumeRatio.load();
SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Modify volume ratio(%lf) directly", ratio);
SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Remove modification timer. result(%p)", result);
}
- long long int diff = backgroundVolume->getDurationAfterDucking();
- if (diff >= backgroundVolume->mDuckingDuration) {
- SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Direct deactivate ducking");
-
- backgroundVolume->deactivateDuckingAll();
- } else {
+ if (false == backgroundVolume->deactivateDuckingAll()) {
+ SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Direct deactivation is failed. Try again after some moments");
+ long long int diff = backgroundVolume->getDurationAfterDucking();
double delay = static_cast<double>(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);
+ SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delay deactivation (%p), delay(%lf)", backgroundVolume->mPostponedRecoverTimer, delay);
}
}
return diff.count();
}
-void BackgroundVolume::deactivateDuckingAll()
+bool BackgroundVolume::deactivateDuckingAll()
{
if (false == isDuckingHandleValid()) {
SLOG(LOG_WARN, tts_tag(), "[BackgroundVolume] There are some invalid handles. Skip ducking deactivation.");
- return;
+ return false;
}
- deactivateDucking(SOUND_STREAM_TYPE_MEDIA);
- deactivateDucking(SOUND_STREAM_TYPE_NOTIFICATION);
- deactivateDucking(SOUND_STREAM_TYPE_ALARM);
+ bool result = true;
+ result &= deactivateDucking(SOUND_STREAM_TYPE_MEDIA);
+ result &= deactivateDucking(SOUND_STREAM_TYPE_NOTIFICATION);
+ result &= deactivateDucking(SOUND_STREAM_TYPE_ALARM);
+
+ return result;
}
Eina_Bool BackgroundVolume::postponedRecoverTimerCb(void* data)
}
BackgroundVolume* backgroundVolume = static_cast<BackgroundVolume*>(data);
- backgroundVolume->deactivateDuckingAll();
- backgroundVolume->mPostponedRecoverTimer = nullptr;
+ if (false == backgroundVolume->deactivateDuckingAll()) {
+ SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Try again.");
+ return EINA_TRUE;
+ }
SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Delayed unset policy success");
+ backgroundVolume->mPostponedRecoverTimer = nullptr;
return EINA_FALSE;
}
-void BackgroundVolume::deactivateDucking(sound_stream_type_e type)
+bool BackgroundVolume::deactivateDucking(sound_stream_type_e type)
{
- bool isDucked = false;
+ bool is_ducked = false;
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));
- return;
+ sound_manager_is_ducked(handle, &is_ducked);
+ if (!is_ducked) {
+ SLOG(LOG_DEBUG, tts_tag(), "[BackgroundVolume] The %s volume is already recovered", get_ducking_stream(type));
+ return true;
}
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));
- } else {
- SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Deactivate ducking for %s", get_ducking_stream(type));
+ SLOG(LOG_ERROR, tts_tag(), "[BackgroundVolume] Fail to deactivate ducking for %s", get_ducking_stream(type));
+ return false;
}
+
+ SLOG(LOG_INFO, tts_tag(), "[BackgroundVolume] Deactivate ducking for %s", get_ducking_stream(type));
+ return true;
}
int BackgroundVolume::createHandles()