[dasher: 2/61] Removed ugly messages about speed changes.



commit 6259dcbabc1054085d5cc37b38e8684d89941fb1
Author: Ada Majorek <amajorek google com>
Date:   Thu Mar 3 14:49:54 2016 -0800

    Removed ugly messages about speed changes.
    
    fixes https://github.com/ipomoena/dasher/issues/89

 Src/DasherCore/AutoSpeedControl.cpp |   47 ++++++++++++----------------------
 Src/DasherCore/AutoSpeedControl.h   |    9 +-----
 Src/DasherCore/DefaultFilter.cpp    |    2 +-
 3 files changed, 20 insertions(+), 38 deletions(-)
---
diff --git a/Src/DasherCore/AutoSpeedControl.cpp b/Src/DasherCore/AutoSpeedControl.cpp
index a9cb1e4..0a2e038 100644
--- a/Src/DasherCore/AutoSpeedControl.cpp
+++ b/Src/DasherCore/AutoSpeedControl.cpp
@@ -12,8 +12,8 @@
 
 using namespace Dasher;
 
-CAutoSpeedControl::CAutoSpeedControl(CSettingsUser *pCreateFrom, CMessageDisplay *pMsgs)
-  : CSettingsUser(pCreateFrom), m_pMsgs(pMsgs) {
+CAutoSpeedControl::CAutoSpeedControl(CSettingsUser *pCreateFrom)
+  : CSettingsUser(pCreateFrom) {
   //scale #samples by #samples = m_dSamplesScale / (current bitrate) + m_dSampleOffset
   m_dSampleScale = 1.5;
   m_dSampleOffset = 1.3;
@@ -94,11 +94,10 @@ inline double CAutoSpeedControl::Variance()
 {
   double avgcos, avgsin;
   avgsin = avgcos = 0.0;
-  DOUBLE_DEQUE::iterator i;
   // find average of cos(theta) and sin(theta)
-  for(i = m_dequeAngles.begin(); i != m_dequeAngles.end(); i++) {
-    avgcos += cos(*i);
-    avgsin += sin(*i);
+  for(auto theta : m_dequeAngles) {
+    avgcos += cos(theta);
+    avgsin += sin(theta);
   }
   avgcos /= (1.0 * m_dequeAngles.size());
   avgsin /= (1.0 * m_dequeAngles.size());
@@ -167,47 +166,35 @@ inline void CAutoSpeedControl::UpdateSigmas(double r, double dFrameRate)
 
 
 void CAutoSpeedControl::SpeedControl(myint iDasherX, myint iDasherY, CDasherView *pView) {
-  if(GetBoolParameter(BP_AUTO_SPEEDCONTROL)) {
+  if (GetBoolParameter(BP_AUTO_SPEEDCONTROL)) {
 
-//  Coordinate transforms:
-       double r,theta;
-       pView->Dasher2Polar(iDasherX, iDasherY, r, theta);
+    //  Coordinate transforms:
+    double r, theta;
+    pView->Dasher2Polar(iDasherX, iDasherY, r, theta);
 
     m_dBitrate = GetLongParameter(LP_MAX_BITRATE) / 100.0; //  stored as long(round(true bitrate * 100))
     double dFrameRate = GetLongParameter(LP_FRAMERATE) / 100.0;
     UpdateSigmas(r, dFrameRate);
 
-//  Data collection:
+    //  Data collection:
 
-    if(r > m_dMinRadius && fabs(theta) < 1.25) {
+    if (r > m_dMinRadius && fabs(theta) < 1.25) {
       m_nSpeedCounter++;
       m_dequeAngles.push_back(theta);
-      while(m_dequeAngles.size() > m_nSpeedSamples) {
-           m_dequeAngles.pop_front();
+      while (m_dequeAngles.size() > m_nSpeedSamples) {
+        m_dequeAngles.pop_front();
       }
 
     }
     m_dSensitivity = GetLongParameter(LP_AUTOSPEED_SENSITIVITY) / 100.0;
-    if(m_nSpeedCounter > round(m_nSpeedSamples / m_dSensitivity)) {
+    if (m_nSpeedCounter > round(m_nSpeedSamples / m_dSensitivity)) {
       //do speed control every so often!
-
       UpdateSampleSize(dFrameRate);
       UpdateMinRadius();
       UpdateBitrate();
-      long lBitrateTimes100 =  long(round(m_dBitrate * 100)); //Dasher settings want long numerical 
parameters
-      if (lBitrateTimes100 != GetLongParameter(LP_MAX_BITRATE)) {
-        const char *msg((lBitrateTimes100 > GetLongParameter(LP_MAX_BITRATE)) ? 
-                   _("Auto-increasing speed to %0.2f") : _("Auto-decreasing speed to %0.2f"));
-        char *buf(new char[strlen(msg) + 5]);
-        sprintf(buf, msg, (lBitrateTimes100/100.0));
-        m_pMsgs->Message(buf,false);
-        delete[] buf;
-        SetLongParameter(LP_MAX_BITRATE, lBitrateTimes100);
-      }
+      long lBitrateTimes100 = long(round(m_dBitrate * 100)); //Dasher settings want long numerical parameters
+      SetLongParameter(LP_MAX_BITRATE, lBitrateTimes100);
       m_nSpeedCounter = 0;
-
     }
-
   }
-
-}
+}
\ No newline at end of file
diff --git a/Src/DasherCore/AutoSpeedControl.h b/Src/DasherCore/AutoSpeedControl.h
index 4956ad1..27a2101 100644
--- a/Src/DasherCore/AutoSpeedControl.h
+++ b/Src/DasherCore/AutoSpeedControl.h
@@ -3,7 +3,6 @@
 
 #include "DasherTypes.h"
 #include "DasherView.h"
-#include "Messages.h"
 #include "SettingsStore.h"
 
 #include <deque>
@@ -13,7 +12,7 @@
 namespace Dasher {
   class CAutoSpeedControl : private CSettingsUser {
  public:
-  CAutoSpeedControl(CSettingsUser *pCreateFrom, CMessageDisplay *pMsgs);
+  CAutoSpeedControl(CSettingsUser *pCreateFrom);
   
   ///
   /// AUTO-SPEED-CONTROL
@@ -74,14 +73,10 @@ namespace Dasher {
   double m_dChange1, m_dChange2, m_dChange3, m_dChange4; // fractional changes to bit rate
   double m_dMinRRate; // controls rate at which min. r adapts HIGHER===SLOWER!
   double m_dSensitivity; // not used, control sensitivity of auto speed control
-  typedef std::deque<double> DOUBLE_DEQUE;
-  DOUBLE_DEQUE m_dequeAngles; // store angles for statistics
+  std::deque<double> m_dequeAngles; // store angles for statistics
   
   //variables for adaptive radius calculations...
   double m_dSigma1, m_dSigma2, m_dMinRadius;
-  
-  CMessageDisplay *m_pMsgs;
-
 };
 }
 /// @}
diff --git a/Src/DasherCore/DefaultFilter.cpp b/Src/DasherCore/DefaultFilter.cpp
index 6617b3e..227a0de 100644
--- a/Src/DasherCore/DefaultFilter.cpp
+++ b/Src/DasherCore/DefaultFilter.cpp
@@ -30,7 +30,7 @@ bool CDefaultFilter::GetSettings(SModuleSettings **sets, int *iCount) {
 CDefaultFilter::CDefaultFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface, CFrameRate 
*pFramerate, ModuleID_t iID, const char *szName)
   : CDynamicFilter(pCreator, pInterface, pFramerate, iID, szName), CSettingsObserver(pCreator), 
m_bTurbo(false) {
   m_pStartHandler = 0;
-  m_pAutoSpeedControl = new CAutoSpeedControl(this, pInterface);
+  m_pAutoSpeedControl = new CAutoSpeedControl(this);
 
   // Initialize autocalibration (i.e. seen nothing yet)
   m_iSum = 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]