Windows > Software Development for Windows Client Forums > DirectShow Development > What to do in FillBuffer in a source filter if there is no data available?
Ask a questionAsk a question
 

AnswerWhat to do in FillBuffer in a source filter if there is no data available?

  • Tuesday, November 03, 2009 11:53 AMpunkypogo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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.

Answers

  • Tuesday, November 03, 2009 3:07 PMChris P_MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You block in FillBuffer until you have samples to push.  Yes, it blocks the rendering window.  Your source filter can send the EC_BUFFERING_DATA events to let the application know that you are buffering.
    www.chrisnet.net
    • Marked As Answer bypunkypogo Tuesday, November 03, 2009 3:42 PM
    •  

All Replies

  • Tuesday, November 03, 2009 3:07 PMChris P_MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You block in FillBuffer until you have samples to push.  Yes, it blocks the rendering window.  Your source filter can send the EC_BUFFERING_DATA events to let the application know that you are buffering.
    www.chrisnet.net
    • Marked As Answer bypunkypogo Tuesday, November 03, 2009 3:42 PM
    •  
  • Tuesday, November 03, 2009 3:42 PMpunkypogo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Chris,

    Thanks for your answer and your split.
  • Tuesday, November 10, 2009 6:48 AMmechifendel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi!
    I overloaded the DoProcessingLoop function and then I have FillBuffer return 99 (I sometimes have frames that i process but i don't want them to be displayed). 

    In DoProcessingLoop, if hr == 99, I skip the

     

    hr=Deliver(pSample);

    and just do
    pSample->Release();

    and everything continues fine.
    Mechi