]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Windows and endian updates
authorChris Tallon <chris@vomp.tv>
Sun, 30 Mar 2008 15:45:07 +0000 (15:45 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 30 Mar 2008 15:45:07 +0000 (15:45 +0000)
eventdispatcher.cc
eventdispatcher.h
vdr.cc

index 8fbd8e6eb1057ae89b4132a12d01ca512d92f1ae..b2aa5fdb284a8c60ca22de0dbf39f01e98f25263 100644 (file)
@@ -71,7 +71,7 @@ bool EventDispatcher::edFindAndCall(void* userTag)
       #ifndef WIN32
       pthread_cond_signal(&edr->cond);
       #else
-      // FIXME
+      SetEvent(edr->cond);
       #endif
     }
   }
@@ -90,7 +90,7 @@ bool EventDispatcher::edFindAndCall(void* userTag)
     #ifndef WIN32
     pthread_cond_signal(&edr->cond);
     #else
-    // FIXME
+    SetEvent(edr->cond);
     #endif
   }
   
@@ -123,7 +123,11 @@ void EventDispatcher::edUnregister(EDReceiver* edr)
 #ifndef WIN32
   pthread_cond_wait(&edr->cond, &mutex);
 #else
-  // FIXME
+  ReleaseMutex(mutex);
+  WaitForSingleObject(edr->cond,INFINITE);
+  WaitForSingleObject(mutex, INFINITE);
+  ResetEvent(edr->cond);
+
 #endif
 
   for(i = receivers.begin(); i != receivers.end(); i++)
@@ -167,7 +171,11 @@ void EventDispatcher::edSleepThisReceiver(EDReceiver* edr)
   pthread_cond_init(&edr->cond, NULL);
   pthread_cond_wait(&edr->cond, &mutex);
 #else
-  // FIXME
+   edr->cond = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL);
+   ReleaseMutex(mutex);
+   WaitForSingleObject(edr->cond,INFINITE);
+   ResetEvent(edr->cond);
+   WaitForSingleObject(mutex, INFINITE);
 #endif
 }
 
@@ -177,6 +185,14 @@ EDReceiver::EDReceiver()
 {
   nomorecalls = false;
   callinprogress = false;
+#ifdef WIN32
+  cond=NULL;
+#endif
 }
 
-
+EDReceiver::~EDReceiver()
+{
+#ifdef WIN32
+  if (cond!=NULL) CloseHandle(cond);
+#endif
+}
index 677c1be6c1107ac77c4a5790c5fc4e1e17798435..77212b439f40930b9cae364a21362ca38d9bc031 100644 (file)
@@ -41,7 +41,7 @@ class EDReceiver //(implementation in eventdispatcher.cc)
 
   public:
     EDReceiver();
-    virtual ~EDReceiver() {};
+    virtual ~EDReceiver();
 
   protected:
     virtual bool call(void* userTag)=0; // Implementor must override this and do the actual call
@@ -52,7 +52,7 @@ class EDReceiver //(implementation in eventdispatcher.cc)
 #ifndef WIN32    
     pthread_cond_t cond;
 #else
-    // FIXME
+    HANDLE cond;
 #endif
 };
 
diff --git a/vdr.cc b/vdr.cc
index 537cc27fdfdf705281c95abc52af46fa33031c43..ae10df105a51b11967e3b6d79750a93ef34e022b 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -208,13 +208,16 @@ void VDR::threadMethod()
       
       continue;      
     }
-    
+    channelID = ntohl(channelID);
+
     vresp = new VDR_ResponsePacket();  
     
     if (channelID == CHANNEL_REQUEST_RESPONSE)
     {
       if (!tcp->readData((UCHAR*)&requestID, sizeof(ULONG))) break;
+      requestID = ntohl(requestID);
       if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break;
+      userDataLength = ntohl(userDataLength);
       if (userDataLength > 5000000) break; // how big can these packets get?
       if (userDataLength > 0)
       {
@@ -232,7 +235,9 @@ void VDR::threadMethod()
     else if (channelID == CHANNEL_STREAM)
     {
       if (!tcp->readData((UCHAR*)&streamID, sizeof(ULONG))) break;
+      streamID = ntohl(streamID);
       if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break; 
+      userDataLength = ntohl(userDataLength);
       if (userDataLength > 0)
       {
         userData = (UCHAR*)malloc(userDataLength);