From 9bec26ad34da96364d661cf9d27c8588bacb8bae Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 5 Apr 2006 16:59:04 +0000 Subject: [PATCH] Portability --- command.cc | 66 ++++++++++++++++++++++++++++++++++++++--------- command.h | 11 ++++++++ demuxer.cc | 49 +++++++++++++++++++---------------- fonts/helvB18.cc | Bin 257328 -> 257515 bytes fonts/helvB24.cc | Bin 298703 -> 298770 bytes 5 files changed, 92 insertions(+), 34 deletions(-) diff --git a/command.cc b/command.cc index 3f55d2a..023debc 100644 --- a/command.cc +++ b/command.cc @@ -56,8 +56,11 @@ int Command::init() initted = 0; return 0; } - +#ifndef WIN32 pthread_mutex_init(&masterLock, NULL); +#else + masterLock=CreateMutex(NULL,FALSE,NULL); +#endif return 1; } @@ -109,8 +112,9 @@ void Command::run() { if (!initted) return; irun = 1; - +#ifndef WIN32 mainPid = getpid(); +#endif // just in case Video::getInstance()->signalOn(); @@ -119,10 +123,11 @@ 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 VConnect* vconnect = new VConnect(); viewman->add(vconnect); vconnect->run(); @@ -132,12 +137,20 @@ void Command::run() while(irun) { // unlock and wait +#ifndef WIN32 pthread_mutex_unlock(&masterLock); +#else + ReleaseMutex(masterLock); +#endif button = remote->getButtonPress(2); // FIXME why is this set to 2 and not 0? so it can quit // something happened, lock and process - pthread_mutex_lock(&masterLock); +#ifndef WIN32 + pthread_mutex_lock(&masterLock); +#else + WaitForSingleObject(masterLock, INFINITE ); +#endif if ((button == Remote::NA_NONE) || (button == Remote::NA_UNKNOWN)) continue; @@ -145,7 +158,11 @@ void Command::run() processMessageQueue(); } - pthread_mutex_unlock(&masterLock); +#ifndef WIN32 + pthread_mutex_unlock(&masterLock); +#else + ReleaseMutex(masterLock); +#endif } void Command::postMessage(Message* m) @@ -156,10 +173,20 @@ void Command::postMessage(Message* m) // locking the mutex ensures that the master thread is waiting on getButtonPress - pthread_mutex_lock(&masterLock); - MessageQueue::postMessage(m); - kill(mainPid, SIGURG); - pthread_mutex_unlock(&masterLock); +#ifndef WIN32 + pthread_mutex_lock(&masterLock); +#else + WaitForSingleObject(masterLock, INFINITE ); +#endif + MessageQueue::postMessage(m); + +#ifndef WIN32 + kill(mainPid, SIGURG); + pthread_mutex_unlock(&masterLock); +#else + //TODO: send Window Message + ReleaseMutex(masterLock); +#endif } void Command::postMessageNoLock(Message* m) @@ -175,7 +202,7 @@ bool Command::postMessageIfNotBusy(Message* m) // This is for the timers module // If the masterlock is locked then the timers module wants to // cancel delivery - +#ifndef WIN32 if (pthread_mutex_trylock(&masterLock) != EBUSY) { MessageQueue::postMessage(m); @@ -187,6 +214,19 @@ bool Command::postMessageIfNotBusy(Message* m) { return false; } +#else + if (WaitForSingleObject(masterLock, INFINITE ) == WAIT_OBJECT_0) + { + MessageQueue::postMessage(m); + //TODO: send Window Message + ReleaseMutex(masterLock); + return true; + } + else + { + return false; + } +#endif } void Command::processMessage(Message* m) @@ -356,7 +396,9 @@ void Command::doReboot() VDR::getInstance()->disconnect(); // just kill it... logger->log("Command", Log::NOTICE, "Reboot"); +#ifndef WIN32 reboot(LINUX_REBOOT_CMD_RESTART); +#endif //Would we support this on windows? } void Command::connectionLost() diff --git a/command.h b/command.h index 2760f74..6b35c3b 100644 --- a/command.h +++ b/command.h @@ -21,12 +21,18 @@ #ifndef COMMAND_H #define COMMAND_H +#ifndef WIN32 #include // for reboot #include #include +#endif #include +#ifndef WIN32 #include +#else + +#endif #include #include "defines.h" @@ -81,8 +87,13 @@ class Command : public MessageQueue void doFromTheTop(bool which); // true - show vinfo,wait. false - del vinfo,restart static Command* instance; +#ifndef WIN32 pid_t mainPid; pthread_mutex_t masterLock; +#else + HANDLE masterLock; + HANDLE mainPid; //Window +#endif UCHAR initted; UCHAR irun; UCHAR isStandby; diff --git a/demuxer.cc b/demuxer.cc index be11edb..f9c22f9 100644 --- a/demuxer.cc +++ b/demuxer.cc @@ -175,21 +175,24 @@ int Demuxer::put(UCHAR* buf, int len) while (len) { full = 0; - switch (state_frametype) + + if (state_frametype == 0) // Search for frame { - case 0: // Search for frame - parsed = parse_find_frame(len); - break; - case FRAMETYPE_VID0 ... FRAMETYPE_VIDMAX: - parsed = parse_video_frame(len, &full); - break; - case FRAMETYPE_AUD0 ... FRAMETYPE_AUDMAX: - parsed = parse_audio_frame(len, &full); - break; - case FRAMETYPE_PRIVATE_1: - parsed = parse_private1_frame(len, &full); - break; + parsed = parse_find_frame(len); + } + else if ((state_frametype >= FRAMETYPE_VID0) && (state_frametype <= FRAMETYPE_VIDMAX)) + { + parsed = parse_video_frame(len, &full); + } + else if ((state_frametype >= FRAMETYPE_AUD0) && (state_frametype <= FRAMETYPE_AUDMAX)) + { + parsed = parse_audio_frame(len, &full); } + else if (state_frametype == FRAMETYPE_PRIVATE_1) + { + parsed = parse_private1_frame(len, &full); + } + ret += parsed; len -= parsed; if (full) // We have to exit early. break; // out of while loop @@ -232,17 +235,19 @@ int Demuxer::parse_find_frame(int len) break; default: state_framepos = 0; // Set initial state for the new frame - switch (byte) + + if (byte == 0) + { + state_framepos = 1; // Count this as a first header byte! + } + else if ( ((byte >= FRAMETYPE_VID0) && (byte <= FRAMETYPE_VIDMAX)) + || ((byte >= FRAMETYPE_AUD0) && (byte <= FRAMETYPE_AUDMAX)) + || byte==FRAMETYPE_PRIVATE_1 ) { - case 0: - state_framepos = 1; // Count this as a first header byte! - break; - case FRAMETYPE_VID0 ... FRAMETYPE_VIDMAX: - case FRAMETYPE_AUD0 ... FRAMETYPE_AUDMAX: - case FRAMETYPE_PRIVATE_1: - state_frametype = byte; - return ret; + state_frametype = byte; + return ret; } + // Not a recognised frame type. Go back to Old Kent Road. break; } diff --git a/fonts/helvB18.cc b/fonts/helvB18.cc index f9b668442cebaf4cade692d45a69a05e8f2869a5..5b82fa7ca98a99c0086d26389d3cfc743294df57 100644 GIT binary patch delta 6391 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