From 18ac0390e294f25324bf0e050ccb600c59946cdc Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 30 Mar 2008 15:56:26 +0000 Subject: [PATCH] Windows updates --- osdwin.cc | 9 ++++++++- threadwin.cc | 11 +++++++++-- threadwin.h | 2 +- ticonfig.c | 4 ++-- udp.cc | 6 ------ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/osdwin.cc b/osdwin.cc index 767b023..859ac90 100644 --- a/osdwin.cc +++ b/osdwin.cc @@ -184,7 +184,13 @@ void OsdWin::Render() { if (!initted) return ; if (external_driving) { - Sleep(5); //Sleep for 5 ms, in order to avoid blocking the other threads + DWORD time1=timeGetTime(); //Updates the Menue + if ((time1-lastrendertime)>200) {//5 fps for OSD updates are enough, avoids tearing + InternalRendering(NULL); + lastrendertime=timeGetTime(); + } else { + Sleep(5); //Sleep for 5 ms, in order to avoid blocking the other threads + } } else { DWORD time1=timeGetTime(); if ((time1-lastrendertime)>50) {//10 fps for OSD updates are enough, avoids tearing @@ -202,6 +208,7 @@ void OsdWin::RenderDS(LPDIRECT3DSURFACE9 present){ if (!initted) return; if (external_driving) { InternalRendering(present); + lastrendertime=timeGetTime(); } } diff --git a/threadwin.cc b/threadwin.cc index 0d85a89..994f6dc 100644 --- a/threadwin.cc +++ b/threadwin.cc @@ -25,6 +25,7 @@ ThreadWin::~ThreadWin() CloseHandle(pthread); CloseHandle(threadCond); CloseHandle(threadCondMutex); + CloseHandle(threadKillable); } @@ -40,6 +41,8 @@ int ThreadWin::threadStart() { threadCond = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL); if (threadCond == NULL) return 0; + threadKillable = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL); + if (threadKillable == NULL) return 0; threadCondMutex = CreateMutex(NULL,FALSE,NULL); if (threadCondMutex == NULL) { @@ -54,6 +57,7 @@ int ThreadWin::threadStart() { CloseHandle(threadCond); CloseHandle(threadCondMutex); + CloseHandle(threadKillable); return 0; } return 1; @@ -71,9 +75,11 @@ void ThreadWin::threadStop() void ThreadWin::threadCancel() { threadActive = 0; - //TerminateThread(pthread, 0); threadSignalNoLock(); - WaitForSingleObject(pthread, INFINITE); + HANDLE objs[]={threadKillable,pthread}; + if (WaitForMultipleObjects(2,objs,FALSE,INFINITE)==WAIT_OBJECT_0) { + TerminateThread(pthread, 0); + } this->threadPostStopCleanup(); } @@ -136,6 +142,7 @@ void ThreadWin::threadWaitForSignalTimed(struct timespec* ts) void ThreadWin::threadSetKillable() { //WIN32:Ignore or use a separate Event Object to simulate this + SetEvent(threadKillable); } void ThreadWin::threadSuicide() diff --git a/threadwin.h b/threadwin.h index def4b4f..d78350a 100644 --- a/threadwin.h +++ b/threadwin.h @@ -65,6 +65,7 @@ class ThreadWin : public Thread HANDLE pthread; HANDLE threadCondMutex; HANDLE threadCond; + HANDLE threadKillable; DWORD threadId; public: @@ -74,4 +75,3 @@ class ThreadWin : public Thread }; #endif - diff --git a/ticonfig.c b/ticonfig.c index deb8296..18c82b3 100644 --- a/ticonfig.c +++ b/ticonfig.c @@ -16,8 +16,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ #include #include diff --git a/udp.cc b/udp.cc index 49acf9c..086e4ab 100755 --- a/udp.cc +++ b/udp.cc @@ -84,13 +84,7 @@ void UDP::threadMethod() int retval; while(1) { - #ifndef WIN32 retval = ds->waitforMessage(0); - #else - log->log("UDP", Log::DEBUG, "Wait for packet"); - threadCheckExit(); - retval = ds->waitforMessage(1); - #endif if (retval == 0) { -- 2.39.2