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
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
deleteCOM objects, you shouldRelease()them.CSourceprobably implementsIUnknown::Release()asdelete this, when the reference count drops to 0.