]> git.vomp.tv Git - vompclient.git/commitdiff
WIP done(ish). Reorganise input system
authorChris Tallon <chris@vomp.tv>
Wed, 19 Feb 2020 15:36:57 +0000 (15:36 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 19 Feb 2020 15:36:57 +0000 (15:36 +0000)
Split Remote (base class) / RemoteWin / RemoteLinux(inc CEC) /
 (defunct) RemoteLirc into separate classes
Replace with: InputLinux, InputCEC, InputUDP, InputWin, (InputLirc)
And InputMan to manage them all.
Move UDP class into Input system
Now any combination of input modules can be active.
Added pipe-quit wait style to DSock
Switch InputUDP to std::thread
Move static strings functions to InputMan.
Split translist into individual Input classes.
Remove all old/new remote stuff - has never been active on RPi.
Drop libcec3 support

12 files changed:
bitmap.h
command.cc
input.cc
input.h
inputman.cc
inputwin.cc
inputwin.h
log.cc
messagequeue.h
player.cc
player.h
winmain.cc

index c15a3941b2a948647e2ff91db88234f57ed361ee..f59b5a5323565974d853b6a5f0137ccd9ae51971 100644 (file)
--- a/bitmap.h
+++ b/bitmap.h
     along with VOMP; if not, write to the Free Software Foundation, Inc.,
     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
+
 #ifndef BITMAP_H
 #define BITMAP_H
 
 #include "defines.h"
 #include <vector>
 
-class DisplayRegion {
-public:
-       DisplayRegion();
-    UINT windowx, windowy,windoww,windowh;
+class DisplayRegion
+{
+  public:
+    DisplayRegion();
+    UINT windowx, windowy, windoww, windowh;
     UINT framewidth,frameheight;
 };
 
-
-
 class Palette
 {
   public:
@@ -39,8 +39,7 @@ class Palette
     UCHAR getBpp() const { return bpp; }
     void reset() { numColours = 0; }
     void setBpp(UCHAR tBpp);
-    ULONG getColour(UCHAR index) const {
-      return index < maxColours ? colour[index] : 0; }
+    ULONG getColour(UCHAR index) const { return index < maxColours ? colour[index] : 0; }
     void setColour(UCHAR index, ULONG tColour);
     void setYCrCbA(UCHAR index, UCHAR tY, UCHAR tCr, UCHAR tCb, UCHAR tA);
     const std::vector<ULONG>& getColourVector() const { return colour; }
@@ -48,7 +47,7 @@ class Palette
     const std::vector<UCHAR>& getCrVector() const { return Cr; }
     const std::vector<UCHAR>& getCbVector() const { return Cb; }
     const std::vector<UCHAR>& getAVector() const { return A; }
-    const UINT getNumColours()const{return numColours;};
+    UINT getNumColours() const { return numColours; }
   private:
     const static UINT MAX_DEPTH = 8;
     std::vector<ULONG> colour;
@@ -80,5 +79,4 @@ class Bitmap
     void setAllIndices(UCHAR index);
 }; 
 
-
 #endif
index 191011d5cdbbb9342fb676ba547c54fc448227e5..e5c767be62cc7399d8ecd386c93135b3a11dabf6 100644 (file)
@@ -465,9 +465,6 @@ void Command::doPowerOff()
     InputMan::getInstance()->changePowerState(false);
     isStandby = true;
     Sleeptimer::getInstance()->shutdown();
-#ifdef WIN32
-    stop(); //different behavoiur on windows, we exit // FIXME - stop() now called directly from winmain
-#endif
   }
 }
 
@@ -521,7 +518,22 @@ void Command::doFromTheTop(bool which)
 
 void Command::clearMQInputEvents()
 {
-  // FIXME implement this
+  std::lock_guard<std::mutex> lg(messageQueueMutex); // Get the lock
+
+  MQueueI i = messages.begin();
+  while(i != messages.end())
+  {
+    Message* m = *i;
+    if (m->message == Message::INPUT_EVENT)
+    {
+      delete m;
+      i = messages.erase(i);
+    }
+    else
+    {
+      ++i;
+    }
+  }
 }
 
 void Command::doReboot()
