All pastes #1570388 Raw Edit

Unnamed

public diff v1 · immutable
#1570388 ·published 2009-09-18 02:41 UTC
rendered paste body
Index: guilib/GUIWindowManager.cpp===================================================================--- guilib/GUIWindowManager.cpp	(revision 22954)+++ guilib/GUIWindowManager.cpp	(working copy)@@ -311,7 +311,7 @@  void CGUIWindowManager::ActivateWindow(int iWindowID, const CStdString& strPath, bool swappingWindows) {-  if (GetCurrentThreadId() != g_application.GetThreadId())+  if (CThread::GetThisThreadID() != g_application.GetThreadId())   {     // make sure graphics lock is not held     int nCount = ExitCriticalSection(g_graphicsContext);@@ -464,7 +464,7 @@  void CGUIWindowManager::Render() {-  if (GetCurrentThreadId() != g_application.GetThreadId())+  if (CThread::GetThisThreadID() != g_application.GetThreadId())   {     // make sure graphics lock is not held     int nCount = ExitCriticalSection(g_graphicsContext);@@ -532,7 +532,7 @@  void CGUIWindowManager::Process(bool renderOnly /*= false*/) {-  if (GetCurrentThreadId() != g_application.GetThreadId())+  if (CThread::GetThisThreadID() != g_application.GetThreadId())   {     // make sure graphics lock is not held     DWORD locks = ExitCriticalSection(g_graphicsContext);Index: xbmc/utils/log.cpp===================================================================--- xbmc/utils/log.cpp	(revision 22954)+++ xbmc/utils/log.cpp	(working copy)@@ -30,6 +30,7 @@ #include "StdString.h" #include "Settings.h" #include "AdvancedSettings.h"+#include "Thread.h"  XFILE::CFile* CLog::m_file = NULL; @@ -99,11 +100,7 @@      CStdString strPrefix, strData; -#ifdef __APPLE__-    strPrefix.Format("%02.2d:%02.2d:%02.2d T:%lu M:%9ju %7s: ", time.wHour, time.wMinute, time.wSecond, GetCurrentThreadId(), stat.dwAvailPhys, levelNames[loglevel]);-#else-    strPrefix.Format("%02.2d:%02.2d:%02.2d T:%lu M:%9u %7s: ", time.wHour, time.wMinute, time.wSecond, GetCurrentThreadId(), stat.dwAvailPhys, levelNames[loglevel]);-#endif+    strPrefix.Format("%02.2d:%02.2d:%02.2d T:%"PRIu64" M:%9"PRIu64" %7s: ", time.wHour, time.wMinute, time.wSecond, (uint64_t)CThread::GetThisThreadID(), (uint64_t)stat.dwAvailPhys, levelNames[loglevel]);      strData.reserve(16384);     va_list va;Index: xbmc/utils/Thread.h===================================================================--- xbmc/utils/Thread.h	(revision 22954)+++ xbmc/utils/Thread.h	(working copy)@@ -69,10 +69,8 @@   operator HANDLE() const;   bool IsAutoDelete() const;   virtual void StopThread();--  // returns the relative cpu usage of this thread since last call-  float GetRelativeUsage();-+  float GetRelativeUsage();  // returns the relative cpu usage of this thread since last call+  static uintptr_t GetThisThreadID(); protected:   virtual void OnStartup(){};   virtual void OnExit(){};Index: xbmc/utils/Thread.cpp===================================================================--- xbmc/utils/Thread.cpp	(revision 22954)+++ xbmc/utils/Thread.cpp	(working copy)@@ -242,12 +242,12 @@    if ( pThread->IsAutoDelete() )   {-    CLog::Log(LOGDEBUG,"Thread %u terminating (autodelete)", GetCurrentThreadId());+    CLog::Log(LOGDEBUG,"Thread %"PRIu64" terminating (autodelete)", CThread::GetThisThreadID());     delete pThread;     pThread = NULL;   }   else-    CLog::Log(LOGDEBUG,"Thread %u terminating", GetCurrentThreadId());  +    CLog::Log(LOGDEBUG,"Thread %"PRIu64" terminating", CThread::GetThisThreadID());    // DXMERGE - this looks like it might have used to have been useful for something... //  g_graphicsContext.DeleteThreadContext();@@ -422,9 +422,18 @@   return 0.0f; } +uintptr_t CThread::GetThisThreadID()+{+#ifdef _LINUX+  return pthread_self();+#else+  return GetCurrentThreadId();+#endif+}+ DWORD CThread::WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) {-  if(dwMilliseconds > 10 && GetCurrentThreadId() == m_ThreadId)+  if(dwMilliseconds > 10 && CThread::GetThisThreadID() == m_ThreadId)   {     HANDLE handles[2] = {hHandle, m_StopEvent};     DWORD result = ::WaitForMultipleObjects(2, handles, false, dwMilliseconds);@@ -449,7 +458,7 @@  void CThread::Sleep(DWORD dwMilliseconds) {-  if(dwMilliseconds > 10 && GetCurrentThreadId() == m_ThreadId)+  if(dwMilliseconds > 10 && CThread::GetThisThreadID() == m_ThreadId)     ::WaitForSingleObject(m_StopEvent, dwMilliseconds);   else     ::Sleep(dwMilliseconds);Index: xbmc/linux/XCriticalSection.h===================================================================--- xbmc/linux/XCriticalSection.h	(revision 22954)+++ xbmc/linux/XCriticalSection.h	(working copy)@@ -58,7 +58,7 @@   private: -  DWORD           m_ownerThread;+  uintptr_t       m_ownerThread;   pthread_mutex_t m_mutex;   pthread_mutex_t m_countMutex;   int             m_count;Index: xbmc/linux/XThreadUtils.cpp===================================================================--- xbmc/linux/XThreadUtils.cpp	(revision 22954)+++ xbmc/linux/XThreadUtils.cpp	(working copy)@@ -85,6 +85,7 @@  DWORD WINAPI GetCurrentThreadId(void) {   // WARNING:  This can truncate thread IDs on x86_64.+  // Use CThread::GetThisThreadID() instead.   return (DWORD)pthread_self(); } Index: xbmc/linux/XCriticalSection.cpp===================================================================--- xbmc/linux/XCriticalSection.cpp	(revision 22954)+++ xbmc/linux/XCriticalSection.cpp	(working copy)@@ -21,6 +21,7 @@ #include "stdafx.h" #include "CriticalSection.h" #include "utils/log.h"+#include "Thread.h"  #define SAFELY(expr)                                   \ {                                                      \@@ -119,7 +120,7 @@ 	 	// Save the owner, bump the count. 	m_count++;-	m_ownerThread = GetCurrentThreadId();+	m_ownerThread = CThread::GetThisThreadID(); 	 	pthread_mutex_unlock(&m_countMutex); }@@ -205,7 +206,7 @@ ////////////////////////////////////////////////////////////////////// BOOL XCriticalSection::Owning() {-	return (m_ownerThread == GetCurrentThreadId());+	return (m_ownerThread == CThread::GetThisThreadID()); }  //////////////////////////////////////////////////////////////////////Index: xbmc/Application.cpp===================================================================--- xbmc/Application.cpp	(revision 22954)+++ xbmc/Application.cpp	(working copy)@@ -487,7 +487,7 @@ #endif    // Grab a handle to our thread to be used later in identifying the render thread.-  m_threadID = GetCurrentThreadId();+  m_threadID = CThread::GetThisThreadID();  #ifndef _LINUX   //floating point precision to 24 bits (faster performance)Index: xbmc/Application.h===================================================================--- xbmc/Application.h	(revision 22954)+++ xbmc/Application.h	(working copy)@@ -117,7 +117,7 @@   void StartZeroconf();   void StopZeroconf();   void DimLCDOnPlayback(bool dim);-  DWORD GetThreadId() const { return m_threadID; };+  uintptr_t GetThreadId() const { return m_threadID; };   void Stop();   void RestartApp();   void LoadSkin(const CStdString& strSkin);@@ -300,7 +300,7 @@   CFileItemList* m_currentStack;   CStdString m_prevMedia;   CSplash* m_splash;-  DWORD m_threadID;       // application thread ID.  Used in applicationMessanger to know where we are firing a thread with delay from.+  uintptr_t m_threadID;       // application thread ID.  Used in applicationMessanger to know where we are firing a thread with delay from.   PLAYERCOREID m_eCurrentPlayer;   bool m_bXboxMediacenterLoaded;   bool m_bSettingsLoaded;Index: xbmc/ApplicationMessenger.cpp===================================================================--- xbmc/ApplicationMessenger.cpp	(revision 22954)+++ xbmc/ApplicationMessenger.cpp	(working copy)@@ -86,7 +86,7 @@   if (wait)   { // check that we're not being called from our application thread, else we'll be waiting     // forever!-    if (GetCurrentThreadId() != g_application.GetThreadId())+    if (CThread::GetThisThreadID() != g_application.GetThreadId())       message.hWaitEvent = CreateEvent(NULL, true, false, NULL);     else     {