Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle VFW_E_BUFFERS_OUTSTANDING errors during pixel format negotiation. #4

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions decoder/LAVVideo/LAVVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ HRESULT CLAVVideo::NegotiatePixelFormat(CMediaType &outMt, int width, int height

HRESULT hr = S_OK;
int i = 0;
int timeout = 100;

DWORD dwAspectX, dwAspectY;
REFERENCE_TIME rtAvg;
Expand All @@ -1132,12 +1133,25 @@ HRESULT CLAVVideo::NegotiatePixelFormat(CMediaType &outMt, int width, int height
for (i = 0; i < m_PixFmtConverter.GetNumMediaTypes(); ++i) {
m_PixFmtConverter.GetMediaType(&mt, i, width, height, dwAspectX, dwAspectY, rtAvg, m_Decoder.IsInterlaced(), bVIH1);
//hr = m_pOutput->GetConnected()->QueryAccept(&mt);
receiveconnection:
hr = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt);
if (hr == S_OK) {
DbgLog((LOG_TRACE, 10, L"::NegotiatePixelFormat(): Filter accepted format with index %d", i));
m_pOutput->SetMediaType(&mt);
hr = S_OK;
goto done;
} 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;
}
}

Expand Down