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,8 @@ DWORD WINAPI GetCurrentThreadId(void) { // WARNING: This can truncate thread IDs on x86_64. + // Use CThread::GetThisThreadID() instead. + CLog::Log(LOGDEBUG, "GetCurrentThreadId() is deprecated. Please 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 { Index: xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp =================================================================== --- xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp (revision 22954) +++ xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp (working copy) @@ -28,7 +28,6 @@ #endif #ifdef _LINUX #include "stdint.h" -#include "linux/XThreadUtils.h" #else #define INT64_C __int64 #endif @@ -45,6 +44,7 @@ #include "AdvancedSettings.h" #include "FileSystem/File.h" #include "utils/log.h" +#include "utils/Thread.h" void CDemuxStreamAudioFFmpeg::GetStreamInfo(std::string& strInfo) { @@ -78,7 +78,7 @@ void ff_avutil_log(void* ptr, int level, const char* format, va_list va) { CSingleLock lock(DllAvCodec::m_critSection); - DWORD threadId = GetCurrentThreadId(); + uintptr_t threadId = CThread::GetThisThreadID(); CStdString &buffer = g_logbuffer[threadId]; AVClass* avc= ptr ? *(AVClass**)ptr : NULL; Index: xbmc/cores/dvdplayer/DVDPlayer.cpp =================================================================== --- xbmc/cores/dvdplayer/DVDPlayer.cpp (revision 22954) +++ xbmc/cores/dvdplayer/DVDPlayer.cpp (working copy) @@ -1510,7 +1510,7 @@ void CDVDPlayer::SyncronizeDemuxer(DWORD timeout) { - if(CThread::ThreadId() == GetCurrentThreadId()) + if(CThread::ThreadId() == CThread::GetThisThreadID()) return; if(!m_messenger.IsInited()) return; @@ -2722,7 +2722,7 @@ { #define THREAD_ACTION(action) \ do { \ - if(GetCurrentThreadId() != CThread::ThreadId()) { \ + if(CThread::GetThisThreadID() != CThread::ThreadId()) { \ m_messenger.Put(new CDVDMsgType(CDVDMsg::GENERAL_GUI_ACTION, action)); \ return true; \ } \ Index: xbmc/cores/VideoRenderers/OverlayRendererGL.cpp =================================================================== --- xbmc/cores/VideoRenderers/OverlayRendererGL.cpp (revision 22954) +++ xbmc/cores/VideoRenderers/OverlayRendererGL.cpp (working copy) @@ -108,7 +108,7 @@ long count = InterlockedDecrement(&m_references); if (count == 0) { - if(GetCurrentThreadId() == g_application.GetThreadId()) + if(CThread::GetThisThreadID() == g_application.GetThreadId()) delete this; else g_renderManager.AddCleanup(this); @@ -385,4 +385,4 @@ glBindTexture(GL_TEXTURE_2D, 0); } -#endif // HAS_GL \ No newline at end of file +#endif // HAS_GL Index: xbmc/lib/libPython/XBPython.h =================================================================== --- xbmc/lib/libPython/XBPython.h (revision 22954) +++ xbmc/lib/libPython/XBPython.h (working copy) @@ -99,7 +99,7 @@ int nextid; PyThreadState* mainThreadState; - DWORD dThreadId; + uintptr_t dThreadId; bool m_bInitialized; HANDLE m_hEvent; int m_iDllScriptCounter; // to keep track of the total scripts running that need the dll Index: xbmc/lib/libPython/XBPython.cpp =================================================================== --- xbmc/lib/libPython/XBPython.cpp (revision 22954) +++ xbmc/lib/libPython/XBPython.cpp (working copy) @@ -119,7 +119,7 @@ InitializeCriticalSection(&m_critSection); m_hEvent = CreateEvent(NULL, false, false, (char*)"pythonEvent"); m_globalEvent = CreateEvent(NULL, false, false, (char*)"pythonGlobalEvent"); - dThreadId = GetCurrentThreadId(); + dThreadId = CThread::GetThisThreadID(); vecPlayerCallbackList.clear(); m_iDllScriptCounter = 0; } @@ -299,7 +299,7 @@ m_iDllScriptCounter++; if (!m_bInitialized) { - if (dThreadId == GetCurrentThreadId()) + if (dThreadId == CThread::GetThisThreadID()) { m_pDll = DllLoaderContainer::LoadModule(PYTHON_DLL, NULL, true);