diff options
author | Casimir666 <casimir666@users.sourceforge.net> | 2008-05-10 17:44:40 +0400 |
---|---|---|
committer | Casimir666 <casimir666@users.sourceforge.net> | 2008-05-10 17:44:40 +0400 |
commit | 1134362fb878603863dafe74a2e6653a45219a7a (patch) | |
tree | 2fa80f2e72c9f9bb85034ef3c56d4fcd0211e334 /src/filters/transform/mpcvideodec/DXVADecoder.cpp | |
parent | 1b95e8eb36f6780563f314ec0844d98d18af116f (diff) |
Fixed : seeking problem on nVidia card
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@510 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/mpcvideodec/DXVADecoder.cpp')
-rw-r--r-- | src/filters/transform/mpcvideodec/DXVADecoder.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/filters/transform/mpcvideodec/DXVADecoder.cpp b/src/filters/transform/mpcvideodec/DXVADecoder.cpp index 1f68c752b..34cd46c0e 100644 --- a/src/filters/transform/mpcvideodec/DXVADecoder.cpp +++ b/src/filters/transform/mpcvideodec/DXVADecoder.cpp @@ -27,6 +27,17 @@ #include "MPCVideoDecFilter.h"
#include "VideoDecDXVAAllocator.h"
+#define MAX_RETRY_ON_PENDING 50
+#define DO_DXVA_PENDING_LOOP(x) nTry = 0; \
+ while (FAILED(hr = x) && nTry<MAX_RETRY_ON_PENDING) \
+ { \
+ if (hr != E_PENDING) break; \
+ TRACE ("Pending loop %d\n", nTry); \
+ Sleep(1); \
+ nTry++; \
+ }
+
+
CDXVADecoder::CDXVADecoder (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
{
@@ -351,23 +362,19 @@ DWORD CDXVADecoder::GetDXVA1CompressedType (DWORD dwDXVA2CompressedType) HRESULT CDXVADecoder::FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex)
{
HRESULT hr;
+ int nTry;
dwBufferIndex = 0; //(dwBufferIndex + 1) % m_ComBufferInfo[DXVA_PICTURE_DECODE_BUFFER].dwNumCompBuffers;
- for (int nTry=0; nTry<5; nTry++)
- {
- hr = m_pAMVideoAccelerator->QueryRenderStatus (-1, dwBufferIndex, 0);
- if (SUCCEEDED (hr)) return hr;
- TRACE ("QueryRenderStatus FAILED : %d - %d (hr=0x%08x)\n", dwTypeIndex, dwBufferIndex, hr);
- Sleep(40);
- }
+ DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->QueryRenderStatus (-1, dwBufferIndex, 0));
return hr;
}
HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver)
{
- HRESULT hr = E_INVALIDARG;
+ HRESULT hr = E_INVALIDARG;
+ int nTry = 0;
for (int i=0; i<20; i++)
{
@@ -381,7 +388,9 @@ HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliv BeginFrameInfo.pInputData = &nSurfaceIndex;
BeginFrameInfo.dwSizeOutputData = 0;
BeginFrameInfo.pOutputData = NULL;
- hr = m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo);
+
+ DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
+
ASSERT (SUCCEEDED (hr));
// TRACE ("BeginFrame %d\n",nSurfaceIndex);
if (SUCCEEDED (hr))
@@ -396,7 +405,8 @@ HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliv if (pSampleService)
{
hr = pSampleService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**) &pDecoderRenderTarget);
- if (SUCCEEDED (hr)) hr = m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, NULL);
+ if (SUCCEEDED (hr))
+ DO_DXVA_PENDING_LOOP (m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, NULL));
}
}
break;
|