开发者

Deleting DirectShow Filters (Destructor not called)

开发者 https://www.devze.com 2023-03-14 02:21 出处:网络
I have built a custom DirectShow filter that implements CSource such as class Myfilter : public CSource

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

精彩评论

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