Sign in to follow this  

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

This topic is 2400 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.

[code]
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;
}
[/code]

[code]
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;
}
[/code]

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

This topic is 2400 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this