]> git.vomp.tv Git - vompclient.git/commitdiff
Portability
authorChris Tallon <chris@vomp.tv>
Wed, 5 Apr 2006 16:59:04 +0000 (16:59 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 5 Apr 2006 16:59:04 +0000 (16:59 +0000)
command.cc
command.h
demuxer.cc
fonts/helvB18.cc
fonts/helvB24.cc

index 3f55d2aa5237b927cf4e305a9094bc1d3407f443..023debc4597bcb1f2b91e4c7d9818ae9d5d0f123 100644 (file)
@@ -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()
index 2760f744bf20b3c7017433a2bec12145bf5c5335..6b35c3b3e13b1b7d73dfb3038aae79e3f624330b 100644 (file)
--- a/command.h
+++ b/command.h
 #ifndef COMMAND_H
 #define COMMAND_H
 
+#ifndef WIN32
 #include <unistd.h> // for reboot
 #include <linux/reboot.h>
 #include <sys/reboot.h>
+#endif
 
 #include <time.h>
+#ifndef WIN32
 #include <pthread.h>
+#else
+
+#endif
 #include <signal.h>
 
 #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;
index be11edb7536f043b7806c088218f4c2939a1ed0a..f9c22f9345c0cb92b8aceb2a0676d16b9139538d 100644 (file)
@@ -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;
     }
index f9b668442cebaf4cade692d45a69a05e8f2869a5..5b82fa7ca98a99c0086d26389d3cfc743294df57 100644 (file)
Binary files a/fonts/helvB18.cc and b/fonts/helvB18.cc differ
index 047b58594fcc3d880ee582ce0febcf54c1d1d2bd..0a3162598dc4d9f567834c94328e6c7737586ae1 100644 (file)
Binary files a/fonts/helvB24.cc and b/fonts/helvB24.cc differ