diff options
-rw-r--r-- | src/DSUtil/DSUtil.cpp | 28 | ||||
-rw-r--r-- | src/DSUtil/DSUtil.h | 1 | ||||
-rw-r--r-- | src/apps/mplayerc/DX7AllocatorPresenter.cpp | 46 | ||||
-rw-r--r-- | src/apps/mplayerc/DX9AllocatorPresenter.cpp | 25 | ||||
-rw-r--r-- | src/apps/mplayerc/EVRAllocatorPresenter.cpp | 1 | ||||
-rw-r--r-- | src/apps/mplayerc/MainFrm.cpp | 5 | ||||
-rw-r--r-- | src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp | 2 |
7 files changed, 81 insertions, 27 deletions
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp index d43328924..b85a44638 100644 --- a/src/DSUtil/DSUtil.cpp +++ b/src/DSUtil/DSUtil.cpp @@ -2535,3 +2535,31 @@ const wchar_t *StreamTypeToName(PES_STREAM_TYPE _Type) }
return NULL;
}
+
+//
+// Usage: SetThreadName (-1, "MainThread");
+//
+typedef struct tagTHREADNAME_INFO
+{
+ DWORD dwType; // must be 0x1000
+ LPCSTR szName; // pointer to name (in user addr space)
+ DWORD dwThreadID; // thread ID (-1=caller thread)
+ DWORD dwFlags; // reserved for future use, must be zero
+} THREADNAME_INFO;
+
+void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
+{
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = szThreadName;
+ info.dwThreadID = dwThreadID;
+ info.dwFlags = 0;
+
+ __try
+ {
+ RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info );
+ }
+ __except(EXCEPTION_CONTINUE_EXECUTION)
+ {
+ }
+}
\ No newline at end of file diff --git a/src/DSUtil/DSUtil.h b/src/DSUtil/DSUtil.h index e30eb3f6e..a24b8ceef 100644 --- a/src/DSUtil/DSUtil.h +++ b/src/DSUtil/DSUtil.h @@ -116,6 +116,7 @@ extern DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb); extern DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
extern void TraceFilterInfo(IBaseFilter* pBF);
extern void TracePinInfo(IPin* pPin);
+extern void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName);
class CPinInfo : public PIN_INFO
{
diff --git a/src/apps/mplayerc/DX7AllocatorPresenter.cpp b/src/apps/mplayerc/DX7AllocatorPresenter.cpp index db7d23500..b3877b9cc 100644 --- a/src/apps/mplayerc/DX7AllocatorPresenter.cpp +++ b/src/apps/mplayerc/DX7AllocatorPresenter.cpp @@ -67,7 +67,9 @@ protected: virtual HRESULT CreateDevice();
virtual HRESULT AllocSurfaces();
- virtual void DeleteSurfaces();
+ virtual void DeleteSurfaces();
+
+ bool ResetDevice();
public:
CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr);
@@ -304,7 +306,11 @@ CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr) return;
}
- hr = CreateDevice();
+ hr = CreateDevice();
+ if (FAILED(hr))
+ {
+ TRACE("CreateDevice failed: 0x%08x\n", (LONG)hr);
+ }
}
HRESULT CDX7AllocatorPresenter::CreateDevice()
@@ -565,22 +571,24 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll) hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
if(hr == DDERR_SURFACELOST)
- {
- HRESULT hr = DDERR_WRONGMODE; // m_pDD->TestCooperativeLevel();
-
- if(hr == DDERR_WRONGMODE)
- {
- DeleteSurfaces();
- if(SUCCEEDED(CreateDevice()) || FAILED(hr = AllocSurfaces()))
- return(true);
- }
-
- hr = S_OK;
- }
+ ResetDevice();
return(true);
}
+bool CDX7AllocatorPresenter::ResetDevice()
+{
+ HRESULT hr;
+ DeleteSurfaces();
+ if(FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces()))
+ {
+ //DDERR_UNSUPPORTEDMODE
+ TRACE("ResetDevice failed: 0x%08x\n", (LONG)hr);
+ return false;
+ }
+ return true;
+}
+
STDMETHODIMP CDX7AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
CheckPointer(size, E_POINTER);
@@ -803,6 +811,8 @@ STDMETHODIMP CVMR7AllocatorPresenter::FreeSurface(DWORD_PTR dwUserID) STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags)
{
+ SetThreadName(-1, "CVMR7AllocatorPresenter");
+
if(!lpSurface)
return E_POINTER;
@@ -851,7 +861,13 @@ extern bool g_bExternalSubtitleTime; STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo)
{
if(!lpPresInfo || !lpPresInfo->lpSurf)
- return E_POINTER;
+ return E_POINTER;
+
+ if (!m_pD3DDev)
+ {
+ if (!ResetDevice())
+ return DDERR_SURFACELOST;
+ }
CAutoLock cAutoLock(this);
diff --git a/src/apps/mplayerc/DX9AllocatorPresenter.cpp b/src/apps/mplayerc/DX9AllocatorPresenter.cpp index 6e8e32f69..5545b7aee 100644 --- a/src/apps/mplayerc/DX9AllocatorPresenter.cpp +++ b/src/apps/mplayerc/DX9AllocatorPresenter.cpp @@ -337,7 +337,7 @@ CDX9AllocatorPresenter::~CDX9AllocatorPresenter() m_pD3DDevEx = NULL;
m_pPSC.Free();
m_pD3D = NULL;
- m_pD3DEx = NULL;
+ m_pD3DEx = NULL;
if (m_hDWMAPI)
{
FreeLibrary(m_hDWMAPI);
@@ -1000,7 +1000,8 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR;
-
+
+ SetThreadName (-1, "D3D9PresenterThread");
if (m_bIsFullscreen)
{
pp.Windowed = false;
@@ -2291,8 +2292,12 @@ void CDX9AllocatorPresenter::UpdateAlphaBitmap() STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
{
-// if (!fAll)
-// return false;
+ if (!m_pD3DDev)
+ {
+ if (!ResetDevice()) // fix Windows+L crash
+ return false;
+ }
+
AppSettings& s = AfxGetAppSettings();
// TRACE("Thread: %d\n", (LONG)((CRITICAL_SECTION &)m_RenderLock).OwningThread);
@@ -2304,10 +2309,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) }
else
{
- __asm
- {
- int 3
- };
+ __debugbreak();
}
#endif
@@ -2868,7 +2870,12 @@ bool CDX9AllocatorPresenter::ResetDevice() CString Error;
// TODO: Report error messages here
if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces()))
- {
+ {
+ // TODO: We should probably pause player
+#ifdef _DEBUG
+ Error += GetWindowsErrorMessage(hr, NULL);
+ TRACE("D3D Reset Error\n%ws\n\n", Error.GetBuffer());
+#endif
return false;
}
OnResetDevice();
diff --git a/src/apps/mplayerc/EVRAllocatorPresenter.cpp b/src/apps/mplayerc/EVRAllocatorPresenter.cpp index bca8b4a3a..af2235a8d 100644 --- a/src/apps/mplayerc/EVRAllocatorPresenter.cpp +++ b/src/apps/mplayerc/EVRAllocatorPresenter.cpp @@ -320,7 +320,6 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString & if (FAILED (hr))
{
_Error += L"DX9AllocatorPresenter failed\n";
-
return;
}
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp index 9adc8cbad..adaa4e8c5 100644 --- a/src/apps/mplayerc/MainFrm.cpp +++ b/src/apps/mplayerc/MainFrm.cpp @@ -2202,7 +2202,7 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam) LONG_PTR evParam1, evParam2;
while(pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0)))
{
- TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: %x\n", GetCurrentThreadId(), evCode);
+ TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: 0x%08x\n", GetCurrentThreadId(), evCode);
CString str;
if(m_fCustomGraph)
@@ -13158,7 +13158,8 @@ IMPLEMENT_DYNCREATE(CGraphThread, CWinThread) BOOL CGraphThread::InitInstance()
{
- AfxSocketInit();
+ SetThreadName(-1, "GraphThread");
+ AfxSocketInit();
return SUCCEEDED(CoInitialize(0)) ? TRUE : FALSE;
}
diff --git a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp index b949290eb..2fddd487e 100644 --- a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp +++ b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp @@ -794,6 +794,8 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) STDMETHODIMP CStreamSwitcherInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
+ SetThreadName(-1, "CStreamSwitcherInputPin");
+
if(!IsConnected())
return S_OK;
|