开发者

Deleting DirectShow Filters (Destructor not called)

I have built a custom DirectShow filter that implements CSource such as

class Myfilter : public CSource
{
   ~MyFilter(){ delete everything;}
}

When I use this filter in GraphStudio, I can delete it properly, the destructor is called correctly.

When I create my filter via COM instaciation, I can no longer delete it with delete

开发者_Go百科IBaseFilter *pFilter = NULL;

HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, 
                              IID_PPV_ARGS(&pFilter));

then delete pFilter will not call the destructor.

How can I call my custom destructor for my filter?


You're not supposed to delete COM objects, you should Release() them. CSource probably implements IUnknown::Release() as delete this, when the reference count drops to 0.


If you've added your filter to a graph, don't forget to remove it from the graph when you're done before releasing your own references.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