From 51a517aa1e2416c55ad6f7df2dd44304d1fe74bf Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 1 Dec 2012 16:19:56 +0100 Subject: [PATCH] Windows compilation and other fixes --- boxstack.cc | 128 ++++++++----------------------------------------- boxstack.h | 9 ++-- defines.h | 2 + dvbsubtitles.h | 6 ++- osdwin.cc | 4 +- remote.cc | 3 ++ surface.cc | 8 ++-- surfacewin.cc | 3 +- surfacewin.h | 2 +- videowin.cc | 8 ++-- winmain.cc | 11 +++-- wselectlist.cc | 1 + 12 files changed, 55 insertions(+), 130 deletions(-) diff --git a/boxstack.cc b/boxstack.cc index 4c821d2..455439f 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -49,12 +49,6 @@ int BoxStack::init() if (initted) return 0; initted = 1; -#ifndef WIN32 - pthread_mutex_init(&boxLock, NULL); -#else - boxLock = CreateMutex(NULL,FALSE,NULL); -#endif - return 1; } @@ -73,30 +67,18 @@ int BoxStack::add(Boxx* v) { if (!initted) return 0; Log::getInstance()->log("BoxStack", Log::DEBUG, "add called"); -#ifndef WIN32 - pthread_mutex_lock(&boxLock); -#else - WaitForSingleObject(boxLock, INFINITE); -#endif + boxLock.Lock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Locked for add"); if (numBoxes == 16) { //Error Log::getInstance()->log("BoxStack", Log::ERR, "More than 16 boxes! Unlocked for add"); -#ifndef WIN32 - pthread_mutex_unlock(&boxLock); -#else - ReleaseMutex(boxLock); -#endif + boxLock.Unlock(); return 0; } boxes[numBoxes++] = v; -#ifndef WIN32 - pthread_mutex_unlock(&boxLock); -#else - ReleaseMutex(boxLock); -#endif + boxLock.Unlock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for add"); @@ -109,20 +91,12 @@ int BoxStack::remove(Boxx* toDelete) { if (!initted) return 0; - #ifndef WIN32 - pthread_mutex_lock(&boxLock); - #else - WaitForSingleObject(boxLock, INFINITE); - #endif + boxLock.Lock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Locked for remove"); if (numBoxes == 0) { - #ifndef WIN32 - pthread_mutex_unlock(&boxLock); - #else - ReleaseMutex(boxLock); - #endif + boxLock.Unlock(); Log::getInstance()->log("BoxStack", Log::ERR, "Unlocked for remove numBoxes == 0"); return 0; } @@ -149,29 +123,17 @@ int BoxStack::remove(Boxx* toDelete) { // not a Box we have! // FIXME - #ifndef WIN32 - pthread_mutex_unlock(&boxLock); - #else - ReleaseMutex(boxLock); - #endif + boxLock.Unlock(); Log::getInstance()->log("BoxStack", Log::ERR, "Unlocked for remove - no boxx deleted"); return 0; } } -#ifndef WIN32 - pthread_mutex_unlock(&boxLock); -#else - ReleaseMutex(boxLock); -#endif + boxLock.Unlock(); toDelete->preDelete(); -#ifndef WIN32 - pthread_mutex_lock(&boxLock); -#else - WaitForSingleObject(boxLock, INFINITE); -#endif + boxLock.Lock(); // Log::getInstance()->log("BoxStack", Log::DEBUG, "Starting deleteBox"); deleteBox(i); @@ -190,11 +152,7 @@ toDelete->preDelete(); Command::getInstance()->postMessageNoLock(m); } -#ifndef WIN32 - pthread_mutex_unlock(&boxLock); -#else - ReleaseMutex(boxLock); -#endif + boxLock.Unlock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for remove"); // Delete the box @@ -224,11 +182,7 @@ void BoxStack::deleteBox(int z) void BoxStack::redrawAllBoxes() { -#ifndef WIN32 - pthread_mutex_lock(&boxLock); -#else - WaitForSingleObject(boxLock, INFINITE); -#endif + boxLock.Lock(); for (int z = 0; z < numBoxes; z++) { @@ -236,23 +190,15 @@ void BoxStack::redrawAllBoxes() } -#ifndef WIN32 - pthread_mutex_unlock(&boxLock); -#else - ReleaseMutex(boxLock); -#endif - update(NULL,NULL); // should blt all + boxLock.Unlock(); + update(NULL,NULL); // should blt all } void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) { Log::getInstance()->log("BoxStack", Log::DEBUG, "Update called"); if (!initted) return; // it is allowed to call this before init -#ifndef WIN32 - pthread_mutex_lock(&boxLock); -#else - WaitForSingleObject(boxLock, INFINITE); -#endif + boxLock.Lock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Locked for update"); // Get the z index of the box @@ -267,11 +213,7 @@ void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) if (z == numBoxes) { // not a Box we have! - #ifndef WIN32 - pthread_mutex_unlock(&boxLock); - #else - ReleaseMutex(boxLock); - #endif + boxLock.Unlock(); Log::getInstance()->log("BoxStack", Log::ERR, "Unlocked for update! box not inside boxstack"); return; } @@ -282,11 +224,7 @@ void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) } if (!toUpdate) { -#ifndef WIN32 - pthread_mutex_unlock(&boxLock); -#else - ReleaseMutex(boxLock); -#endif + boxLock.Unlock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for update, no box present"); return ; } @@ -319,11 +257,7 @@ void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) rl.pop_front(); } -#ifndef WIN32 - pthread_mutex_unlock(&boxLock); -#else - ReleaseMutex(boxLock); -#endif + boxLock.Unlock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for update"); } @@ -500,37 +434,21 @@ void BoxStack::removeAll() while(numBoxes > 1) { - #ifndef WIN32 - pthread_mutex_lock(&boxLock); - #else - WaitForSingleObject(boxLock, INFINITE); - #endif + boxLock.Lock(); if (numBoxes == 1) { - #ifndef WIN32 - pthread_mutex_unlock(&boxLock); - #else - ReleaseMutex(boxLock); - #endif + boxLock.Unlock(); break; } toDel = boxes[numBoxes - 1]; - #ifndef WIN32 - pthread_mutex_unlock(&boxLock); - #else - ReleaseMutex(boxLock); - #endif + boxLock.Unlock(); toDel->preDelete(); - #ifndef WIN32 - pthread_mutex_lock(&boxLock); - #else - WaitForSingleObject(boxLock, INFINITE); - #endif + boxLock.Lock(); // If boxes[numBoxes - 1] isn't toDel then there's a problem if (boxes[numBoxes - 1] == toDel) @@ -543,11 +461,7 @@ void BoxStack::removeAll() toDel = NULL; } - #ifndef WIN32 - pthread_mutex_unlock(&boxLock); - #else - ReleaseMutex(boxLock); - #endif + boxLock.Unlock(); //AVO: do the delete outside the lock to allow for recursive deletes Log::getInstance()->log("BoxStack", Log::DEBUG, "going to delete boxx %p, num=%d", toDel, numBoxes); diff --git a/boxstack.h b/boxstack.h index 1e0d638..b0b7156 100644 --- a/boxstack.h +++ b/boxstack.h @@ -30,6 +30,8 @@ #include #endif +#include "mutex.h" + #include "boxx.h" #include "region.h" #include "message.h" @@ -69,11 +71,8 @@ class BoxStack Boxx* boxes[20]; int numBoxes; -#ifndef WIN32 - pthread_mutex_t boxLock; -#else - HANDLE boxLock; -#endif + Mutex boxLock; + void deleteBox(int z); void repaintRevealed(int x, Region r); diff --git a/defines.h b/defines.h index 4ed4f15..7578553 100644 --- a/defines.h +++ b/defines.h @@ -43,6 +43,8 @@ long long getTimeMS(); #define Thread_TYPE ThreadWin #define ThreadID_TYPE unsigned int + #define RemoteStartDev ""//No devices passed + #define SNPRINTF _snprintf #define VSNPRINTF _vsnprintf #define STRCASECMP _stricmp diff --git a/dvbsubtitles.h b/dvbsubtitles.h index d08f3c3..7258c18 100644 --- a/dvbsubtitles.h +++ b/dvbsubtitles.h @@ -25,7 +25,11 @@ #include "bitmap.h" #include "demuxer.h" -#include "inttypes.h" +#ifndef WIN32 +#include +#else +typedef unsigned long long uint64_t; +#endif #include #include #include diff --git a/osdwin.cc b/osdwin.cc index c55bb11..4c70e09 100644 --- a/osdwin.cc +++ b/osdwin.cc @@ -28,8 +28,8 @@ #include "message.h" #include "command.h" -#define BACKBUFFER_WIDTH 1280 -#define BACKBUFFER_HEIGHT 720 +#define BACKBUFFER_WIDTH 1920 +#define BACKBUFFER_HEIGHT 1080 diff --git a/remote.cc b/remote.cc index a17e6ee..d0bf896 100644 --- a/remote.cc +++ b/remote.cc @@ -27,6 +27,7 @@ Remote* Remote::instance = NULL; +#ifndef _MSC_VER const ULONG Remote::NOLEARNMODE; // Not buttons @@ -101,6 +102,8 @@ const UCHAR Remote::PLAYPAUSE; const UCHAR Remote::OLDREMOTE; const UCHAR Remote::NEWREMOTE; +#endif + Remote::Remote() { if (instance) return; diff --git a/surface.cc b/surface.cc index 1ae5411..ba8f747 100644 --- a/surface.cc +++ b/surface.cc @@ -53,14 +53,14 @@ void initpol_tables(){ float fposy=((float)(ttcharsizey))/((float)(charsizey))*((float)py); float yweight=fposy-floor(fposy); float yinvweight=1.-yweight; - interpol_upline[py]=min((unsigned int)ceil(fposy),9); - interpol_lowline[py]=max((unsigned int)floor(fposy),0); + interpol_upline[py]=min((int)(ceil(fposy)),9); + interpol_lowline[py]=max((int)(floor(fposy)),0); for (int px=0;px SurfaceWin::SurfaceWin(int id) : Surface(id) @@ -236,7 +237,7 @@ void SurfaceWin::drawVertLine(int x, int y1, int y2, const DrawStyle& c) fillblt(x, y1, 1, y2-y1, c); } -void SurfaceWin::drawBitmap(int x, int y, const Bitmap& bm) +void SurfaceWin::drawBitmap(int x, int y, const Bitmap& bm,const DisplayRegion & region) { // Temporary code? Draw one pixel at a time using drawPixel() startFastDraw(); diff --git a/surfacewin.h b/surfacewin.h index 093b28e..5be38cf 100644 --- a/surfacewin.h +++ b/surfacewin.h @@ -41,7 +41,7 @@ class SurfaceWin : public Surface int fillblt(int x, int y, int width, int height, const DrawStyle& c); void drawHorzLine(int x1, int x2, int y, const DrawStyle& c); void drawVertLine(int x, int y1, int y2, const DrawStyle& c); - void drawBitmap(int x, int y, const Bitmap& bm); + void drawBitmap(int x, int y, const Bitmap& bm,const DisplayRegion & region); int updateToScreen(int sx, int sy, int w, int h, int dx, int dy); void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b); void screenShot(const char* fileName); diff --git a/videowin.cc b/videowin.cc index 06983da..dcde4aa 100644 --- a/videowin.cc +++ b/videowin.cc @@ -1942,10 +1942,10 @@ bool VideoWin::displayIFrame(const UCHAR* buffer, UINT length) IMediaSample* ms=NULL; REFERENCE_TIME reftime1=0; REFERENCE_TIME reftime2=0; - if (!videoon) return; + if (!videoon) return false; if (!getCurrentVideoMediaSample(&ms) || ms==NULL) {// get the current sample MILLISLEEP(10); - return ; + return false; } BYTE *ms_buf; DWORD ms_length; @@ -1957,7 +1957,7 @@ bool VideoWin::displayIFrame(const UCHAR* buffer, UINT length) DWORD pattern, packet_length; DWORD headerstrip=0; bool first=true; - if (length < 4) return ; + if (length < 4) return false; //Now we strip the pes header pattern = (buffer[0] << 16) | (buffer[1] << 8) | (buffer[2]); while (read_pos + 7 <= length) @@ -1989,7 +1989,7 @@ bool VideoWin::displayIFrame(const UCHAR* buffer, UINT length) if (!getCurrentVideoMediaSample(&ms) || ms==NULL) {// get the current sample MILLISLEEP(10); - return ; + return false; } write_pos=0; ms_length=ms->GetSize(); diff --git a/winmain.cc b/winmain.cc index 9b261f0..d120f8a 100644 --- a/winmain.cc +++ b/winmain.cc @@ -901,15 +901,16 @@ void shutdown(int code) // ------------------------------------------------------------------------------------------------------------------- -ULLONG ntohll(ULLONG a) -{ - return htonll(a); -} - ULLONG htonll(ULLONG a) { return (((ULLONG)htonl((ULONG)((a<<32)>> 32))<<32) |(ULONG)htonl(((ULONG) (a >> 32)))); } + +ULLONG ntohll(ULLONG a) +{ + return htonll(a); +} + #endif diff --git a/wselectlist.cc b/wselectlist.cc index 3c9b0a0..1c5e2d7 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -249,6 +249,7 @@ bool WSelectList::mouseAndroidScroll(int x, int y,int sx, int sy) if (seloption<0) seloption=0; else if (seloption>options.size()-1) seloption=options.size()-1; selectedOption=seloption;*/ + return false; } -- 2.39.5