Permalink
Browse files

MP1-4781V8 : madVR V342 (Another fix to avoid deadlock on stop when D…

…3D is reset)
  • Loading branch information...
Sebastiii committed Oct 7, 2017
1 parent 98ab451 commit ff862ae562b94c05d29784595525ddf39cea30a2
@@ -684,13 +684,15 @@ HRESULT MPMadPresenter::Stopping()
if (m_pSRCB)
{
// nasty, but we have to let it know about our death somehow
static_cast<CSubRenderCallback*>(static_cast<ISubRenderCallback*>(m_pSRCB))->SetShutdownSub(m_pShutdown);
static_cast<CSubRenderCallback*>(static_cast<ISubRenderCallback*>(m_pSRCB))->SetDXRAPSUB(nullptr);
Log("MPMadPresenter::Stopping() m_pSRCB");
}
if (m_pORCB)
{
// nasty, but we have to let it know about our death somehow
static_cast<COsdRenderCallback*>(static_cast<IOsdRenderCallback*>(m_pORCB))->SetShutdownOsd(m_pShutdown);
static_cast<COsdRenderCallback*>(static_cast<IOsdRenderCallback*>(m_pORCB))->SetDXRAP(nullptr);
Log("MPMadPresenter::Stopping() m_pORCB");
}
@@ -48,6 +48,7 @@ class MPMadPresenter : public CUnknown, public CCritSec
class COsdRenderCallback : public CUnknown, public IOsdRenderCallback, public CCritSec
{
MPMadPresenter* m_pDXRAP;
bool m_pShutdownOsd = false;
public: COsdRenderCallback(MPMadPresenter* pDXRAP) : CUnknown(_T("COsdRender"), NULL) , m_pDXRAP(pDXRAP) {}
@@ -65,22 +66,39 @@ class MPMadPresenter : public CUnknown, public CCritSec
m_pDXRAP = pDXRAP;
}
void SetShutdownOsd(bool pShutdownOsd)
{
m_pShutdownOsd = pShutdownOsd;
}
// IOsdRenderCallback
STDMETHODIMP ClearBackground(LPCSTR name, REFERENCE_TIME frameStart, RECT *fullOutputRect, RECT *activeVideoRect)
{
if (m_pShutdownOsd)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAP ? m_pDXRAP->ClearBackground(name, frameStart, fullOutputRect, activeVideoRect) : E_UNEXPECTED;
}
STDMETHODIMP RenderOsd(LPCSTR name, REFERENCE_TIME frameStart, RECT *fullOutputRect, RECT *activeVideoRect)
{
if (m_pShutdownOsd)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAP ? m_pDXRAP->RenderOsd(name, frameStart, fullOutputRect, activeVideoRect) : E_UNEXPECTED;
}
STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev)
{
if (m_pShutdownOsd)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAP ? m_pDXRAP->SetDeviceOsd(pD3DDev) : E_UNEXPECTED;
}
@@ -89,6 +107,7 @@ class MPMadPresenter : public CUnknown, public CCritSec
class CSubRenderCallback : public CUnknown, public ISubRenderCallback4, public CCritSec
{
MPMadPresenter* m_pDXRAPSUB;
bool m_pShutdownSub = false;
public: CSubRenderCallback(MPMadPresenter* pDXRAPSUB) : CUnknown(_T("CSubRender"), NULL) , m_pDXRAPSUB(pDXRAPSUB) {}
@@ -106,34 +125,59 @@ class MPMadPresenter : public CUnknown, public CCritSec
m_pDXRAPSUB = pDXRAPSUB;
}
void SetShutdownSub(bool pShutdownSub)
{
m_pShutdownSub = pShutdownSub;
}
// ISubRenderCallback
STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev)
{
if (m_pShutdownSub)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAPSUB ? m_pDXRAPSUB->SetDevice(pD3DDev) : E_UNEXPECTED;
}
STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height)
{
if (m_pShutdownSub)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAPSUB ? m_pDXRAPSUB->Render(rtStart, left, top, right, bottom, width, height) : E_UNEXPECTED;
}
STDMETHODIMP RenderEx(REFERENCE_TIME frameStart, REFERENCE_TIME frameStop, REFERENCE_TIME avgTimePerFrame, int left, int top, int right, int bottom, int width, int height)
{
if (m_pShutdownSub)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAPSUB ? m_pDXRAPSUB->Render(frameStart, left, top, right, bottom, width, height) : E_UNEXPECTED;
}
STDMETHODIMP RenderEx2(REFERENCE_TIME frameStart, REFERENCE_TIME frameStop, REFERENCE_TIME avgTimePerFrame, RECT croppedVideoRect, RECT originalVideoRect, RECT viewportRect, const double videoStretchFactor = 1.0)
{
if (m_pShutdownSub)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAPSUB ? m_pDXRAPSUB->Render(frameStart, croppedVideoRect.left, croppedVideoRect.top, croppedVideoRect.right, croppedVideoRect.bottom, viewportRect.top, viewportRect.right) : E_UNEXPECTED;
}
STDMETHODIMP RenderEx3(REFERENCE_TIME frameStart, REFERENCE_TIME frameStop, REFERENCE_TIME avgTimePerFrame, RECT croppedVideoRect, RECT originalVideoRect, RECT viewportRect, const double videoStretchFactor = 1.0, int xOffsetInPixels = 0, DWORD flags = 0)
{
if (m_pShutdownSub)
{
return S_OK;
}
CAutoLock cAutoLock(this);
return m_pDXRAPSUB ? m_pDXRAPSUB->RenderEx3(std::move(frameStart), std::move(frameStop), std::move(avgTimePerFrame), std::move(croppedVideoRect), std::move(originalVideoRect), std::move(viewportRect), std::move(videoStretchFactor), xOffsetInPixels) : E_UNEXPECTED;
}

0 comments on commit ff862ae

Please sign in to comment.