From 937acde4c9a0a07383fddc938069e6c4e3bcd7bf Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 30 Mar 2008 15:45:07 +0000 Subject: [PATCH] Windows and endian updates --- eventdispatcher.cc | 26 +++++++++++++++++++++----- eventdispatcher.h | 4 ++-- vdr.cc | 7 ++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/eventdispatcher.cc b/eventdispatcher.cc index 8fbd8e6..b2aa5fd 100644 --- a/eventdispatcher.cc +++ b/eventdispatcher.cc @@ -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 +} diff --git a/eventdispatcher.h b/eventdispatcher.h index 677c1be..77212b4 100644 --- a/eventdispatcher.h +++ b/eventdispatcher.h @@ -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 537cc27..ae10df1 100644 --- 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); -- 2.39.5