Jump to content
  • Advertisement
Sign in to follow this  
bluestrings

How to control threads that will be started by DirectShow Filter ?

This topic is 2613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have writing a DirectShow Capture filter and now confusing with threads that will be generated by my filter class that will inherit CSourceStream, IAMStreamConfig and IKsPropertySet.

Then I met problems are occurred when I do manipulations below.

- First, start a host program that will loads the filter's DLL.
- Second, prompt a command "regsvr32 -u myfilter.ax" and "regsvr32 myfilter.ax" sequentially. This command can be executed by hands or some process.
- Then DLL will crush in the FillBuffer virtual function by manipulating the stream's memory. It seems a dirty access or a race condition... But this crush has one condition that is the defference in the SetFormat virtual function of this filter class. Below are two types of SetFormat methods.


HRESULT STDMETHODCALLTYPE CMyFilter::SetFormat(
AM_MEDIA_TYPE *pmt
)
{
DECLARE_PTR(VIDEOINFOHEADER, pvi, m_mt.pbFormat);
prev_vid_info = *pvi;

m_mt = *pmt; // this line will be cause of the error with filter's threads.

IPin* pin;
ConnectedTo(&pin);
if(pin)
{
IFilterGraph *pGraph = m_pParent->GetGraph();
pGraph->Reconnect(this);
}
return S_OK;
}



HRESULT STDMETHODCALLTYPE CMyFilter::SetFormat(
AM_MEDIA_TYPE *pmt
)
{
DECLARE_PTR(VIDEOINFOHEADER, pvi, m_mt.pbFormat);
prev_vid_info = *pvi;

// comment out the line below and error will not occurres BUT this filter will be incapable with modification of resolutions. (i.e. with the Adobe Flash Media Live Encoder)
//m_mt = *pmt;

IPin* pin;
ConnectedTo(&pin);
if(pin)
{
IFilterGraph *pGraph = m_pParent->GetGraph();
pGraph->Reconnect(this);
}
return S_OK;
}


How can I control filter's threads when I reload filter DLL with regsvr32 ?
I have tried to control this thread with IMediaControl interface's methods but these functions don't work.
I've reached informations with CSourceStream's DoBufferProcessingLoop method. But I don't get nice ideas to manipulate threads with this virtual method.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!