From: Chris Tallon Date: Wed, 5 Apr 2006 16:59:04 +0000 (+0000) Subject: Portability X-Git-Url: https://git.vomp.tv/gitweb/?a=commitdiff_plain;h=9bec26ad34da96364d661cf9d27c8588bacb8bae;p=vompclient-marten.git Portability --- 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 f9b6684..5b82fa7 100644 Binary files a/fonts/helvB18.cc and b/fonts/helvB18.cc differ diff --git a/fonts/helvB24.cc b/fonts/helvB24.cc index 047b585..0a31625 100644 Binary files a/fonts/helvB24.cc and b/fonts/helvB24.cc differ