If you look at the docs for FillBuffer, it can return S_OK (prefer this to the equivalent NOERROR) or S_FALSE.
You cannot return S_OK unless you have provided a valid sample in the parameter pSample .
You can return S_FALSE if you are at the end of the stream but not to indicate that you do not have a sample ready.
I provided the information on the loop above but here it is in code:
Code Snippet
while (true) {
{
CAutoLock lock(&m_lock); // shared CCritSec with function in other thread that gets the sample data
hr = CheckForNewSample(pSample); // return VFW_S_STATE_INTERMEDIATE when a sample is not ready, S_OK for a sample is provided in pSample and S_FALSE when end of stream is detected
if (hr != VFW_S_STATE_INTERMEDIATE)
return hr;
}
::Sleep(1); // adjust the sleep value to suit your needs
}
Hello,
I'm in the case where my source filter doesn't have (yet) any sample to push. But I don't know what to do in FillBuffer():
- I can't return S_OK since no sample is produced
- I can't return S_FALSE since it is not an end of stream
- I can't do a Sleep() until I have samples to produce, since it blocks the video rendering window.
I'm stuck.
Do you have any idea?
Thanks.