Fixed defect detected by static analysis tool
[platform/core/uifw/inputdelegator.git] / src / MicEffector.cpp
index a8d3c62..9010026 100755 (executable)
@@ -15,7 +15,6 @@
  */
 
 #include <string.h>
-#include <efl_assist.h>
 #include "MicEffector.h"
 
 using namespace is::ui;
@@ -32,7 +31,7 @@ static float timeout_s = 1.0f / 60.0f;
 
 #define MATH_PI (3.141592)
 
-double cubic_easy_in_out (double index, double start, double end, double duration)
+double cubic_easy_in_out(double index, double start, double end, double duration)
 {
        index /= duration/2;
        if (index < 1)
@@ -69,10 +68,10 @@ MicEffector::MicEffector(Evas_Object *canvas, Evas_Object *layout, IMicEffector&
        : drawcount(0)
        , forcestop(false)
        , started(false)
+       , fake(false)
        , timer(NULL)
        , layout(layout)
        , ieffect(effect)
-       , fake(false)
 {
 //     path = ea_vector_path_create();
 //     paint = ea_vector_paint_create();
@@ -135,28 +134,27 @@ void MicEffector::DrawDummyFrame()
  */
 void MicEffector::DrawQue(int idx, bool is_start)
 {
-       float margin = spectrum_posx;
-       float posx = 0.0;
+//     float margin = spectrum_posx;
+//     float posx = 0.0;
 
        double speed = cubic_easy_out(idx + 1.0, 0.0, 23.0, 23);
 
        unsigned int start = start_stop_anim_count - (int) speed;
        unsigned int end = start_stop_anim_count + (int) speed;
 
-       double opacity;
+//     double opacity;
 
-       if(is_start) {
-               opacity = cubic_easy_out(idx, 0.0, 1.0, 26.0);
-       }
-       else {
-               opacity = cubic_easy_out(idx, 0, 1.0, 26.0);
+       if (is_start) {
+//             opacity = cubic_easy_out(idx, 0.0, 1.0, 26.0);
+       } else {
+//             opacity = cubic_easy_out(idx, 0, 1.0, 26.0);
        }
 
 //     ea_vector_path_reset(path);
 
        for(unsigned int i = start; i < end; i++)
        {
-               posx = margin + (i * 5);
+//             posx = margin + (i * 5);
 
 //             ea_vector_path_move_to(path, posx, 37.0f);
 //             ea_vector_path_line_to(path, posx, 38.0f);
@@ -222,29 +220,28 @@ float MicEffector::GetAmplifyValue(unsigned int idx)
  * Center of effect area, it applies amplified value.
  *
  */
-void MicEffector::DrawWave(unsigned int idx, int amount, int prev_amount, double opacity,bool is_lastcmd)
+void MicEffector::DrawWave(unsigned int idx, int amount, int prev_amount, double opacity, bool is_lastcmd)
 {
-       float ratio = GetAmplifyValue(idx);
+//     float ratio = GetAmplifyValue(idx);
 
-       float am = ((float) amount) * ratio;
-       float pam = ((float) prev_amount) * ratio;
-       float cnt = (float) drawcount;
+//     float am = ((float) amount) * ratio;
+//     float pam = ((float) prev_amount) * ratio;
+//     float cnt = (float) drawcount;
 
        float posx = spectrum_posx;
 
-       float height = pam > am?
-               pam - cubic_easy_in_out(cnt + 1.0, am, pam, 7):
-               cubic_easy_in_out(cnt + 1.0, pam, am, 7);
+//     float height = pam > am?
+//             pam - cubic_easy_in_out(cnt + 1.0, am, pam, 7):
+//             cubic_easy_in_out(cnt + 1.0, pam, am, 7);
 
        posx += idx * 5;
 
 //     ea_vector_path_move_to(path, posx, (37.0f - (height / 2.0)));
 //     ea_vector_path_line_to(path, posx, (38.0f + (height / 2.0)));
 
-       if(is_lastcmd) {
+       if (is_lastcmd) {
 //             ea_vector_paint_set_color(paint, 0.1451f, 0.204f, 0.255f, opacity);//RGB = 37:52:65
-       }
-       else {
+       } else {
 //             ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity);//RGB: 255 255 255
        }
 }
@@ -279,20 +276,17 @@ void MicEffector::Start()
         * Que animation
         *
         */
-       timer = ecore_timer_add ( timeout_s,
+       timer = ecore_timer_add(timeout_s,
                                [](void *data)->Eina_Bool
                                {
                                        MicEffector *effector = static_cast<MicEffector*>(data);
 
                                        effector->DrawQue(effector->drawcount);
 
-                                       if(effector->drawcount < (int) start_stop_anim_count)
-                                       {
+                                       if(effector->drawcount < (int) start_stop_anim_count) {
                                                effector->drawcount += 2;
                                                return ECORE_CALLBACK_RENEW;
-                                       }
-                                       else
-                                       {
+                                       } else {
                                                for(unsigned int i = 0; i < spectrum_count; i++)
                                                        effector->DrawWave(i, 0, 0);
 
@@ -308,8 +302,6 @@ void MicEffector::Start()
                                this);
 }
 
-
-
 /**
  * Volume effect
  *
@@ -325,10 +317,9 @@ void MicEffector::Effect(bool fake)
                        timer = NULL;
        }
 
-       timer = ecore_timer_add ( timeout_s,
+       timer = ecore_timer_add(timeout_s,
                                [](void *data)->Eina_Bool
                                {
-
                                        MicEffector *effector = static_cast<MicEffector *>(data);
 
                                        bool is_empty_prev = effector->prev.empty();
@@ -338,17 +329,16 @@ void MicEffector::Effect(bool fake)
 
                                        for(unsigned int i = 0; i < effector->current.size(); i++)
                                        {
-                                               if(is_empty_prev)
+                                               if (is_empty_prev)
                                                        effector->DrawWave(i, effector->current.at(i), 0);
                                                else
                                                        effector->DrawWave(i, effector->current.at(i), effector->prev.at(i));
                                        }
 //                                     ea_vector_canvas_draw(effector->canvas, effector->path, effector->paint);
 
-                                       if(effector->drawcount < 7)     {
+                                       if (effector->drawcount < 7)    {
                                                effector->drawcount++;
-                                       }
-                                       else {
+                                       } else {
                                                effector->drawcount = 0;
                                                effector->VolumeCheck(effector->fake);
                                        }
@@ -386,17 +376,13 @@ void MicEffector::Stop(bool forced)
 
                        effector->DrawQue(start_stop_anim_count - effector->drawcount, false);
 
-                       if(effector->drawcount < (int) start_stop_anim_count)
-                       {
+                       if(effector->drawcount < (int) start_stop_anim_count) {
                                effector->drawcount += 2;
                                return ECORE_CALLBACK_RENEW;
-                       }
-                       else
-                       {
+                       } else {
                                if(!effector->forcestop) {
                                        effector->Processing();
-                               }
-                               else {
+                               } else {
                                        effector->Idle();
                                }
 
@@ -405,12 +391,9 @@ void MicEffector::Stop(bool forced)
                                effector->timer = NULL;
                                return ECORE_CALLBACK_CANCEL;
                        }
-
                }, this);
 }
 
-
-
 /**
  * Signal. Refresh volume effect
  *
@@ -423,10 +406,10 @@ void MicEffector::VolumeCheck(bool fake)
 
        if(!fake) {
                volumes = ieffect.GetVolume();
-       }
-       else {
+       } else {
                for(unsigned int i = 0; i < spectrum_count; i++) {
-                       volumes.push_back(rand() % 2);
+                       unsigned int seed = time(NULL);
+                       volumes.push_back(rand_r(&seed) % 2);
                }
        }