From 4cc398a0baf6150f1c14ac24e06bfe1d5b76deff Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 19 Feb 2020 15:36:57 +0000 Subject: [PATCH] WIP done(ish). Reorganise input system 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 --- bitmap.h | 18 ++++++++---------- command.cc | 20 ++++++++++++++++---- input.cc | 4 ++-- input.h | 2 +- inputman.cc | 2 ++ inputwin.cc | 10 ---------- inputwin.h | 1 - log.cc | 4 ++-- messagequeue.h | 1 + player.cc | 13 +++++++++---- player.h | 2 +- winmain.cc | 3 --- 12 files changed, 42 insertions(+), 38 deletions(-) diff --git a/bitmap.h b/bitmap.h index c15a394..f59b5a5 100644 --- a/bitmap.h +++ b/bitmap.h @@ -17,21 +17,21 @@ 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 -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& getColourVector() const { return colour; } @@ -48,7 +47,7 @@ class Palette const std::vector& getCrVector() const { return Cr; } const std::vector& getCbVector() const { return Cb; } const std::vector& getAVector() const { return A; } - const UINT getNumColours()const{return numColours;}; + UINT getNumColours() const { return numColours; } private: const static UINT MAX_DEPTH = 8; std::vector colour; @@ -80,5 +79,4 @@ class Bitmap void setAllIndices(UCHAR index); }; - #endif diff --git a/command.cc b/command.cc index 191011d..e5c767b 100644 --- a/command.cc +++ b/command.cc @@ -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 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() diff --git a/input.cc b/input.cc index 568fd25..93eaf6e 100644 --- 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 dc8e8de..a88501d 100644 --- a/input.h +++ b/input.h @@ -35,7 +35,7 @@ class VDR; -typedef std::map RemoteTranslationList; +typedef std::map RemoteTranslationList; class Input: public AbstractOption { diff --git a/inputman.cc b/inputman.cc index 6278a60..230df7f 100644 --- a/inputman.cc +++ b/inputman.cc @@ -25,7 +25,9 @@ #include "inputcec.h" #endif #include "inputudp.h" +#ifdef WIN32 #include "inputwin.h" +#endif #include "i18n.h" #include "input.h" diff --git a/inputwin.cc b/inputwin.cc index d40d31c..6a07dfe 100644 --- a/inputwin.cc +++ b/inputwin.cc @@ -513,13 +513,3 @@ void InputWin::Signal() SetEvent(event); } */ - -void InputWin::SendPower() -{ - /* - curevent=POWER; - hascurevent=true; - SetEvent(event); - */ - sendInputKey(POWER); -} diff --git a/inputwin.h b/inputwin.h index 629a90c..f664230 100644 --- a/inputwin.h +++ b/inputwin.h @@ -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 52250bc..eb80502 100644 --- 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; diff --git a/messagequeue.h b/messagequeue.h index 7e897cb..837d2a9 100644 --- a/messagequeue.h +++ b/messagequeue.h @@ -27,6 +27,7 @@ class Message; typedef std::deque MQueue; +typedef std::deque::iterator MQueueI; class MessageQueue { diff --git a/player.cc b/player.cc index a65f3df..6dba51f 100644 --- 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(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(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(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(lengthBytes - feedPosition); else // normal askFor = blockSize; } diff --git a/player.h b/player.h index 3ac56cc..45d221c 100644 --- 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 diff --git a/winmain.cc b/winmain.cc index cb13e36..9d2fcba 100644 --- a/winmain.cc +++ b/winmain.cc @@ -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: { -- 2.39.5