index 568fd25824b004b65b7ad75c958d5d8ec2921457..93eaf6e696987f961c227aeea7911dbd45905615 100644 (file)
--- a/input.cc
+++ b/input.cc
@@ -66,12 +66,12 @@ UCHAR Input::TranslateHWCList(HWC_TYPE code)
   }
 }
 
-void Input::setHWCtoCommand(ULLONG hcw, UCHAR command)
+void Input::setHWCtoCommand(HWC_TYPE hcw, UCHAR command)
 {
   translist[hcw] = command;
 }
 
-void Input::unsetHWC(ULLONG hcw) // FIXME never used
+void Input::unsetHWC(HWC_TYPE hcw) // FIXME never used
 {
   translist.erase(hcw);
 }
diff --git a/input.h b/input.h
index dc8e8de1b86e11bce03c331d4263e55f740d5ebf..a88501d5a0f246a5e9f73cc8bbd5ade38863ed23 100644 (file)
--- a/input.h
+++ b/input.h
@@ -35,7 +35,7 @@
 
 class VDR;
 
-typedef std::map<ULLONG, UCHAR> RemoteTranslationList;
+typedef std::map<HWC_TYPE, UCHAR> RemoteTranslationList;
 
 class Input: public AbstractOption
 {
index 6278a609d60a50d00193b902eff11039f1881a46..230df7f6b0969e7a173c7abfc257c065713498e0 100644 (file)
@@ -25,7 +25,9 @@
 #include "inputcec.h"
 #endif
 #include "inputudp.h"
+#ifdef WIN32
 #include "inputwin.h"
+#endif
 #include "i18n.h"
 #include "input.h"
 
index d40d31ca92aea32bf78b590697607f693e981d1b..6a07dfebfad0c46ae1e69e482d7cde9111b2ea4c 100644 (file)
@@ -513,13 +513,3 @@ void InputWin::Signal()
        SetEvent(event);
 }
 */
-
-void InputWin::SendPower()
-{
-  /*
-       curevent=POWER;
-  hascurevent=true;
-       SetEvent(event);
-  */
-  sendInputKey(POWER);
-}
index 629a90c540bb6b5a14bb8310dc6680b0d3f64078..f664230e08419e64c95e39d0bc3385a178c6d8fb 100644 (file)
@@ -42,7 +42,6 @@ class InputWin : public Input
     int ReceiveButtonCH(UINT button); //Windows Message from WND_PROC (char)
          int ReceiveButtonAP(UINT button); // (App command)
          int ReceiveButtonRI(UINT button); // (Remote control)
-         void SendPower();
     void InitHWCListwithDefaults();
     const char* getHardCodedHardwareKeyNameForVompKey(UCHAR vompKey);
     std::string getHardwareKeyName(HWC_TYPE hardwareKey);
diff --git a/log.cc b/log.cc
index 52250bc62ca45defc9dca9b99d3ec4a1cced6c7c..eb805027e000fdbde50cf367e054199c6cbba040 100644 (file)
--- a/log.cc
+++ b/log.cc
@@ -80,9 +80,9 @@ int Log::init(int startLogLevel, const char* fileName, int tenabled)
   initted = 1;
   logLevel = startLogLevel;
   enabled = tenabled;
-  logfile = fopen(fileName, "a");
+  //logfile = fopen(fileName, "a");
 //  logfile = fopen(stdout, "a");
-  //logfile = stdout;
+  logfile = stdout;
 //  logfile = fopen("/log", "a");
 
   if (logfile) return 1;
index 7e897cbf8e07161951ed165abb5b342d88db3eac..837d2a97864c3b4490b512ed8fadfe6573b82597 100644 (file)
@@ -27,6 +27,7 @@
 class Message;
 
 typedef std::deque<Message*> MQueue;
