[Ring] Repeat vibration on ringing. 79/126679/3
authorKamil Lipiszko <k.lipiszko@samsung.com>
Mon, 24 Apr 2017 14:39:11 +0000 (16:39 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 25 Apr 2017 10:17:08 +0000 (10:17 +0000)
Make loop that repeats vibration during alarm ring, however in
my opinion this should be supported by feedback library as it is
in player where the loop is set with player_set_loop and the
external app solves the sound length and its repeating period.
Right now the loop repeats every 2.5 sec.

Change-Id: I45c3feb004721e17df9d44afeaf98d9e111f4bd9

clock/inc/Utils/FeedbackManager.h
clock/src/Utils/FeedbackManager.cpp

index 36c06b3c511f2cff887951123534af99cca7728f..cdd92bf2e49c9ed860e200f9e2eaf996f5edd351 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef _CLOCK_UTILS_FEEDBACK_MANAGER_H_
 #define _CLOCK_UTILS_FEEDBACK_MANAGER_H_
 
+#include <Elementary.h>
+
 namespace utils {
 
        /**
@@ -49,6 +51,7 @@ namespace utils {
                FeedbackManager &operator = (const FeedbackManager &) = delete;
                FeedbackManager(FeedbackManager const &) = delete;
 
+               Ecore_Timer *timer = NULL;
        };
 
 } //namespace utils
index 0e22090726dec5ca6ff7fc53ffa7a8d9fdce1e19..26aa37396cfe0753a9faf62b585de8ed8b43422e 100644 (file)
@@ -19,6 +19,8 @@
 #include "Utils/FeedbackManager.h"
 #include "Utils/Log.h"
 
+#define FEEDBACK_VIBRATION_PERIOD 2.5
+
 namespace utils {
 
 FeedbackManager &FeedbackManager::GetInstance()
@@ -41,22 +43,35 @@ FeedbackManager::~FeedbackManager()
                ERR("feedback_deinitialize failed[%d]: %s", ret, get_error_message(ret));
 }
 
+static Eina_Bool Vibrate(void *data)
+{
+       int ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_TIMER);
+       if (ret != FEEDBACK_ERROR_NONE)
+               ERR("feedback_play_type failed[%d]: %s", ret, get_error_message(ret));
+
+       return ECORE_CALLBACK_RENEW;
+}
+
 void FeedbackManager::VibrationStart()
 {
+       timer = ecore_timer_add(FEEDBACK_VIBRATION_PERIOD, Vibrate, this);
+       Vibrate(this);
+
        bool status;
        int ret = feedback_is_supported_pattern(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_TIMER, &status);
        if (ret != FEEDBACK_ERROR_NONE || !status) {
                ERR("feedback_is_supported_pattern failed[%d]: %s", ret, get_error_message(ret));
                return;
        }
-
-       ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_TIMER);
-       if (ret != FEEDBACK_ERROR_NONE)
-               ERR("feedback_play_type failed[%d]: %s", ret, get_error_message(ret));
 }
 
 void FeedbackManager::VibrationStop()
 {
+       if (timer) {
+               ecore_timer_del(timer);
+               timer = NULL;
+       }
+
        int ret = feedback_stop();
        if (ret != FEEDBACK_ERROR_NONE)
                ERR("feedback_stop failed[%d]: %s", ret, get_error_message(ret));