Skip to content

Commit

Permalink
Handle VFW_E_BUFFERS_OUTSTANDING errors during reconnection
Browse files Browse the repository at this point in the history
The VMR-9 renderer can send these errors when trying to reconnect
and its still rendering a frame. To work around the issue, try to give
the renderer a bit time to finish rendering the frames, and as a last
resort do a flush to ensure we can reconnect.
  • Loading branch information
Nevcairiel committed Jul 3, 2013
1 parent 7748566 commit a33fdad
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions decoder/LAVVideo/LAVVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ HRESULT CLAVVideo::ReconnectOutput(int width, int height, AVRational ar, DXVA2_E

HRESULT hr = S_FALSE;
BOOL bNeedReconnect = FALSE;
int timeout = 100;

DWORD dwAspectX = 0, dwAspectY = 0;
RECT rcTargetOld = {0};
Expand Down Expand Up @@ -1033,6 +1034,7 @@ HRESULT CLAVVideo::ReconnectOutput(int width, int height, AVRational ar, DXVA2_E
m_bSendMediaType = TRUE;
m_pOutput->SetMediaType(&mt);
} else {
receiveconnection:
hr = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt);
if(SUCCEEDED(hr)) {
IMediaSample *pOut = NULL;
Expand All @@ -1059,6 +1061,18 @@ HRESULT CLAVVideo::ReconnectOutput(int width, int height, AVRational ar, DXVA2_E
}
pOut->Release();
}
} else if (hr == VFW_E_BUFFERS_OUTSTANDING && timeout != -1) {
if (timeout > 0) {
DbgLog((LOG_TRACE, 10, L"-> Buffers outstanding, retrying in 10ms.."));
Sleep(10);
timeout -= 10;
} else {
DbgLog((LOG_TRACE, 10, L"-> Buffers outstanding, timeout reached, flushing.."));
m_pOutput->DeliverBeginFlush();
m_pOutput->DeliverEndFlush();
timeout = -1;
}
goto receiveconnection;
} else if (hrQA == S_OK) {
DbgLog((LOG_TRACE, 10, L"-> Downstream accepts new format, but cannot reconnect dynamically..."));
if (pBIH->biSizeImage > oldSizeImage) {
Expand Down

0 comments on commit a33fdad

Please sign in to comment.