+typedef std::deque<Message*>::iterator MQueueI;
 
 class MessageQueue
 {
index a65f3dfb81efb5d27ec2a40df952a4eee296798c..6dba51fa84d6c8c9b2e499820c192934ae5503d0 100644 (file)
--- a/player.cc
+++ b/player.cc
@@ -544,6 +544,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame)
         }
       }
     }
+    FALLTHROUGH // keep compiler happy (all posibilities return)
     case S_PAUSE_P: // from S_PAUSE_P -----------------------------------
     {
       switch(toState)
@@ -641,6 +642,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame)
         }
       }
     }
+    FALLTHROUGH // keep compiler happy (all posibilities return)
     case S_PAUSE_I: // from S_PAUSE_I -----------------------------------
     {
       switch(toState)
@@ -695,6 +697,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame)
         }
       }
     }
+    FALLTHROUGH // keep compiler happy (all posibilities return)
     case S_FFWD: // from S_FFWD -----------------------------------
     {
       switch(toState)
@@ -702,7 +705,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame)
         case S_PLAY: // to S_PLAY
         {
           state = S_PLAY;
-          ULONG stepback = (ULONG)(((double)USER_RESPONSE_TIME * ifactor) * fps / 1000.);
+          ULONG stepback = static_cast<ULONG>(USER_RESPONSE_TIME * ifactor * fps / 1000);
           if (stepback < currentFrameNumber)
             currentFrameNumber -= stepback;
           else
@@ -758,6 +761,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame)
         }
       }
     }
+    FALLTHROUGH // keep compiler happy (all posibilities return)
     case S_FBWD: // from S_FBWD -----------------------------------
     {
       switch(toState)
@@ -816,6 +820,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame)
         }
       }
     }
+    FALLTHROUGH // keep compiler happy (all posibilities return)
     case S_STOP: // from S_STOP -----------------------------------
     {
       switch(toState)
@@ -1021,7 +1026,7 @@ void Player::call(void* caller)
     else
     {
       logger->log("Player", Log::DEBUG, "Demuxer said video is something else... setting it anyway");
-         video->setAspectRatio(dxCurrentAspect,parx,pary);
+         video->setAspectRatio(static_cast<UCHAR>(dxCurrentAspect), parx, pary);
     }
 
   }
@@ -1121,14 +1126,14 @@ void Player::threadFeedPlay()
     if (startup)
     {
       if (startupBlockSize > lengthBytes)
-        askFor = lengthBytes; // is a very small recording!
+        askFor = static_cast<UINT>(lengthBytes); // is a very small recording!
       else
         askFor = startupBlockSize; // normal, but a startup sized block to detect all the audio streams
     }
     else
     {
       if ((feedPosition + blockSize) > lengthBytes) // last block of recording
-        askFor = lengthBytes - feedPosition;
+        askFor = static_cast<UINT>(lengthBytes - feedPosition);
       else // normal
         askFor = blockSize;
     }
index 3ac56ccc9b09057e656dfad4ea8deee99bc1bfc4..45d221c75c235349d3cfaa4ef38599ec39e7ece3 100644 (file)
--- a/player.h
+++ b/player.h
@@ -173,7 +173,7 @@ class Player : public Thread_TYPE, public Callback
     UINT startupBlockSize{250000};
     UCHAR* threadBuffer{};
     UCHAR state{S_STOP};
-    UCHAR ifactor{4};
+    UCHAR ifactor{4}; // 4, 8, 16, 32
 };
 
 #endif
index cb13e36ef891736fb5d900559ce4d3cf10c700b7..9d2fcba41860f743d9953e921f6c334c017a1901 100644 (file)
@@ -568,10 +568,7 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam)
    case WM_DESTROY: {
      //TODO: call command
      logger->log("Core", Log::NOTICE, "Window closed, shutting down...");
-
-     //inputWin->SendPower(); // FIXME this could be the only call
      command->stop();
-
      PostQuitMessage(0);
   }break;
    case WM_SIZING: {