删除 DirectShow 过滤器(未调用析构函数)
我构建了一个实现 CSource 的自定义 DirectShow 过滤器,例如
class Myfilter : public CSource
{
~MyFilter(){ delete everything;}
}
当我在 GraphStudio 中使用此过滤器时,我可以正确删除它,析构函数被正确调用。
当我通过 COM instaciation 创建过滤器时,我无法再使用 delete 删除它
IBaseFilter *pFilter = NULL;
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pFilter));
,然后删除 pFilter 将不会调用析构函数。
如何为我的过滤器调用自定义析构函数?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该
删除
COM 对象,您应该Release()
它们。当引用计数降至 0 时,CSource
可能会实现IUnknown::Release()
作为删除此
。You're not supposed to
delete
COM objects, you shouldRelease()
them.CSource
probably implementsIUnknown::Release()
asdelete 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.