diff options
author | beliyaal <beliyaal@users.sourceforge.net> | 2009-10-28 00:31:46 +0300 |
---|---|---|
committer | beliyaal <beliyaal@users.sourceforge.net> | 2009-10-28 00:31:46 +0300 |
commit | f269e5b9fb3c3db8a1398f87a7062da406fdf30b (patch) | |
tree | 7eeabde3e2ae21ed2cf29b0d299c7fe71e4e05cc /src/filters/BaseClasses | |
parent | 7d6aecccb36aa9d11ed8b485b0770f2679443dc5 (diff) |
Fixed: Scanline and refresh rate detection algorithm changed
Fixed: Scanline detection and sync was incorrect on rotated displays
Fixed: D3D device interference from other threads minimized
Added: TryLock added to CCritSec
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1312 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/BaseClasses')
-rw-r--r-- | src/filters/BaseClasses/wxutil.cpp | 20 | ||||
-rw-r--r-- | src/filters/BaseClasses/wxutil.h | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/filters/BaseClasses/wxutil.cpp b/src/filters/BaseClasses/wxutil.cpp index 5bc97a9ae..9e84cd338 100644 --- a/src/filters/BaseClasses/wxutil.cpp +++ b/src/filters/BaseClasses/wxutil.cpp @@ -508,6 +508,26 @@ void CCritSec::Lock() }
}
+bool CCritSec::TryLock()
+{
+ UINT tracelevel=3;
+ DWORD us = GetCurrentThreadId();
+ DWORD currentOwner = m_currentOwner;
+ BOOL bSuccess = TryEnterCriticalSection(&m_CritSec);
+ if (bSuccess)
+ {
+ if (0 == m_lockCount++) {
+ // we now own it for the first time. Set owner information
+ m_currentOwner = us;
+
+ if (m_fTrace) {
+ DbgLog((LOG_LOCKING, tracelevel, TEXT("Thread %d now owns lock %x"), m_currentOwner, &m_CritSec));
+ }
+ }
+ }
+ return bSuccess != 0;
+}
+
void CCritSec::Unlock() {
if (0 == --m_lockCount) {
// about to be unowned
diff --git a/src/filters/BaseClasses/wxutil.h b/src/filters/BaseClasses/wxutil.h index 305974a5f..a1866ed9c 100644 --- a/src/filters/BaseClasses/wxutil.h +++ b/src/filters/BaseClasses/wxutil.h @@ -33,6 +33,7 @@ public: CCritSec();
~CCritSec();
void Lock();
+ bool TryLock();
void Unlock();
#else
@@ -49,6 +50,11 @@ public: EnterCriticalSection(&m_CritSec);
};
+ bool TryLock()
+ {
+ return TryEnterCriticalSection(&m_CritSec) != 0;
+ };
+
void Unlock() {
LeaveCriticalSection(&m_CritSec);
};
|