From 97db908c6fb6d506b51b643bb9316099e93ced80 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 5 Feb 2020 18:01:21 +0000 Subject: [PATCH] Rework master loop Implement thread safe MessageQueue All postMessage* calls replaced with a single safe-to-call anywhere postMessage() Rewrite main command loop to use new locking around MessageQueue Deleted Command::masterMutex Use condition variable in MessageQueue/Command to wait on rather than going into Remote Implemented new thread loop in Remote. Reports input events by Message Completely replaced signal handling system Revert Linux compiler to GCC Revert Linux linker to GCC LD This will be broken for Windows - remote class needs updating --- GNUmakefile | 12 +- audioplayer.cc | 2 +- boxstack.cc | 2 +- command.cc | 271 ++------ command.h | 26 +- main.cc | 38 +- message.h | 2 + messagequeue.cc | 31 +- messagequeue.h | 17 +- osdopenvg.cc | 4 +- osdwinvector.cc | 2 +- player.cc | 4 +- playerliveradio.cc | 8 +- playerlivetv.cc | 12 +- playermedia.cc | 6 +- remote.cc | 27 + remote.h | 23 +- remotelinux.cc | 1362 ++++++++++++++++++++------------------ remotelinux.h | 58 +- remotewin.cc | 4 - remotewin.h | 1 - teletextdecodervbiebu.cc | 4 +- timers.h | 1 - vaudioselector.cc | 14 +- vchannelselect.cc | 18 +- vchannelselect.h | 2 +- vepg.cc | 6 +- vepglistadvanced.cc | 2 +- vepgsettimer.cc | 2 +- vmedialist.cc | 4 +- vmediaview.cc | 6 +- vmute.cc | 2 +- vopts.cc | 2 +- vquestion.cc | 2 +- vradiorec.cc | 8 +- vrecmove.cc | 2 +- vrecording.cc | 16 +- vrecordingmenu.cc | 12 +- vserverselect.cc | 2 +- vsleeptimer.cc | 8 +- vtimeredit.cc | 4 +- vvideolivetv.cc | 2 +- vvideomedia.cc | 10 +- vvideorec.cc | 8 +- vvolume.cc | 2 +- winmain.cc | 7 +- wremoteconfig.cc | 4 +- wwinaudiofilter.cc | 2 +- wwinmp3audiofilter.cc | 2 +- wwinvideofilter.cc | 2 +- wwinvideoh264filter.cc | 2 +- 51 files changed, 1008 insertions(+), 1062 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index ac92b67..81267bf 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -42,10 +42,16 @@ PICTURES += -Wl,--format=default ifeq ($(vomp_platform),raspberry) $(info Raspberry Pi native compiler) -CC=clang-9 +CC=gcc STRIP=strip -CXX=clang++-9 -LD=clang++-9 +CXX=g++ +LD=g++ + +#CC=clang-9 +#STRIP=strip +#CXX=clang++-9 +#LD=clang++-9 + vomp_options += -DIPV6 LDFLAGS = -fuse-ld=gold $(PICTURES) LIBPATHS = -L/opt/vc/lib -L/usr/lib/arm-linux-gnueabihf diff --git a/audioplayer.cc b/audioplayer.cc index eb48c2c..e6001e7 100644 --- a/audioplayer.cc +++ b/audioplayer.cc @@ -296,7 +296,7 @@ void AudioPlayer::sendFrontendMessage(ULONG para) m->from = this; m->message = Message::PLAYER_EVENT; m->parameter = para; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } //open a new file diff --git a/boxstack.cc b/boxstack.cc index 1107f3d..0c477d4 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -169,7 +169,7 @@ int BoxStack::remove(Boxx* toDelete) Message* m = new Message(); m->to = Command::getInstance(); m->message = Message::LAST_VIEW_CLOSE; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } if (!videoStack.empty() && videoStack.top().first==toDelete) { diff --git a/command.cc b/command.cc index 7252599..ac05cc8 100644 --- a/command.cc +++ b/command.cc @@ -17,10 +17,6 @@ along with VOMP. If not, see . */ -#ifndef WIN32 -#include -#endif - #include "command.h" #ifdef WIN32 @@ -96,12 +92,6 @@ int Command::init(bool tcrashed, char* tServer) SkinFactory::InitSkin(0); -#ifndef WIN32 - pthread_mutex_init(&masterLock, NULL); -#else - masterLock = CreateMutex(NULL, FALSE, NULL); -#endif - return 1; } @@ -114,9 +104,12 @@ int Command::shutdown() void Command::stop() { - logger->log("Command", Log::NOTICE, "stop"); - udp.shutdown(); - irun = false; + logger->log("Command", Log::NOTICE, "Request stop"); + + Message* m = new Message(); // break master loop + m->message = Message::SHUTDOWN; + m->to = this; + postMessage(m); } void Command::doWallpaper() @@ -175,9 +168,6 @@ void Command::run() { if (!initted) return; irun = true; -#ifndef WIN32 - mainPid = getpid(); -#endif // just in case Video::getInstance()->signalOn(); @@ -185,13 +175,6 @@ void Command::run() doWallpaper(); - // End of startup. Lock the mutex and put the first view up -#ifndef WIN32 - pthread_mutex_lock(&masterLock); -#else - WaitForSingleObject(masterLock, INFINITE ); -#endif - if (crashed) { buildCrashedBox(); @@ -203,216 +186,42 @@ void Command::run() vconnect->run(); } + // Start remote thread loop + remote->start(); + // Start method 2 of getting commands in... udp.run(this); - UCHAR button = 0; - while(irun) - { - // unlock and wait -#ifndef WIN32 - pthread_mutex_unlock(&masterLock); -#else - ReleaseMutex(masterLock); -#endif - button = remote->getButtonPress(2); // Don't block (0) in case a signal arrives after checking signals but before this line - // something happened, lock and process - if (signals) processSignals(); // If a signal arrived process now. - -#ifndef WIN32 - pthread_mutex_lock(&masterLock); -#else - WaitForSingleObject(masterLock, INFINITE ); -#endif - - if (button == Remote::NA_NONE) continue; - - if (button != Remote::NA_SIGNAL) handleCommand(button); - processMessageQueue(); - } - -#ifndef WIN32 - pthread_mutex_unlock(&masterLock); -#else - ReleaseMutex(masterLock); -#endif - - boxstack->removeAllExceptWallpaper(); - boxstack->remove(wallpaper); - delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL; -} - -void Command::setSignal(int signalReceived) -{ -#ifndef WIN32 - if (signalReceived == SIGINT) - signals |= SIG_INT; - else if (signalReceived == SIGTERM) - signals |= SIG_TERM; - else if (signalReceived == SIGUSR1) - signals |= SIG_USR1; - else if (signalReceived == SIGUSR2) - signals |= SIG_USR2; - else if (signalReceived == SIGURG) - signals |= SIG_URG; -#endif -} - -void Command::processSignals() -{ -#ifndef WIN32 - if (signals & SIG_INT) - { - signals = signals & ~SIG_INT; - logger->log("Command", Log::NOTICE, "INT signal, shutting down..."); - stop(); - } - - if (signals & SIG_TERM) - { - signals = signals & ~SIG_TERM; - logger->log("Command", Log::NOTICE, "TERM signal, shutting down..."); - stop(); - } + // FIXME Remote::NA_SIGNAL is possibly obsolete now - if (signals & SIG_USR1) - { - logger->log("Command", Log::NOTICE, "USR1 signal"); - signals = signals & ~SIG_USR1; - } - - if (signals & SIG_USR2) - { - logger->log("Command", Log::NOTICE, "USR2 signal"); - signals = signals & ~SIG_USR2; - } + std::unique_lock lockWrapper(messageQueueMutex); // locks. unlocks on out-of-scope - if (signals & SIG_URG) + while(irun) { - logger->log("Command", Log::NOTICE, "URG signal"); // This is used to break from getButtonPress to process the message queue - signals = signals & ~SIG_URG; - } -#endif -} + messageQueueCond.wait(lockWrapper, [&] { return !irun || !messages.empty(); }); + logger->log("Command", Log::DEBUG, "woke"); -void Command::postMessage(Message* m) -{ - // This is locked here in case the main loop is not waiting for an event, but is processing one - // it could be killed but then not react to it because the signal wouldn't cause - // remote->getButtonPress to break - // locking the mutex ensures that the master thread is waiting on getButtonPress - -#ifndef WIN32 - pthread_mutex_lock(&masterLock); -#else - WaitForSingleObject(masterLock, INFINITE ); -#endif - MessageQueue::postMessage(m); + if (!irun) break; -#ifndef WIN32 -#ifndef __ANDROID__ - kill(mainPid, SIGURG); -#else - ((RemoteAndroid*)Remote::getInstance())->Signal(); -#endif - pthread_mutex_unlock(&masterLock); -#else - ((RemoteWin*)Remote::getInstance())->Signal(); - ReleaseMutex(masterLock); -#endif -} + while(!messages.empty()) + { + Message* m = messages.front(); + messages.pop_front(); -void Command::postMessageNoLock(Message* m) // FIXME - get rid of this if the sending-to-MessageQueue idea pans out -{ - // As above but use this one if this message is being posted because of a button press - // the mutex is already locked, locking around postMessage is not needed as the - // queue is guaranteed to be run when the button has been processed - MessageQueue::postMessage(m); -} + lockWrapper.unlock(); -bool Command::postMessageIfNotBusy(Message* m) -{ - // Used for Windows mouse events + processMessage(m); + delete m; -#ifndef WIN32 - if (pthread_mutex_trylock(&masterLock) != EBUSY) - { - MessageQueue::postMessage(m); -#ifndef __ANDROID__ - kill(mainPid, SIGURG); -#else - ((RemoteAndroid*)Remote::getInstance())->Signal(); -#endif - pthread_mutex_unlock(&masterLock); - return true; - } - else - { - return false; - } -#else - switch (WaitForSingleObject(masterLock, 0 )) - { //FIXME this is not "if not busy" check - case WAIT_OBJECT_0: //but with proper argument 0 this did not work - // case WAIT_ABANDONED: - MessageQueue::postMessage(m); - ((RemoteWin*)Remote::getInstance())->Signal(); - ReleaseMutex(masterLock); - return true; - - case WAIT_ABANDONED: return false; - case WAIT_TIMEOUT: return false; + lockWrapper.lock(); + } } - return false; -#endif -} -void Command::postMessageFromOuterSpace(Message* m) -{ - /* - Yet another way of getting messages into Command. This one is for events that - are not standard button presses (or UDP generated buttons). It is also not for - events that are generated as a result of other events (events that can safely - call postMessageNoLock and be guaranteed that the message will be processed - because it is known that the queue is currently being processed). - This is for events that come from outer space and can occur when the master - mutex is locked or not, they need to be queued and executed but it doesn't - matter when. - Actually so far it is for events caused by the video stream - aspect ratio - changes. These can occur when the master mutex is locked and so postMessage - doesn't work. postMessageNoLock doesn't work because if the mutex *isn't* - locked at the time then the message could be sat around a while before - being noticed. - The whole message system was at first supposed to prevent the problem of - calling a function on an object that had just been deleted, by ordering - messages such that all calls are done before object deletion. However, - because of the new centralised messaging system and the fact that BoxStack - locates the destination object before calling it, the messaging system now - allows the kind of sloppy calls it was supposed to stop. Weird huh. This - is mentioned here because the video stream might generate an event just as - the user hits stop. The mutex is locked, and by the time the message - is examined the vvideorec/live has been deleted. This doesn't matter because - boxstack will drop the message if it can't find the matching object to - deliver it to. - Finally, all this is fine and dandy, except that I'm not 100% sure that - this sloppy postMessage and hope a queued signal will force it to be processed - thingy will actually work. Hmmm. - Lastly , I will consider making the naming system a little more sane - if this works. - */ - - logger->log("Command", Log::DEBUG, "PMFOS called"); - MessageQueue::postMessage(m); + remote->stop(); -#ifndef WIN32 -#ifndef __ANDROID__ - kill(mainPid, SIGURG); -#else - ((RemoteAndroid*)Remote::getInstance())->Signal(); -#endif -#else - ((RemoteWin*)Remote::getInstance())->Signal(); -#endif + boxstack->removeAllExceptWallpaper(); + boxstack->remove(wallpaper); + delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL; } void Command::processMessage(Message* m) @@ -428,6 +237,12 @@ void Command::processMessage(Message* m) { switch(m->message) { + case Message::SHUTDOWN: + { + udp.shutdown(); + irun = false; + break; + } // << FIXME OBSELETE case Message::STOP_PLAYBACK: { @@ -454,6 +269,13 @@ void Command::processMessage(Message* m) doFromTheTop(true); break; } + case Message::INPUT_EVENT: + { + logger->log("Command", Log::NOTICE, "INPUT_EVENT %i", m->parameter); + + handleCommand(m->parameter); + break; + } case Message::UDP_BUTTON: { handleCommand(m->parameter); @@ -684,7 +506,8 @@ void Command::doFromTheTop(bool which) connLost->draw(); boxstack->add(connLost); boxstack->update(connLost); - remote->clearBuffer(); + + clearMQInputEvents(); } else { @@ -695,7 +518,6 @@ void Command::doFromTheTop(bool which) connLost = NULL; flushMessageQueue(); - remote->clearBuffer(); // at this point, everything should be reset to first-go @@ -705,6 +527,11 @@ void Command::doFromTheTop(bool which) } } +void Command::clearMQInputEvents() +{ + // FIXME implement this +} + void Command::doReboot() { @@ -742,7 +569,7 @@ void Command::connectionLost() Message* m = new Message(); // break into master mutex m->message = Message::CONNECTION_LOST; m->to = this; - postMessageFromOuterSpace(m); + postMessage(m); } void Command::buildCrashedBox() diff --git a/command.h b/command.h index 0d5dafb..bc42923 100644 --- a/command.h +++ b/command.h @@ -31,8 +31,6 @@ #include #endif -#include - #include #include @@ -68,12 +66,8 @@ class Command : public MessageQueue int init(bool crashed = false, char* server = NULL); int shutdown(); void run(); + void stop(); void doReboot(); - void postMessage(Message* m); // override of MessageQueue::postMessage - void postMessageNoLock(Message* m); // override of MessageQueue::postMessage - bool postMessageIfNotBusy(Message* m); // for timers, when masterMutex might be locked - void postMessageFromOuterSpace(Message* m); // err, read the cc comments. - void setSignal(int signalReceived); void connectionLost(); void setAdvMenus(bool adv) { advMenus = adv; }; @@ -84,9 +78,7 @@ class Command : public MessageQueue ASLPrefList &getASLList() { return langcodes; }; private: - void stop(); void handleCommand(int); - void processSignals(); void doStandby(); void doPowerOn(); void doPowerOff(); @@ -95,15 +87,9 @@ class Command : public MessageQueue void doFromTheTop(bool which); // true - show vinfo,wait. false - del vinfo,restart void buildCrashedBox(); void sig1(); + void clearMQInputEvents(); static Command* instance; -#ifndef WIN32 - pid_t mainPid; - pthread_mutex_t masterLock; -#else - HANDLE masterLock; - HANDLE mainPid; //Window -#endif Log* logger; BoxStack* boxstack; @@ -113,7 +99,6 @@ class Command : public MessageQueue bool irun{}; bool isStandby{}; bool firstBoot{true}; - int signals{}; Boxx* wallpaper{}; WJpeg* wallpaper_pict{}; VInfo* connLost{}; @@ -127,13 +112,6 @@ class Command : public MessageQueue UDP udp; void processMessage(Message* m); - - const static int SIG_INT{1}; - const static int SIG_TERM{2}; - const static int SIG_USR1{4}; - const static int SIG_USR2{8}; - const static int SIG_URG{16}; - }; #endif diff --git a/main.cc b/main.cc index 1c1a7ab..f005054 100644 --- a/main.cc +++ b/main.cc @@ -64,8 +64,8 @@ #include "vsleeptimer.h" -#ifndef WIN32 -void sighandler(int signalReceived); +#ifndef WIN32 // FIXME do we need any if WIN32 stuff in here? windows has own winmain file +void threadSignalReceiverFunction(); #endif void shutdown(int code); @@ -180,6 +180,21 @@ int main(int argc, char** argv) // Set up signal handling ------------------------------------------------------------------------------------------ + // Block all signals + sigset_t set; + sigfillset(&set); + int sigBlockResult = pthread_sigmask(SIG_SETMASK, &set, NULL); + if (sigBlockResult) + { + logger->log("Core", Log::EMERG, "Could not block signals: %i", sigBlockResult); + shutdown(1); + } + + // Start signal receiver thread + std::thread threadSignalReceiver(threadSignalReceiverFunction); + threadSignalReceiver.detach(); + + /* sighandler_t sigtest; sigtest = signal(SIGPIPE, SIG_IGN); @@ -218,6 +233,7 @@ int main(int argc, char** argv) logger->log("Core", Log::EMERG, "Could not set up signal handler for SIGURG. Aborting."); shutdown(1); } + */ logger->log("Core", Log::INFO, "Signal handlers set up successfully"); @@ -358,9 +374,23 @@ int main(int argc, char** argv) // ------------------------------------------------------------------------------------------------------------------- -void sighandler(int signalReceived) +void threadSignalReceiverFunction() { - if (command) command->setSignal(signalReceived); + int sig; + sigset_t set; + sigfillset(&set); + while(1) + { + if(sigwait(&set, &sig)) + { + logger->log("Core", Log::CRIT, "Sigwait returned fail - signal handler exiting"); + return; + } + + logger->log("Core", Log::NOTICE, "Signal received: %i", sig); + + if ((sig == SIGINT) || (sig == SIGTERM)) command->stop(); + } } #endif diff --git a/message.h b/message.h index d3d3b17..052c515 100644 --- a/message.h +++ b/message.h @@ -52,6 +52,7 @@ class Message const static ULONG SCREENSHOT = 5; const static ULONG CHANNEL_CHANGE = 6; const static ULONG RESUME_SELECTED_RECORDING = 7; + const static ULONG INPUT_EVENT = 8; const static ULONG STOP_PLAYBACK = 9; const static ULONG SERVER_SELECTED = 10; const static ULONG VDR_CONNECTED = 11; @@ -79,6 +80,7 @@ class Message const static ULONG NEW_PICTURE = 36; const static ULONG NEW_PICTURE_STATIC = 37; const static ULONG REDRAW = 38; + const static ULONG SHUTDOWN = 39; }; #endif diff --git a/messagequeue.cc b/messagequeue.cc index 6f7a44b..e79bccb 100644 --- a/messagequeue.cc +++ b/messagequeue.cc @@ -32,29 +32,18 @@ MessageQueue* MessageQueue::getInstance() { return instance; } void MessageQueue::postMessage(Message* m) { - messages.push(m); -} + Log::getInstance()->log("MessageQueue", Log::DEBUG, "PostMessage"); + std::lock_guard lg(messageQueueMutex); // Get the lock + messages.push_back(m); + Log::getInstance()->log("MessageQueue", Log::DEBUG, "Pushed message. Notify..."); + messageQueueCond.notify_one(); +} // mutex unlocks -void MessageQueue::processMessageQueue() -{ - Message *m; - while(messages.size()) - { - m = messages.front(); - messages.pop(); - processMessage(m); - delete m; - } -} void MessageQueue::flushMessageQueue() { - Message *m; - while(messages.size()) - { - m = messages.front(); - messages.pop(); - delete m; - } -} + std::lock_guard lg(messageQueueMutex); // Get the lock + for (auto m : messages) delete m; + messages.clear(); +} diff --git a/messagequeue.h b/messagequeue.h index 5fa5aa9..7e897cb 100644 --- a/messagequeue.h +++ b/messagequeue.h @@ -20,11 +20,13 @@ #ifndef MESSAGEQUEUE_H #define MESSAGEQUEUE_H -#include +#include +#include +#include class Message; -typedef std::queue MQueue; +typedef std::deque MQueue; class MessageQueue { @@ -35,20 +37,17 @@ class MessageQueue static MessageQueue* getInstance(); virtual void postMessage(Message* m); - virtual void postMessageNoLock(Message* m)=0; - virtual void postMessageFromOuterSpace(Message* m)=0; - virtual bool postMessageIfNotBusy(Message* m)=0; protected: virtual void flushMessageQueue(); - virtual void processMessageQueue(); virtual void processMessage(Message* m)=0; - private: - static MessageQueue* instance; - MQueue messages; + std::mutex messageQueueMutex; + std::condition_variable messageQueueCond; + private: + static MessageQueue* instance; }; #endif diff --git a/osdopenvg.cc b/osdopenvg.cc index c1682a2..50abceb 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -1237,7 +1237,7 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) m->message=Message::NEW_PICTURE_STATIC; m->tag = info->lindex>> 32LL; } - MessageQueue::getInstance()->postMessageFromOuterSpace(m); // inform command about new picture + MessageQueue::getInstance()->postMessage(m); // inform command about new picture delete info; @@ -1276,7 +1276,7 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) m->message=Message::NEW_PICTURE_STATIC; m->tag = info->lindex>> 32LL; } - MessageQueue::getInstance()->postMessageFromOuterSpace(m); // inform command about new picture + MessageQueue::getInstance()->postMessage(m); // inform command about new picture delete info; } break; diff --git a/osdwinvector.cc b/osdwinvector.cc index 6e566d1..f7aab50 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -1249,7 +1249,7 @@ void OsdWinVector::createPicture(struct PictureInfo& pict_inf) m->message = Message::NEW_PICTURE_STATIC; m->tag = pict_inf.lindex >> 32LL; } - MessageQueue::getInstance()->postMessageFromOuterSpace(m); // inform command about new picture + MessageQueue::getInstance()->postMessage(m); // inform command about new picture } else { pict_inf.decoder->freeReference(pict_inf.reference); diff --git a/player.cc b/player.cc index e8a1323..be9be81 100644 --- a/player.cc +++ b/player.cc @@ -1004,7 +1004,7 @@ void Player::call(void* caller) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = Player::ASPECT43; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } else if (dxCurrentAspect == Demuxer::ASPECT_16_9) { @@ -1016,7 +1016,7 @@ void Player::call(void* caller) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = Player::ASPECT169; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } else { diff --git a/playerliveradio.cc b/playerliveradio.cc index 077d27c..95e0f12 100644 --- a/playerliveradio.cc +++ b/playerliveradio.cc @@ -175,7 +175,7 @@ void PlayerLiveRadio::streamReceive(ULONG flag, void* data, ULONG len) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveRadio::STREAM_END; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } if (streamChunks.size() < 11) @@ -348,7 +348,7 @@ bool PlayerLiveRadio::checkError() m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveRadio::CONNECTION_LOST; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); return true; } @@ -451,7 +451,7 @@ void PlayerLiveRadio::threadMethod() m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveRadio::STREAM_END; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } } } @@ -484,7 +484,7 @@ void PlayerLiveRadio::threadMethod() m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveRadio::PREBUFFERING; m->tag = percentDone; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); if (preBufferCount == preBufferAmount) { diff --git a/playerlivetv.cc b/playerlivetv.cc index 7a79996..ce1e5fc 100644 --- a/playerlivetv.cc +++ b/playerlivetv.cc @@ -251,7 +251,7 @@ void PlayerLiveTV::call(void* caller) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveTV::ASPECT43; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } else if (dxCurrentAspect == Demuxer::ASPECT_16_9) { @@ -270,7 +270,7 @@ void PlayerLiveTV::call(void* caller) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveTV::ASPECT169; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } else { @@ -309,7 +309,7 @@ void PlayerLiveTV::streamReceive(ULONG flag, void* data, ULONG len) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveTV::STREAM_END; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } if (streamChunks.size() < PLAYER_MAX_STREAMING_BUFFERS) @@ -653,7 +653,7 @@ bool PlayerLiveTV::checkError() m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveTV::CONNECTION_LOST; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); return true; } @@ -813,7 +813,7 @@ void PlayerLiveTV::threadMethod() m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveTV::STREAM_END; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); } } } @@ -851,7 +851,7 @@ void PlayerLiveTV::threadMethod() m->message = Message::PLAYER_EVENT; m->parameter = PlayerLiveTV::PREBUFFERING; m->tag = percentDone; - messageQueue->postMessageFromOuterSpace(m); + messageQueue->postMessage(m); if (preBufferCount == preBufferAmount) { diff --git a/playermedia.cc b/playermedia.cc index a3a308a..692dd20 100644 --- a/playermedia.cc +++ b/playermedia.cc @@ -332,7 +332,7 @@ void PlayerMedia::sendFrontendMessage(ULONG para) m->from = this; m->message = Message::PLAYER_EVENT; m->parameter = para; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } //method called by the playing thread to handle @@ -669,7 +669,7 @@ void PlayerMedia::call(void* caller) m->to = frontend; m->message = Message::PLAYER_EVENT; m->parameter = PlayerMedia::ASPECT43; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } else if (dxCurrentAspect == Demuxer::ASPECT_16_9) { @@ -681,7 +681,7 @@ void PlayerMedia::call(void* caller) m->to = frontend; m->message = Message::PLAYER_EVENT; m->parameter = PlayerMedia::ASPECT169; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } else { diff --git a/remote.cc b/remote.cc index c0e4c51..1d0041e 100644 --- a/remote.cc +++ b/remote.cc @@ -541,3 +541,30 @@ bool Remote::saveOptionstoServer() SaveKeysConfig(); return true; } + + + + +bool Remote::start() +{ + Log::getInstance()->log("Remote", Log::INFO, "start called"); + + threadStartProtect.lock(); + listenThread = std::thread( [this ] + { + threadStartProtect.lock(); + threadStartProtect.unlock(); + // FIXME block signals + + eventLoop(); + }); + threadStartProtect.unlock(); + return true; +} + +void Remote::stop() +{ + listenLoopStop = true; + informStopEventLoop(); + listenThread.join(); +} diff --git a/remote.h b/remote.h index cccfb64..2308ba6 100644 --- a/remote.h +++ b/remote.h @@ -22,6 +22,8 @@ #include #include +#include +#include #include "defines.h" #include "abstractoption.h" @@ -36,6 +38,9 @@ class Remote: public AbstractOption virtual ~Remote(); static Remote* getInstance(); + bool start(); + void stop(); + bool addOptionPagesToWTB(WTabBar *wtb); bool loadOptionsfromServer(VDR* vdr); bool saveOptionstoServer(); @@ -49,8 +54,7 @@ class Remote: public AbstractOption virtual int init(const char *devName)=0; virtual int shutdown()=0; - virtual UCHAR getButtonPress(int how)=0; - virtual void clearBuffer()=0; + virtual UCHAR getButtonPress(int how)=0; // DEPRECATED virtual bool mayHaveFewButtons() {return false;}; @@ -155,6 +159,21 @@ class Remote: public AbstractOption static Remote* instance; UCHAR remoteType; RemoteTranslationList translist; + + + std::thread listenThread; + std::mutex threadStartProtect; + + virtual void eventLoop() {}; // FIXME change to abstract + virtual void informStopEventLoop() {}; // abstract + + bool listenLoopStop{}; }; #endif + +// FIXME rename all remote stuff to some sort of INPUT +// Roll in UDP receiver + +// FIXME have Top remote system create new listeners for various devices? Hot plug? +// Where remotelinux has multi listeners, move that to top? diff --git a/remotelinux.cc b/remotelinux.cc index 0ff0916..9018a3e 100644 --- a/remotelinux.cc +++ b/remotelinux.cc @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon; 2012 Marten Richter + Copyright 2004-2020 Chris Tallon; 2012 Marten Richter This file is part of VOMP. @@ -17,19 +17,11 @@ along with VOMP. If not, see . */ -#include "remotelinux.h" -#include "i18n.h" -#include "vdr.h" -#include "woptionpane.h" - #include #include - - -#include - #include #include +#include #include #include @@ -37,10 +29,18 @@ #include +#include +#include using namespace CEC; -#include +#include "i18n.h" +#include "vdr.h" +#include "woptionpane.h" +#include "message.h" +#include "messagequeue.h" +#include "command.h" // FIXME - get rid after predefined message targets +#include "remotelinux.h" #define W_G_HCW(type,code) ((static_cast(type) << 32) | code) @@ -51,71 +51,60 @@ using namespace CEC; RemoteLinux::RemoteLinux() { - initted = 0; - curcec=0; - hascurcec=false; - haspower=false; - powerkey=0; - signal=false; - cec_adap=NULL; - num_loop=0; - cechandlesvolume=false; - } RemoteLinux::~RemoteLinux() { - for (unsigned int i=0; ilog("Remote", Log::NOTICE, "Probe /dev/input/event%d",eventid); - // file exists - unsigned long ev_type=0; - int new_fd=open(buffer,O_RDONLY); - if (new_fd<0) { - Log::getInstance()->log("Remote", Log::NOTICE, "Can not open /dev/input/event%d",eventid); - continue; - } - if (ioctl(new_fd, EVIOCGBIT(0, EV_MAX), &ev_type) < 0) { - Log::getInstance()->log("Remote", Log::NOTICE, "Ioctl failed /dev/input/event%d %d",eventid,errno); - close(new_fd); - } - //Now test if it generates keyboard presses - if (test_bit((char*)&ev_type , EV_KEY)) { - Log::getInstance()->log("Remote", Log::NOTICE, "Add /dev/input/event%d to List",eventid); - devices.push_back(new_fd); - } else { - close(new_fd); - } - - - - - } - - - - + for (int eventid = 0; eventid < 100; eventid++) + { + char buffer[1024]; + sprintf(buffer,"/dev/input/event%d", eventid); + struct stat test_buf; + if (stat(buffer, &test_buf) == 0) + { + Log::getInstance()->log("Remote", Log::NOTICE, "Probe /dev/input/event%d", eventid); + // file exists + unsigned long ev_type = 0; + int new_fd = open(buffer, O_RDONLY); + if (new_fd < 0) + { + Log::getInstance()->log("Remote", Log::NOTICE, "Can not open /dev/input/event%d", eventid); + continue; + } + + if (ioctl(new_fd, EVIOCGBIT(0, EV_MAX), &ev_type) < 0) + { + Log::getInstance()->log("Remote", Log::NOTICE, "Ioctl failed /dev/input/event%d %d", eventid, errno); + close(new_fd); + } + + //Now test if it generates keyboard presses + if (test_bit(reinterpret_cast(&ev_type), EV_KEY)) + { + Log::getInstance()->log("Remote", Log::NOTICE, "Add /dev/input/event%d to List", eventid); + devices.push_back(new_fd); + } + else + { + close(new_fd); + } + } } return initCec(); } @@ -225,15 +214,16 @@ void RemoteLinux::deinitCec() } } - +/* UCHAR RemoteLinux::getButtonPress(int waitType) { - /* how = 0 - block + / * how = 0 - block how = 1 - start new wait how = 2 - continue wait how = 3 - no wait - */ + * / //in units of 40 ms + Log::getInstance()->log("Remote", Log::NOTICE, "get button press"); int retval; fd_set readfds; @@ -267,6 +257,9 @@ UCHAR RemoteLinux::getButtonPress(int waitType) { FD_SET(cur_fd, &readfds); } + FD_SET(pfds[0], &readfds); + maxfd = max(pfds[0], maxfd); + retval = select(maxfd + 1, &readfds, NULL, NULL, &tv); tv.tv_sec = 0; tv.tv_usec = 40000; @@ -287,8 +280,15 @@ UCHAR RemoteLinux::getButtonPress(int waitType) { if (retval == -1) { Log::getInstance()->log("Remote", Log::NOTICE, "na_signal"); return NA_SIGNAL; - } + + if (FD_ISSET(pfds[0], &readfds)) + { + // quit signal + Log::getInstance()->log("Remote", Log::NOTICE, "pfds quit"); + return NA_SIGNAL; // use NA_SIGNAL for now + } + for (unsigned int i = 0; i < devices.size(); i++) { int cur_fd = devices[i]; if (FD_ISSET(cur_fd, &readfds)) { @@ -317,60 +317,54 @@ UCHAR RemoteLinux::getButtonPress(int waitType) { return NA_UNKNOWN; } - -void RemoteLinux::clearBuffer() -{ - UCHAR buttonpress=getButtonPress(3); - while(buttonpress != NA_NONE && buttonpress!=NA_UNKNOWN){ - buttonpress=getButtonPress(3); - }; -} +*/ UCHAR RemoteLinux::TranslateHWCFixed(ULLONG code) { switch (code) { - case W_G_HCW(W_HCW_KC,KEY_DOWN): + case W_G_HCW(W_HCW_KC, KEY_DOWN): return DOWN; - case W_G_HCW(W_HCW_KC,KEY_UP): + case W_G_HCW(W_HCW_KC, KEY_UP): return UP; - case W_G_HCW(W_HCW_KC,KEY_LEFT): + case W_G_HCW(W_HCW_KC, KEY_LEFT): return LEFT; - case W_G_HCW(W_HCW_KC,KEY_RIGHT): + case W_G_HCW(W_HCW_KC, KEY_RIGHT): return RIGHT; - case W_G_HCW(W_HCW_KC,KEY_M): - case W_G_HCW(W_HCW_KC,KEY_MEDIA): + case W_G_HCW(W_HCW_KC, KEY_M): + case W_G_HCW(W_HCW_KC, KEY_MEDIA): return MENU; - case W_G_HCW(W_HCW_KC,KEY_BACKSPACE): - case W_G_HCW(W_HCW_KC,KEY_EXIT): + case W_G_HCW(W_HCW_KC, KEY_BACKSPACE): + case W_G_HCW(W_HCW_KC, KEY_EXIT): return BACK; - case W_G_HCW(W_HCW_KC,KEY_ENTER): - case W_G_HCW(W_HCW_KC,KEY_SPACE): - case W_G_HCW(W_HCW_KC,KEY_OK): + case W_G_HCW(W_HCW_KC, KEY_ENTER): + case W_G_HCW(W_HCW_KC, KEY_SPACE): + case W_G_HCW(W_HCW_KC, KEY_OK): return OK; + //CEC - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_DOWN): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_DOWN): return DOWN; - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_UP): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_UP): return UP; - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_LEFT): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_LEFT): return LEFT; - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RIGHT): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_RIGHT): return RIGHT; - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ROOT_MENU): - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CONTENTS_MENU): - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SETUP_MENU): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_ROOT_MENU): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_CONTENTS_MENU): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_SETUP_MENU): return MENU; - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_EXIT ): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_EXIT ): return BACK; - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ENTER): - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SELECT): - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_AN_RETURN): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_ENTER): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_SELECT): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_AN_RETURN): return OK; - case W_G_HCW(W_HCW_KC,KEY_SLEEP): - case W_G_HCW(W_HCW_KC,KEY_POWER): - case W_G_HCW(W_HCW_KC,KEY_ESC): - case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_POWER): + case W_G_HCW(W_HCW_KC, KEY_SLEEP): + case W_G_HCW(W_HCW_KC, KEY_POWER): + case W_G_HCW(W_HCW_KC, KEY_ESC): + case W_G_HCW(W_HCW_CEC, CEC_USER_CONTROL_CODE_POWER): case POWER: return POWER; default: @@ -380,148 +374,146 @@ UCHAR RemoteLinux::TranslateHWCFixed(ULLONG code) const char*RemoteLinux::HardcodedTranslateStr(UCHAR command) { - switch (command) - { + switch (command) + { case DOWN: - return tr("Down"); + return tr("Down"); case UP: - return tr("Up"); + return tr("Up"); case LEFT: - return tr("Left"); + return tr("Left"); case RIGHT: - return tr("Right"); + return tr("Right"); case MENU: - return tr("M"); + return tr("M"); case BACK: - return tr("Backspace, Back"); + return tr("Backspace, Back"); case OK: - return tr("Return, Space"); + return tr("Return, Space"); default: - return NULL; - }; - + return NULL; + } } void RemoteLinux::InitHWCListwithDefaults() { - //Processing VK_Messages - translist[W_G_HCW(W_HCW_KC,KEY_9)] = NINE; - translist[W_G_HCW(W_HCW_KC,KEY_8)] = EIGHT; - translist[W_G_HCW(W_HCW_KC,KEY_7)] = SEVEN; - translist[W_G_HCW(W_HCW_KC,KEY_6)] = SIX; - translist[W_G_HCW(W_HCW_KC,KEY_5)] = FIVE; - translist[W_G_HCW(W_HCW_KC,KEY_4)] = FOUR; - translist[W_G_HCW(W_HCW_KC,KEY_3)] = THREE; - translist[W_G_HCW(W_HCW_KC,KEY_2)] = TWO; - translist[W_G_HCW(W_HCW_KC,KEY_1)] = ONE; - translist[W_G_HCW(W_HCW_KC,KEY_0)] = ZERO; - translist[W_G_HCW(W_HCW_KC,KEY_KPDOT)] = STAR; - // translist[W_G_HCW(W_HCW_KC,KEY_#)] = HASH; - - translist[W_G_HCW(W_HCW_KC,KEY_KP9)] = NINE; - translist[W_G_HCW(W_HCW_KC,KEY_KP8)] = EIGHT; - translist[W_G_HCW(W_HCW_KC,KEY_KP7)] = SEVEN; - translist[W_G_HCW(W_HCW_KC,KEY_KP6)] = SIX; - translist[W_G_HCW(W_HCW_KC,KEY_KP5)] = FIVE; - translist[W_G_HCW(W_HCW_KC,KEY_KP4)] = FOUR; - translist[W_G_HCW(W_HCW_KC,KEY_KP3)] = THREE; - translist[W_G_HCW(W_HCW_KC,KEY_KP2)] = TWO; - translist[W_G_HCW(W_HCW_KC,KEY_KP1)] = ONE; - translist[W_G_HCW(W_HCW_KC,KEY_KP0)] = ZERO; - - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_9)] = NINE; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_8)] = EIGHT; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_7)] = SEVEN; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_6)] = SIX; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_5)] = FIVE; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_4)] = FOUR; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_3)] = THREE; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_2)] = TWO; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_1)] = ONE; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_0)] = ZERO; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_STAR)] = STAR; - translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_POUND)] = HASH; - - - translist[W_G_HCW(W_HCW_KC,KEY_J)] = GO; //j for JUMP TO instead of go to - translist[W_G_HCW(W_HCW_KC,KEY_R)] = RED; - translist[W_G_HCW(W_HCW_KC,KEY_G)] = GREEN; - translist[W_G_HCW(W_HCW_KC,KEY_Y)] = YELLOW; - translist[W_G_HCW(W_HCW_KC,KEY_B)] = BLUE; - //Processing Remote Style Messages - translist[W_G_HCW(W_HCW_KC,KEY_GREEN)] = GREEN; - translist[W_G_HCW(W_HCW_KC,KEY_RED)] = RED; - translist[W_G_HCW(W_HCW_KC,KEY_YELLOW)] = YELLOW; - translist[W_G_HCW(W_HCW_KC,KEY_BLUE)] = BLUE; - translist[W_G_HCW(W_HCW_KC,KEY_MENU)] = MENU; - - translist[W_G_HCW(W_HCW_KC,KEY_RECORD)] = RECORD; - translist[W_G_HCW(W_HCW_KC,KEY_PLAY)] = PLAY; //Playback Televison - translist[W_G_HCW(W_HCW_KC,KEY_PAUSE)] = PAUSE; - translist[W_G_HCW(W_HCW_KC,KEY_STOP)] = STOP; - translist[W_G_HCW(W_HCW_KC,KEY_PLAYPAUSE)] = PLAYPAUSE; - translist[W_G_HCW(W_HCW_KC,KEY_P)] = PLAYPAUSE; - translist[W_G_HCW(W_HCW_KC,KEY_NEXT)] = SKIPFORWARD; - translist[W_G_HCW(W_HCW_KC,KEY_F2)] = SKIPFORWARD; - translist[W_G_HCW(W_HCW_KC,KEY_PREVIOUS)] = SKIPBACK; - translist[W_G_HCW(W_HCW_KC,KEY_F1)] = SKIPBACK; - translist[W_G_HCW(W_HCW_KC,KEY_FORWARD)] = FORWARD; - translist[W_G_HCW(W_HCW_KC,KEY_FASTFORWARD)] = FORWARD; - translist[W_G_HCW(W_HCW_KC,KEY_F)] = FORWARD; - translist[W_G_HCW(W_HCW_KC,KEY_BACK)] = REVERSE; - translist[W_G_HCW(W_HCW_KC,KEY_REWIND)] = REVERSE; - translist[W_G_HCW(W_HCW_KC,KEY_T)] = REVERSE; - translist[W_G_HCW(W_HCW_KC,KEY_MUTE)] = MUTE; - translist[W_G_HCW(W_HCW_KC,KEY_F8)] = MUTE; - translist[W_G_HCW(W_HCW_KC,KEY_F10)] = VOLUMEUP; - translist[W_G_HCW(W_HCW_KC,KEY_F9)] = VOLUMEDOWN; - translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEUP)] = VOLUMEUP; - translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEDOWN)] = VOLUMEDOWN; - translist[W_G_HCW(W_HCW_KC,KEY_CHANNELUP)] = CHANNELUP; - translist[W_G_HCW(W_HCW_KC,KEY_CHANNELDOWN)] = CHANNELDOWN; - translist[W_G_HCW(W_HCW_KC,KEY_PAGEUP)] = CHANNELUP; - translist[W_G_HCW(W_HCW_KC,KEY_PAGEDOWN)] = CHANNELDOWN; - - - //Processing CEC_Messages - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER9)] = NINE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER8)] = EIGHT; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER7)] = SEVEN; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER6)] = SIX; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER5)] = FIVE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER4)] = FOUR; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER3)] = THREE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER2)] = TWO; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER1)] = ONE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER0)] = ZERO; - //translist[W_G_HCW(W_HCW_CEC,KEY_KPDOT)] = STAR; - - - - //translist[W_G_HCW(W_HCW_CEC,KEY_J)] = GO; //j for JUMP TO instead of go to - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F2_RED)] = RED; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F3_GREEN)] = GREEN; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F4_YELLOW)] = YELLOW; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F1_BLUE)] = BLUE; - //Processing Remote Style Messages - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAVORITE_MENU)] = MENU; - - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RECORD)] = RECORD; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PLAY)] = PLAY; //Playback Televison - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE)] = PAUSE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_STOP)] = STOP; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION)] = PLAYPAUSE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FORWARD)] = SKIPFORWARD; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_BACKWARD)] = SKIPBACK; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAST_FORWARD )] = FORWARD; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_REWIND)] = REVERSE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_MUTE)] = MUTE; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_UP)] = VOLUMEUP; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_DOWN)] = VOLUMEDOWN; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_UP )] = CHANNELUP; - translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_DOWN)] = CHANNELDOWN; - + // Processing VK_Messages + translist[W_G_HCW(W_HCW_KC,KEY_9)] = NINE; + translist[W_G_HCW(W_HCW_KC,KEY_8)] = EIGHT; + translist[W_G_HCW(W_HCW_KC,KEY_7)] = SEVEN; + translist[W_G_HCW(W_HCW_KC,KEY_6)] = SIX; + translist[W_G_HCW(W_HCW_KC,KEY_5)] = FIVE; + translist[W_G_HCW(W_HCW_KC,KEY_4)] = FOUR; + translist[W_G_HCW(W_HCW_KC,KEY_3)] = THREE; + translist[W_G_HCW(W_HCW_KC,KEY_2)] = TWO; + translist[W_G_HCW(W_HCW_KC,KEY_1)] = ONE; + translist[W_G_HCW(W_HCW_KC,KEY_0)] = ZERO; + translist[W_G_HCW(W_HCW_KC,KEY_KPDOT)] = STAR; + // translist[W_G_HCW(W_HCW_KC,KEY_#)] = HASH; + + translist[W_G_HCW(W_HCW_KC,KEY_KP9)] = NINE; + translist[W_G_HCW(W_HCW_KC,KEY_KP8)] = EIGHT; + translist[W_G_HCW(W_HCW_KC,KEY_KP7)] = SEVEN; + translist[W_G_HCW(W_HCW_KC,KEY_KP6)] = SIX; + translist[W_G_HCW(W_HCW_KC,KEY_KP5)] = FIVE; + translist[W_G_HCW(W_HCW_KC,KEY_KP4)] = FOUR; + translist[W_G_HCW(W_HCW_KC,KEY_KP3)] = THREE; + translist[W_G_HCW(W_HCW_KC,KEY_KP2)] = TWO; + translist[W_G_HCW(W_HCW_KC,KEY_KP1)] = ONE; + translist[W_G_HCW(W_HCW_KC,KEY_KP0)] = ZERO; + + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_9)] = NINE; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_8)] = EIGHT; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_7)] = SEVEN; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_6)] = SIX; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_5)] = FIVE; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_4)] = FOUR; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_3)] = THREE; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_2)] = TWO; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_1)] = ONE; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_0)] = ZERO; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_STAR)] = STAR; + translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_POUND)] = HASH; + + + translist[W_G_HCW(W_HCW_KC,KEY_J)] = GO; //j for JUMP TO instead of go to + translist[W_G_HCW(W_HCW_KC,KEY_R)] = RED; + translist[W_G_HCW(W_HCW_KC,KEY_G)] = GREEN; + translist[W_G_HCW(W_HCW_KC,KEY_Y)] = YELLOW; + translist[W_G_HCW(W_HCW_KC,KEY_B)] = BLUE; + //Processing Remote Style Messages + translist[W_G_HCW(W_HCW_KC,KEY_GREEN)] = GREEN; + translist[W_G_HCW(W_HCW_KC,KEY_RED)] = RED; + translist[W_G_HCW(W_HCW_KC,KEY_YELLOW)] = YELLOW; + translist[W_G_HCW(W_HCW_KC,KEY_BLUE)] = BLUE; + translist[W_G_HCW(W_HCW_KC,KEY_MENU)] = MENU; + + translist[W_G_HCW(W_HCW_KC,KEY_RECORD)] = RECORD; + translist[W_G_HCW(W_HCW_KC,KEY_PLAY)] = PLAY; //Playback Televison + translist[W_G_HCW(W_HCW_KC,KEY_PAUSE)] = PAUSE; + translist[W_G_HCW(W_HCW_KC,KEY_STOP)] = STOP; + translist[W_G_HCW(W_HCW_KC,KEY_PLAYPAUSE)] = PLAYPAUSE; + translist[W_G_HCW(W_HCW_KC,KEY_P)] = PLAYPAUSE; + translist[W_G_HCW(W_HCW_KC,KEY_NEXT)] = SKIPFORWARD; + translist[W_G_HCW(W_HCW_KC,KEY_F2)] = SKIPFORWARD; + translist[W_G_HCW(W_HCW_KC,KEY_PREVIOUS)] = SKIPBACK; + translist[W_G_HCW(W_HCW_KC,KEY_F1)] = SKIPBACK; + translist[W_G_HCW(W_HCW_KC,KEY_FORWARD)] = FORWARD; + translist[W_G_HCW(W_HCW_KC,KEY_FASTFORWARD)] = FORWARD; + translist[W_G_HCW(W_HCW_KC,KEY_F)] = FORWARD; + translist[W_G_HCW(W_HCW_KC,KEY_BACK)] = REVERSE; + translist[W_G_HCW(W_HCW_KC,KEY_REWIND)] = REVERSE; + translist[W_G_HCW(W_HCW_KC,KEY_T)] = REVERSE; + translist[W_G_HCW(W_HCW_KC,KEY_MUTE)] = MUTE; + translist[W_G_HCW(W_HCW_KC,KEY_F8)] = MUTE; + translist[W_G_HCW(W_HCW_KC,KEY_F10)] = VOLUMEUP; + translist[W_G_HCW(W_HCW_KC,KEY_F9)] = VOLUMEDOWN; + translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEUP)] = VOLUMEUP; + translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEDOWN)] = VOLUMEDOWN; + translist[W_G_HCW(W_HCW_KC,KEY_CHANNELUP)] = CHANNELUP; + translist[W_G_HCW(W_HCW_KC,KEY_CHANNELDOWN)] = CHANNELDOWN; + translist[W_G_HCW(W_HCW_KC,KEY_PAGEUP)] = CHANNELUP; + translist[W_G_HCW(W_HCW_KC,KEY_PAGEDOWN)] = CHANNELDOWN; + + + //Processing CEC_Messages + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER9)] = NINE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER8)] = EIGHT; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER7)] = SEVEN; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER6)] = SIX; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER5)] = FIVE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER4)] = FOUR; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER3)] = THREE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER2)] = TWO; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER1)] = ONE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER0)] = ZERO; + //translist[W_G_HCW(W_HCW_CEC,KEY_KPDOT)] = STAR; + + + + //translist[W_G_HCW(W_HCW_CEC,KEY_J)] = GO; //j for JUMP TO instead of go to + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F2_RED)] = RED; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F3_GREEN)] = GREEN; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F4_YELLOW)] = YELLOW; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F1_BLUE)] = BLUE; + //Processing Remote Style Messages + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAVORITE_MENU)] = MENU; + + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RECORD)] = RECORD; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PLAY)] = PLAY; //Playback Televison + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE)] = PAUSE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_STOP)] = STOP; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION)] = PLAYPAUSE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FORWARD)] = SKIPFORWARD; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_BACKWARD)] = SKIPBACK; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAST_FORWARD )] = FORWARD; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_REWIND)] = REVERSE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_MUTE)] = MUTE; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_UP)] = VOLUMEUP; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_DOWN)] = VOLUMEDOWN; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_UP )] = CHANNELUP; + translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_DOWN)] = CHANNELDOWN; } #define NAMETRICK(pre, code) linux_keymap[pre ## code]= #code @@ -533,334 +525,337 @@ static const char * cec_keymap[CEC_USER_CONTROL_CODE_MAX+1]; void RemoteLinux::InitKeymap() { - for (int i=0;i> 32; - char *rt=NULL; + unsigned int type = static_cast(hcw >> 32); + unsigned int vk = static_cast(hcw); + char* rt = NULL; + switch(type) { - case W_HCW_KC:{ - unsigned int vk=(ULONG)hcw; - rt=new char[10]; + case W_HCW_KC: + { + rt = new char[10]; const char *desc=linux_keymap[vk]; - if (desc) { - strncpy(rt,desc,9); - } else { - sprintf(rt,"0x%x",vk); - } - }break; - case W_HCW_CEC:{ - unsigned int vk=(ULONG)hcw; - rt=new char[10]; - const char *desc=cec_keymap[vk]; - if (desc) { - strncpy(rt,desc,9); - } else { - sprintf(rt,"0x%x",vk); - } - }break; + if (desc) + strncpy(rt, desc, 9); + else + sprintf(rt, "0x%x", vk); + break; + } + case W_HCW_CEC: + { + rt = new char[10]; + const char* desc = cec_keymap[vk]; + if (desc) + strncpy(rt, desc, 9); + else + sprintf(rt, "0x%x", vk); + break; + } /* case W_HCW_LIRC:{ ULONG ri=(ULONG)hcw; rt=new char[10]; sprintf(rt,"R: %X",ri); }break;*/ + } - }; return rt; } -void RemoteLinux::changePowerState(bool poweron){ - if (cec_adap) { - if (poweron) { - //Log::getInstance()->log("Remote", Log::DEBUG, "CEC set active source" ); - cec_adap->SetActiveSource(cec_config.deviceTypes[0]); - haspower=false; - } else { - //Log::getInstance()->log("Remote", Log::DEBUG, "CEC set inactive view" ); - cec_adap->SetInactiveView(); - haspower=false; //clear stuff - } - } +void RemoteLinux::changePowerState(bool poweron) +{ + if (cec_adap) + { + if (poweron) + { + //Log::getInstance()->log("Remote", Log::DEBUG, "CEC set active source"); + cec_adap->SetActiveSource(cec_config.deviceTypes[0]); + } + else + { + //Log::getInstance()->log("Remote", Log::DEBUG, "CEC set inactive view"); + cec_adap->SetInactiveView(); + } + } } #if CEC_LIB_VERSION_MAJOR >= 4 @@ -924,13 +924,13 @@ void RemoteLinux::changePowerState(bool poweron){ void RemoteLinux::cecLogMessage(void* /* param */, const cec_log_message* message) { - Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s", message->time, message->level, message->message); + Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s", message->time, message->level, message->message); } void RemoteLinux::cecKeyPress(void* /* param */, const cec_keypress* key) { - //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key->keycode,key->duration); - if (key->duration==0) static_cast(Remote::getInstance())->incomingCECkey(key->keycode); + //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key->keycode,key->duration); + if (key->duration == 0) static_cast(Remote::getInstance())->incomingCECkey(key->keycode); } void RemoteLinux::cecCommand(void* /* param */, const cec_command* command) @@ -975,16 +975,17 @@ void RemoteLinux::cecConfigurationChanged(void* /* param */, const libcec_config int RemoteLinux::cecLogMessage(void *param, const cec_log_message message) { - Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s",message.time , message.level, message.message ); - return 0; + Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s", message.time, message.level, message.message); + return 0; } int RemoteLinux::cecKeyPress(void*param, const cec_keypress key) { - //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key.keycode,key.duration); - if (key.duration==0) ((RemoteLinux*)Remote::getInstance())->incomingCECkey(key.keycode); - return 1; + //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key.keycode,key.duration); + if (key.duration == 0) ((RemoteLinux*)Remote::getInstance())->incomingCECkey(key.keycode); + return 1; } + int RemoteLinux::cecCommand(void *param, const cec_command command) { Log::getInstance()->log("Remote", Log::DEBUG, "CECCommand: %d",command.opcode); @@ -1030,64 +1031,72 @@ int RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration void RemoteLinux::cecSourceActivated(void* /* param */, const cec_logical_address address, const uint8_t activated) { - Log::getInstance()->log("Remote", Log::DEBUG, "CECSourceActivated: %d %d", address, activated); - if (activated==1) { - static_cast(Remote::getInstance())->incomingPowerkey(POWERON); - } + Log::getInstance()->log("Remote", Log::DEBUG, "CECSourceActivated: %d %d", address, activated); + if (activated == 1) + { + static_cast(Remote::getInstance())->incomingPowerkey(POWERON); + } } void RemoteLinux::incomingCECkey(int keys) { - curcec=keys; - hascurcec=true; + // Send INPUT message + Message* m = new Message(); + m->message = Message::INPUT_EVENT; + m->to = Command::getInstance(); + m->from = this; + m->parameter = static_cast(TranslateHWC(W_G_HCW(W_HCW_CEC, keys))); + MessageQueue::getInstance()->postMessage(m); } -void RemoteLinux::incomingPowerkey(UCHAR key){ - haspower=true; - powerkey=key; +void RemoteLinux::incomingPowerkey(UCHAR key) +{ + // Send INPUT message + Message* m = new Message(); + m->message = Message::INPUT_EVENT; + m->to = Command::getInstance(); + m->from = this; + m->parameter = key; + MessageQueue::getInstance()->postMessage(m); } bool RemoteLinux::loadOptionsfromServer(VDR* vdr) { - // Set remote keys - char * name; + char* name; name = vdr->configLoad("RemoteLinux", "HandleVolume"); - if (name != NULL) { - if (STRCASECMP(name, "Vomp") == 0) { - cechandlesvolume=false; - } else if (STRCASECMP(name, "Cec") == 0) { - cechandlesvolume=true; - } - delete[] name; - } + if (name != NULL) + { + if (STRCASECMP(name, "Vomp") == 0) cechandlesvolume = false; + else if (STRCASECMP(name, "Cec") == 0) cechandlesvolume = true; + delete[] name; + } return Remote::loadOptionsfromServer(vdr); } bool RemoteLinux::saveOptionstoServer() { - if (cechandlesvolume) VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Cec"); - else VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Vomp"); + if (cechandlesvolume) VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Cec"); + else VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Vomp"); - return Remote::saveOptionstoServer(); + return Remote::saveOptionstoServer(); } bool RemoteLinux::addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane) { - if (!Remote::addOptionsToPanes(panenumber,options,pane)) return false; - - - Option* option; - if (panenumber == 2) - { - static const char* volumeopts[]={"Vomp","Cec"}; - option = new Option(100,tr("Volume handled by"), "RemoteLinux","HandleVolume",Option::TYPE_TEXT,/*4,2*/2,0,0,volumeopts,NULL,false,this); - options->push_back(option); - pane->addOptionLine(option); - } + if (!Remote::addOptionsToPanes(panenumber, options, pane)) return false; + + Option* option; + if (panenumber == 2) + { + static const char* volumeopts[]={"Vomp","Cec"}; + option = new Option(100,tr("Volume handled by"), "RemoteLinux","HandleVolume",Option::TYPE_TEXT,/*4,2*/2,0,0,volumeopts,NULL,false,this); + options->push_back(option); + pane->addOptionLine(option); + } - return true; + return true; } bool RemoteLinux::handleOptionChanges(Option* option) @@ -1113,20 +1122,103 @@ bool RemoteLinux::handleOptionChanges(Option* option) void RemoteLinux::volumeUp() { - cec_adap->VolumeUp(); + cec_adap->VolumeUp(); } void RemoteLinux::volumeDown() { - cec_adap->VolumeDown(); + cec_adap->VolumeDown(); } void RemoteLinux::volumeMute() { #if CEC_LIB_VERSION_MAJOR >= 4 - cec_adap->AudioToggleMute(); + cec_adap->AudioToggleMute(); #else - cec_adap->MuteAudio(); + cec_adap->MuteAudio(); #endif } +void RemoteLinux::informStopEventLoop() +{ + listenLoopStop = true; + write(pfds[1], "1", 1); // break the select in getButtonPress +} + +void RemoteLinux::eventLoop() +{ + fd_set readfds; + int maxfd; + + if (pipe2(pfds, O_NONBLOCK) == -1) + { + Log::getInstance()->log("RemoteLinux", Log::ERR, "pipe2() fail"); + return; + } + + Log::getInstance()->log("RemoteLinux", Log::INFO, "Listen loop"); + + while(1) + { + if (listenLoopStop) break; + + FD_ZERO(&readfds); + + maxfd = 0; + for (unsigned int i = 0; i < devices.size(); i++) + { + int cur_fd = devices[i]; + maxfd = max(cur_fd, maxfd); + FD_SET(cur_fd, &readfds); + } + + FD_SET(pfds[0], &readfds); + maxfd = max(pfds[0], maxfd); + + // 0 = nothing happened and timeout expired + // >0 = num of descriptors that changed + // -1 = error + if (select(maxfd + 1, &readfds, NULL, NULL, NULL) < 1) + { + Log::getInstance()->log("RemoteLinux", Log::ERR, "Select fail"); + break; + } + + if (FD_ISSET(pfds[0], &readfds)) + { + // assume quit signal + Log::getInstance()->log("Remote", Log::NOTICE, "pfds quit"); + break; + + // FUTURE: read the byte and do different things? Read listenLoopStop and maybe other bools? + } + + for (unsigned int i = 0; i < devices.size(); i++) + { + int cur_fd = devices[i]; + if (FD_ISSET(cur_fd, &readfds)) + { + struct input_event ev; + int count = read(cur_fd, &ev, sizeof(ev)); + if (count == sizeof(ev)) + { + if (ev.type == EV_KEY && ev.value == 1) + { + // Send INPUT message + Message* m = new Message(); + m->message = Message::INPUT_EVENT; + m->to = Command::getInstance(); + m->from = this; + m->parameter = static_cast(TranslateHWC(W_G_HCW(W_HCW_KC,ev.code))); + MessageQueue::getInstance()->postMessage(m); + } + } + } + } + } + + close(pfds[1]); + close(pfds[0]); +} + +// FIXME surely NA_SIGNAL can go diff --git a/remotelinux.h b/remotelinux.h index fe382fe..7de9e60 100644 --- a/remotelinux.h +++ b/remotelinux.h @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon; 2012 Marten Richter + Copyright 2004-2020 Chris Tallon; 2012 Marten Richter This file is part of VOMP. @@ -14,26 +14,20 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef REMOTELINUX_H #define REMOTELINUX_H #include +#include +#include #include "defines.h" #include "log.h" #include "remote.h" -#include -#include - - - - - class RemoteLinux : public Remote { public: @@ -43,11 +37,10 @@ class RemoteLinux : public Remote int init(const char *devName); int shutdown(); int getDevice(); - UCHAR getButtonPress(int how); - void clearBuffer(); + UCHAR getButtonPress(int) { return NA_UNKNOWN; } // DEPRECATED // void Signal(); -// void SendPower(); +// void SendPower(); void InitHWCListwithDefaults(); const char*HardcodedTranslateStr(UCHAR command); char* HCWDesc(ULLONG hcw); @@ -61,7 +54,7 @@ class RemoteLinux : public Remote bool mayHaveFewButtons() {return true;}; - virtual bool handlesVolume() {return cechandlesvolume;}; + virtual bool handlesVolume() { return cechandlesvolume; }; virtual void volumeUp(); virtual void volumeDown(); virtual void volumeMute(); @@ -69,23 +62,17 @@ class RemoteLinux : public Remote int initCec(); void deinitCec(); - - private: - int initted; - bool signal; - int curcec; - bool hascurcec; - bool cechandlesvolume; - bool haspower; - UCHAR powerkey; + int initted{}; + bool signal{}; + bool cechandlesvolume{}; UCHAR TranslateHWCFixed(ULLONG code); void InitKeymap(); std::vector devices; - int num_loop; + int num_loop{}; - CEC::ICECAdapter * cec_adap; + CEC::ICECAdapter* cec_adap{}; CEC::libcec_configuration cec_config; CEC::ICECCallbacks cec_callbacks; @@ -93,19 +80,22 @@ class RemoteLinux : public Remote void incomingPowerkey(UCHAR key); #if CEC_LIB_VERSION_MAJOR >= 4 - static void cecLogMessage(void *param, const CEC::cec_log_message* message); - static void cecKeyPress(void*param, const CEC::cec_keypress* key); - static void cecCommand(void *param, const CEC::cec_command* command); - static void cecConfigurationChanged(void *param, const CEC::libcec_configuration* config); + static void cecLogMessage(void *param, const CEC::cec_log_message* message); + static void cecKeyPress(void*param, const CEC::cec_keypress* key); + static void cecCommand(void *param, const CEC::cec_command* command); + static void cecConfigurationChanged(void *param, const CEC::libcec_configuration* config); #else - static int cecLogMessage(void *param, const CEC::cec_log_message message); - static int cecKeyPress(void*param, const CEC::cec_keypress key); - static int cecCommand(void *param, const CEC::cec_command command); - static int cecConfigurationChanged(void *param, const CEC::libcec_configuration config); + static int cecLogMessage(void *param, const CEC::cec_log_message message); + static int cecKeyPress(void*param, const CEC::cec_keypress key); + static int cecCommand(void *param, const CEC::cec_command command); + static int cecConfigurationChanged(void *param, const CEC::libcec_configuration config); #endif static void cecSourceActivated(void*param, const CEC::cec_logical_address address, const uint8_t activated); + void eventLoop(); + void informStopEventLoop(); + + int pfds[2]; }; #endif - diff --git a/remotewin.cc b/remotewin.cc index 4dd1da4..52d7025 100644 --- a/remotewin.cc +++ b/remotewin.cc @@ -100,10 +100,6 @@ UCHAR RemoteWin::getButtonPress(int waitType) } -void RemoteWin::clearBuffer() -{ -} - UCHAR RemoteWin::TranslateHWCFixed(ULLONG code) { switch (code) diff --git a/remotewin.h b/remotewin.h index bda8221..c866333 100644 --- a/remotewin.h +++ b/remotewin.h @@ -43,7 +43,6 @@ class RemoteWin : public Remote int shutdown(); int getDevice(); UCHAR getButtonPress(int how); - void clearBuffer(); void Signal(); int ReceiveButtonVK(UINT button);//Windows Message from WND_PROC int ReceiveButtonCH(UINT button);//Windows Message from WND_PROC diff --git a/teletextdecodervbiebu.cc b/teletextdecodervbiebu.cc index 4a4a2e2..f50864b 100644 --- a/teletextdecodervbiebu.cc +++ b/teletextdecodervbiebu.cc @@ -824,14 +824,14 @@ void TeletextDecoderVBIEBU::RenderTeletextCode(bool renderfirstlineonly) { m->to = txtview; m->from = this; m->parameter = 0; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } else if (firstlineupdate==10) { Message* m= new Message(); m->message = Message::TELETEXTUPDATEFIRSTLINE; m->to = txtview; m->from = this; m->parameter = 0; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); firstlineupdate=0; } else firstlineupdate++; diff --git a/timers.h b/timers.h index 36db443..3cbd1d3 100644 --- a/timers.h +++ b/timers.h @@ -35,7 +35,6 @@ Big Mutex. > * Most (all?) timercall()s eventually send a message to command in order to > do something within The Big Mutex. This makes it easier and simpler code wise > * Gets rid of Timers. -> * Hopefully gets rid of most postMessageFromOuterSpace calls > Bad points: > * Timers become gui only features. Solve this with a MessageReceiver interface and diff --git a/vaudioselector.cc b/vaudioselector.cc index 746f189..fd80800 100644 --- a/vaudioselector.cc +++ b/vaudioselector.cc @@ -441,7 +441,7 @@ VAudioSelector::~VAudioSelector() m->from = this; m->to = parent; m->message = Message::CHILD_CLOSE; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } void VAudioSelector::draw() @@ -486,7 +486,7 @@ int VAudioSelector::handleCommand(int command) m->to = parent; m->message = Message::SUBTITLE_CHANGE_CHANNEL; m->parameter = (((AudioSubtitleChannel*)ssl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)ssl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } else { asl.up(); asl.draw(); @@ -496,7 +496,7 @@ int VAudioSelector::handleCommand(int command) m->to = parent; m->message = Message::AUDIO_CHANGE_CHANNEL; m->parameter = (((AudioSubtitleChannel*)asl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)asl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } return 2; @@ -514,7 +514,7 @@ int VAudioSelector::handleCommand(int command) m->message = Message::SUBTITLE_CHANGE_CHANNEL; m->parameter = (((AudioSubtitleChannel*)ssl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)ssl.getCurrentOptionData())->type &0xFF)<<16 |(((AudioSubtitleChannel*)asl.getCurrentOptionData())->streamtype &0xFF)<<24 ; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } else { asl.down(); asl.draw(); @@ -525,7 +525,7 @@ int VAudioSelector::handleCommand(int command) m->message = Message::AUDIO_CHANGE_CHANNEL; m->parameter = (((AudioSubtitleChannel*)asl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)asl.getCurrentOptionData())->type &0xFF)<<16 |(((AudioSubtitleChannel*)asl.getCurrentOptionData())->streamtype &0xFF)<<24 ; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } return 2; @@ -583,7 +583,7 @@ void VAudioSelector::processMessage(Message* m) m2->to = parent; m2->message = Message::AUDIO_CHANGE_CHANNEL; m2->parameter = (((AudioSubtitleChannel*)asl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)asl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } return; @@ -605,7 +605,7 @@ void VAudioSelector::processMessage(Message* m) m2->to = parent; m2->message = Message::SUBTITLE_CHANGE_CHANNEL; m2->parameter = (((AudioSubtitleChannel*)ssl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)ssl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } return; } diff --git a/vchannelselect.cc b/vchannelselect.cc index 0bba053..1fac3f0 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -56,7 +56,7 @@ void VChannelSelect::timercall(int clientReference) { Log::getInstance()->log("VChannelSelect", Log::DEBUG, "Timer call"); if (ignoreTimer) return; - changeChannel(false); + changeChannel(); } void VChannelSelect::doInput(int number) @@ -91,7 +91,7 @@ void VChannelSelect::draw() } } -void VChannelSelect::changeChannel(bool which) +void VChannelSelect::changeChannel() { ignoreTimer = true; Timers::getInstance()->cancelTimer(this, 1); @@ -115,10 +115,7 @@ void VChannelSelect::changeChannel(bool which) m->parameter += input[i] * (ULONG)pow(10., i); } - if (which) - MessageQueue::getInstance()->postMessageNoLock(m); - else - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } // Close me @@ -126,10 +123,7 @@ void VChannelSelect::changeChannel(bool which) m->from = this; m->to = BoxStack::getInstance(); m->message = Message::CLOSE_ME; - if (which) - MessageQueue::getInstance()->postMessageNoLock(m); - else - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } int VChannelSelect::handleCommand(int command) @@ -150,13 +144,13 @@ int VChannelSelect::handleCommand(int command) doInput(command); draw(); BoxStack::getInstance()->update(this); - if (numGot == numWidth) changeChannel(true); + if (numGot == numWidth) changeChannel(); else Timers::getInstance()->setTimerD(this, 1, 3); return 2; } case Remote::OK: { - changeChannel(true); + changeChannel(); return 2; } } diff --git a/vchannelselect.h b/vchannelselect.h index fbd8fbf..ab22182 100644 --- a/vchannelselect.h +++ b/vchannelselect.h @@ -45,7 +45,7 @@ class VChannelSelect : public Boxx, public TimerReceiver bool ignoreTimer; void doInput(int number); - void changeChannel(bool which); // true = in lock, false out lock + void changeChannel(); }; #endif diff --git a/vepg.cc b/vepg.cc index fb0b526..5354e73 100644 --- a/vepg.cc +++ b/vepg.cc @@ -453,7 +453,7 @@ int VEpg::handleCommand(int command) m->to = parent; m->message = Message::CHANNEL_CHANGE; m->parameter = (*chanList)[currentChannelIndex]->number; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } setCurrentChannel(); @@ -481,7 +481,7 @@ int VEpg::handleCommand(int command) m->to = parent; m->message = Message::CHANNEL_CHANGE; m->parameter = (*chanList)[currentChannelIndex]->number; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } setCurrentChannel(); @@ -502,7 +502,7 @@ int VEpg::handleCommand(int command) m->to = parent; m->message = Message::CHANNEL_CHANGE; m->parameter = (*chanList)[currentChannelIndex]->number; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } setCurrentChannel(); diff --git a/vepglistadvanced.cc b/vepglistadvanced.cc index 7df9c20..3b6f9f8 100644 --- a/vepglistadvanced.cc +++ b/vepglistadvanced.cc @@ -270,7 +270,7 @@ void VEpgListAdvanced::doSwitch() m->message = Message::CHANNEL_CHANGE; m->parameter = channelNumber; m->tag = 0; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } } diff --git a/vepgsettimer.cc b/vepgsettimer.cc index 8a34346..cc0ded6 100644 --- a/vepgsettimer.cc +++ b/vepgsettimer.cc @@ -280,7 +280,7 @@ void VEpgSetTimer::doit() m->message = Message::ADD_VIEW; m->to = boxstack; m->parameter = (ULONG)vi; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } void VEpgSetTimer::processMessage(Message* m) diff --git a/vmedialist.cc b/vmedialist.cc index 0f79239..e1001c4 100644 --- a/vmedialist.cc +++ b/vmedialist.cc @@ -1185,7 +1185,7 @@ int VMediaList::load() { m->message = Message::ADD_VIEW; m->to = boxstack; m->parameter = (ULONG)vi; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } return 1; } @@ -1204,7 +1204,7 @@ void VMediaList::timercall(int ref) { m->message = Message::PLAYER_EVENT; m->to = this; m->parameter = ref; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } } diff --git a/vmediaview.cc b/vmediaview.cc index d40f45d..6f3f955 100644 --- a/vmediaview.cc +++ b/vmediaview.cc @@ -222,7 +222,7 @@ class DrawingThread : public Thread_TYPE { m->to = _parent; m->from = _parent; m->parameter = rt?VMediaView::EVENT_DRAWINGDONE:VMediaView::EVENT_DRAWINGERROR; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } Log::getInstance()->log("DrawingThread",Log::DEBUG,"finishing interrupt=%d",(int)_interrupted); } @@ -1085,7 +1085,7 @@ void VMediaView::sendViewMsg(Boxx *v) { m->to = BoxStack::getInstance(); m->from = v; m->parameter=(ULONG)v; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } void VMediaView::sendCommandMsg(int command) { Message* m = new Message(); @@ -1094,7 +1094,7 @@ void VMediaView::sendCommandMsg(int command) { m->to = this; m->from = this; m->parameter = command; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } void VMediaView::enableBanner(bool enable) { diff --git a/vmute.cc b/vmute.cc index 2de57ab..a554b9a 100644 --- a/vmute.cc +++ b/vmute.cc @@ -73,7 +73,7 @@ void VMute::timercall(int clientReference) m->message = Message::CLOSE_ME; m->to = BoxStack::getInstance(); m->from = this; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } int VMute::handleCommand(int command) diff --git a/vopts.cc b/vopts.cc index 963ea58..1f3e4a3 100644 --- a/vopts.cc +++ b/vopts.cc @@ -366,7 +366,7 @@ void VOpts::doSave() Message* m = new Message(); m->message = Message::CHANGE_LANGUAGE; m->to = Command::getInstance(); - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); break; } case 3: diff --git a/vquestion.cc b/vquestion.cc index 2a41a4a..d51e0e5 100644 --- a/vquestion.cc +++ b/vquestion.cc @@ -109,7 +109,7 @@ int VQuestion::handleCommand(int command) m->from = this; m->to = replyTo; m->message = Message::QUESTION_YES; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); return 4; } diff --git a/vradiorec.cc b/vradiorec.cc index b031c86..232564c 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -159,7 +159,7 @@ void VRadioRec::go(bool resume) m->message = Message::CLOSE_ME; m->from = this; m->to = boxstack; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); VInfo* vi = new VInfo(); vi->setSize(400, 150); @@ -178,7 +178,7 @@ void VRadioRec::go(bool resume) m->message = Message::ADD_VIEW; m->to = boxstack; m->parameter = (ULONG)vi; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } } @@ -320,7 +320,7 @@ void VRadioRec::processMessage(Message* m) Message* m2 = new Message(); m2->to = Command::getInstance(); m2->message = Message::CONNECTION_LOST; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); break; } case Player::STOP_PLAYBACK: @@ -329,7 +329,7 @@ void VRadioRec::processMessage(Message* m) Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex m2->to = Command::getInstance(); m2->message = Message::STOP_PLAYBACK; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); break; } } diff --git a/vrecmove.cc b/vrecmove.cc index c899bd7..b84328c 100644 --- a/vrecmove.cc +++ b/vrecmove.cc @@ -131,7 +131,7 @@ int VRecMove::handleCommand(int command) m->message = Message::MOVE_RECORDING; m->to = parent; m->parameter = sl.getCurrentOptionData(); - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); return 4; } diff --git a/vrecording.cc b/vrecording.cc index 2cb7509..6666c7a 100644 --- a/vrecording.cc +++ b/vrecording.cc @@ -226,7 +226,7 @@ int VRecording::handleCommand(int command) m->from = this; m->to = vRecList; m->message = Message::PLAY_SELECTED_RECORDING; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); return 4; } @@ -236,7 +236,7 @@ int VRecording::handleCommand(int command) m->from = this; m->to = vRecList; m->message = Message::RESUME_SELECTED_RECORDING; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); return 4; } @@ -266,7 +266,7 @@ int VRecording::handleCommand(int command) m->message = Message::ADD_VIEW; m->to = BoxStack::getInstance(); m->parameter = (ULONG)vi; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); if (ret == 1) { @@ -282,7 +282,7 @@ int VRecording::handleCommand(int command) m2->from = this; m2->to = vRecList; m2->message = Message::REDRAW; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } return 2; @@ -446,13 +446,13 @@ void VRecording::processMessage(Message* m) m2->from = this; m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); m2 = new Message(); // OK. Want this to delete before this message does its job m2->from = this; m2->to = vRecList; m2->message = Message::DELETE_SELECTED_RECORDING; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } } else if (m->message == Message::MOVE_RECORDING) @@ -461,14 +461,14 @@ void VRecording::processMessage(Message* m) m2->from = this; m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); m2 = new Message(); m2->from = this; m2->to = vRecList; m2->message = Message::MOVE_RECORDING; m2->parameter = m->parameter; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } } diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 2db388b..49307d0 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -108,7 +108,7 @@ int VRecordingMenu::handleCommand(int command) m->from = this; m->to = vRecList; m->message = Message::PLAY_SELECTED_RECORDING; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); return 4; } @@ -118,7 +118,7 @@ int VRecordingMenu::handleCommand(int command) m->from = this; m->to = vRecList; m->message = Message::RESUME_SELECTED_RECORDING; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); return 4; } @@ -227,13 +227,13 @@ void VRecordingMenu::processMessage(Message* m) m2->from = this; m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); m2 = new Message(); // OK. Want this to delete before this message does its job m2->from = this; m2->to = vRecList; m2->message = Message::DELETE_SELECTED_RECORDING; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } } else if (m->message == Message::MOVE_RECORDING) @@ -242,13 +242,13 @@ void VRecordingMenu::processMessage(Message* m) m2->from = this; m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); m2 = new Message(); m2->from = this; m2->to = vRecList; m2->message = Message::MOVE_RECORDING; m2->parameter = m->parameter; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } } diff --git a/vserverselect.cc b/vserverselect.cc index 182e04f..bddee34 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -99,7 +99,7 @@ int VServerSelect::handleCommand(int command) m->to = replyTo; m->message = Message::SERVER_SELECTED; m->parameter = sl.getCurrentOption(); - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); return 4; } } diff --git a/vsleeptimer.cc b/vsleeptimer.cc index 0258e0b..e1f1814 100644 --- a/vsleeptimer.cc +++ b/vsleeptimer.cc @@ -162,7 +162,7 @@ void Sleeptimer::threadMethod() m1->message = Message::ADD_VIEW; m1->to = BoxStack::getInstance(); m1->parameter = (ULONG)count; - MessageQueue::getInstance()->postMessageNoLock(m1); + MessageQueue::getInstance()->postMessage(m1); } MILLISLEEP(1000); @@ -173,7 +173,7 @@ void Sleeptimer::threadMethod() m2->to = Command::getInstance(); m2->from = this; m2->parameter = 61; // FIXME use constant name when they're sorted out - MessageQueue::getInstance()->postMessageFromOuterSpace(m2); + MessageQueue::getInstance()->postMessage(m2); shutdown(); } } @@ -231,7 +231,7 @@ void VSleeptimer::timercall(int clientReference) m->message = Message::CLOSE_ME; m->to = BoxStack::getInstance(); m->from = this; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } int VSleeptimer::handleCommand(int command) @@ -298,5 +298,5 @@ void VCountdown::timercall(int clientReference) m->message = Message::CLOSE_ME; m->to = BoxStack::getInstance(); m->from = this; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } diff --git a/vtimeredit.cc b/vtimeredit.cc index 7031902..b8dd5f6 100644 --- a/vtimeredit.cc +++ b/vtimeredit.cc @@ -267,13 +267,13 @@ void VTimerEdit::processMessage(Message* m) m2->from = this; m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); m2 = new Message(); // OK. Want this to delete before this message does its job m2->from = this; m2->to = vTimerList; m2->message = Message::DELETE_SELECTED_TIMER; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); } } } diff --git a/vvideolivetv.cc b/vvideolivetv.cc index b8cab9d..8f05b06 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -874,7 +874,7 @@ void VVideoLiveTV::timercall(int ref) m->to = this; m->parameter = newChannel; m->tag = 1; // signal to call displayOSD(); - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Timer Call 1 key end."); } else diff --git a/vvideomedia.cc b/vvideomedia.cc index 04e17e7..c91cda0 100644 --- a/vvideomedia.cc +++ b/vvideomedia.cc @@ -175,7 +175,7 @@ void VVideoMedia::go(bool resume) m->message = Message::CLOSE_ME; m->from = this; m->to = boxstack; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); VInfo* vi = new VInfo(); vi->setSize(400, 150); @@ -194,7 +194,7 @@ void VVideoMedia::go(bool resume) m->message = Message::ADD_VIEW; m->to = boxstack; m->parameter = (ULONG)vi; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } } @@ -374,7 +374,7 @@ void VVideoMedia::processMessage(Message* m) Message* m2 = new Message(); m2->to = Command::getInstance(); m2->message = Message::CONNECTION_LOST; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); break; } case PlayerMedia::STREAM_END: @@ -382,7 +382,7 @@ void VVideoMedia::processMessage(Message* m) Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); break; } case PlayerMedia::STATUS_CHANGE: @@ -585,7 +585,7 @@ void VVideoMedia::timercall(int clientReference) m->to=this; m->from=this; m->parameter=PLAYER_TIMER_BASE+clientReference; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } void VVideoMedia::drawBarClocks() diff --git a/vvideorec.cc b/vvideorec.cc index 2a71f15..12650ab 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -196,7 +196,7 @@ void VVideoRec::go(bool resume) m->message = Message::CLOSE_ME; m->from = this; m->to = boxstack; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); VInfo* vi = new VInfo(); vi->setSize(360, 200); @@ -216,7 +216,7 @@ void VVideoRec::go(bool resume) m->message = Message::ADD_VIEW; m->to = boxstack; m->parameter = (ULONG)vi; - MessageQueue::getInstance()->postMessageNoLock(m); + MessageQueue::getInstance()->postMessage(m); } } @@ -530,7 +530,7 @@ void VVideoRec::processMessage(Message* m) Message* m2 = new Message(); m2->to = Command::getInstance(); m2->message = Message::CONNECTION_LOST; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); break; } case Player::STOP_PLAYBACK: @@ -539,7 +539,7 @@ void VVideoRec::processMessage(Message* m) Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex m2->to = Command::getInstance(); m2->message = Message::STOP_PLAYBACK; - MessageQueue::getInstance()->postMessageNoLock(m2); + MessageQueue::getInstance()->postMessage(m2); break; } case Player::ASPECT43: diff --git a/vvolume.cc b/vvolume.cc index 0cbb104..9c05d62 100644 --- a/vvolume.cc +++ b/vvolume.cc @@ -89,7 +89,7 @@ void VVolume::timercall(int clientReference) m->message = Message::CLOSE_ME; m->to = BoxStack::getInstance(); m->from = this; - MessageQueue::getInstance()->postMessageFromOuterSpace(m); + MessageQueue::getInstance()->postMessage(m); } int VVolume::handleCommand(int command) diff --git a/winmain.cc b/winmain.cc index 3dbc7fb..8f1ad64 100644 --- a/winmain.cc +++ b/winmain.cc @@ -688,8 +688,7 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam) mousemes->to=BoxStack::getInstance(); mousemes->parameter=(mpos.x & 0xFFFF)<< 16| (mpos.y & 0xFFFF); mousemes->tag=0; - //command->postMessageFromOuterSpace(mousemes); - messageQueue->postMessageIfNotBusy(mousemes); + messageQueue->postMessage(mousemes); } return 0; @@ -721,7 +720,7 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam) mousemes->to=BoxStack::getInstance(); mousemes->parameter=(mpos.x & 0xFFFF)<< 16| (mpos.y & 0xFFFF); mousemes->tag=0; - messageQueue->postMessageFromOuterSpace(mousemes); + messageQueue->postMessage(mousemes); } }break; case WM_MOUSEWHEEL:{ @@ -734,7 +733,7 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam) mousemes->to = BoxStack::getInstance(); mousemes->parameter = (0 & 0xFFFF) << 16 | (GET_WHEEL_DELTA_WPARAM(wparam) &0xFFFF); mousemes->tag = (mpos.x & 0xFFFF) << 16 | (mpos.y & 0xFFFF); - messageQueue->postMessageFromOuterSpace(mousemes); + messageQueue->postMessage(mousemes); } } break; diff --git a/wremoteconfig.cc b/wremoteconfig.cc index f934754..0d4497a 100644 --- a/wremoteconfig.cc +++ b/wremoteconfig.cc @@ -159,7 +159,7 @@ void WRemoteConfig::doSave() m->message = Message::CHANGED_REMOTECONTROL; m->to = parent; m->parameter = 0; - //Command::getInstance()->postMessageNoLock(m); + //Command::getInstance()->postMessage(m); } */ @@ -237,7 +237,7 @@ int WRemoteConfig::handleCommand(int command) m->message = Message::CLOSE_ME; m->from = this; m->to = viewman; - //Command::getInstance()->postMessageNoLock(m); + //Command::getInstance()->postMessage(m); return 2; */ } diff --git a/wwinaudiofilter.cc b/wwinaudiofilter.cc index 1552f31..19a2cd6 100644 --- a/wwinaudiofilter.cc +++ b/wwinaudiofilter.cc @@ -170,7 +170,7 @@ void WWinAudioFilter::doSave() m->message = Message::CHANGED_DEVICEOPTIONS; m->to = parent; m->parameter = 0; - //Command::getInstance()->postMessageNoLock(m); + //Command::getInstance()->postMessage(m); }*/ diff --git a/wwinmp3audiofilter.cc b/wwinmp3audiofilter.cc index 3cda108..50392c3 100644 --- a/wwinmp3audiofilter.cc +++ b/wwinmp3audiofilter.cc @@ -178,7 +178,7 @@ void WWinMp3AudioFilter::processMessage(Message* m) m->message = Message::CHANGED_DEVICEOPTIONS; m->to = parent; m->parameter = 0; - //Command::getInstance()->postMessageNoLock(m); + //Command::getInstance()->postMessage(m); }*/ diff --git a/wwinvideofilter.cc b/wwinvideofilter.cc index b6b16b0..b91f45b 100644 --- a/wwinvideofilter.cc +++ b/wwinvideofilter.cc @@ -170,7 +170,7 @@ void WWinVideoFilter::doSave() m->message = Message::CHANGED_DEVICEOPTIONS; m->to = parent; m->parameter = 0; - //Command::getInstance()->postMessageNoLock(m); + //Command::getInstance()->postMessage(m); }*/ diff --git a/wwinvideoh264filter.cc b/wwinvideoh264filter.cc index a18f9ad..7c6ec07 100644 --- a/wwinvideoh264filter.cc +++ b/wwinvideoh264filter.cc @@ -170,7 +170,7 @@ void WWinVideoH264Filter::doSave() m->message = Message::CHANGED_DEVICEOPTIONS; m->to = parent; m->parameter = 0; - //Command::getInstance()->postMessageNoLock(m); + //Command::getInstance()->postMessage(m); }*/ -- 2.39.5