diff options
author | jonasno <jonasno@users.sourceforge.net> | 2011-06-03 00:54:54 +0400 |
---|---|---|
committer | jonasno <jonasno@users.sourceforge.net> | 2011-06-03 00:54:54 +0400 |
commit | a138c13d4d9eca76e6687b96d9c979cf227c489e (patch) | |
tree | 8a45a42e1daa24939e2ac3aea17a0ca46f63d28c /src/filters/renderer/VideoRenderers | |
parent | 90f652daf84728ba61534810aece6445fc076248 (diff) |
Fixed a threading issue when moving player window from display 1 to display 2
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3175 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/renderer/VideoRenderers')
-rw-r--r-- | src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp | 8 | ||||
-rw-r--r-- | src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp | 36 |
2 files changed, 40 insertions, 4 deletions
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp index b2727fd8e..420355842 100644 --- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp @@ -1866,11 +1866,19 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice() TRACE("ResetDevice\n");
_ASSERT(m_MainThreadId == GetCurrentThreadId());
StopWorkerThreads();
+
+ // In VMR-9 deleting the surfaces before we are told to is bad !
+ // Can't comment out this because CDX9AllocatorPresenter is used by EVR Custom
+ // Why is EVR using a presenter for DX9 anyway ?!
DeleteSurfaces();
+
HRESULT hr;
CString Error;
// TODO: Report error messages here
+ // In VMR-9 'AllocSurfaces' call is redundant afaik because
+ // 'CreateDevice' calls 'm_pIVMRSurfAllocNotify->ChangeD3DDevice' which in turn calls
+ // 'CVMR9AllocatorPresenter::InitializeDevice' which calls 'AllocSurfaces'
if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces())) {
// TODO: We should probably pause player
#ifdef _DEBUG
diff --git a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp index 7d7ecc5ab..939958d51 100644 --- a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp @@ -179,11 +179,13 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A return E_FAIL;
}
+ // WTF: Is this some kind of forgotten debug code ?
if((GetAsyncKeyState(VK_CONTROL)&0x80000000))
if(lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I') {
return E_FAIL;
}
+ // The surfaces should already be free when InitializeDevice is called
DeleteSurfaces();
int nOriginal = *lpNumBuffers;
@@ -250,6 +252,9 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
{
+ // We should not free the surfaces until we are told to !
+ // Thats what TerminateDevice is for
+ DeleteSurfaces();
return S_OK;
}
@@ -259,19 +264,42 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD Surfa return E_POINTER;
}
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ /*
+ SurfaceIndex = 0
+ m_pSurfaces.GetCount() = 0
+
+ Scenario:
+ Thread 1:
+ Wait on m_RenderLock in this function
+ Thread 2:
+ Have m_RenderLock and removes all m_pSurfaces
+ (Happens by calling ex CDX9AllocatorPresenter::ResetDevice)
+
+ When thread 2 releases the lock thread 1 gets it and boom!
+
+ Possible solution: Adding object lock and moving m_RenderLock to try to fix this threading issue.
+ This problem occurs when moving the window from display a to display b.
+
+ NOTE: This is just a workaround.
+ CDX9AllocatorPresenter doesn't follow the rules which is why this happened.
+ And it is used by EVR custom (which it really shouldn't) so i can't easily fix it without breaking EVR custom.
+ */
if(SurfaceIndex >= m_pSurfaces.GetCount()) {
return E_FAIL;
}
- CAutoLock cRenderLock(&m_RenderLock);
-
if (m_nVMR9Surfaces) {
++m_iVMR9Surface;
m_iVMR9Surface = m_iVMR9Surface % m_nVMR9Surfaces;
- (*lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex])->AddRef();
+ *lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex];
+ (*lplpSurface)->AddRef();
} else {
m_iVMR9Surface = SurfaceIndex;
- (*lplpSurface = m_pSurfaces[SurfaceIndex])->AddRef();
+ *lplpSurface = m_pSurfaces[SurfaceIndex];
+ (*lplpSurface)->AddRef();
}
return S_OK;
|