简体   繁体   English

Directshow渲染过滤器仅在发布模式下崩溃

[英]Directshow render filter crashes only in release mode

I've written a custom renderer filter to push video frames to system memory and later to OpenGL. 我编写了一个自定义渲染器过滤器,将视频帧推送到系统内存,然后推送到OpenGL。 It's not in a DLL and I don't register it, but instead use it like this page describes in the first paragraph. 它不在DLL中,我也没有注册它,而是像本页面在第一段中描述的那样使用它。 This works fine in the Debug mode, but in Release it starts crashing. 在“调试”模式下,此方法工作正常,但在“发行版”中,它开始崩溃。 I'm doing the following to initialize the graph: 我正在执行以下初始化图:

HRESULT hr;

CoInitialize(0);
CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC, IID_IGraphBuilder, (void**)&graph);

graph->QueryInterface(IID_IMediaControl, (void**)&mediaControl);
graph->QueryInterface(IID_IMediaSeeking, (void**)&mediaSeeking);

grabber = new textureGrabber(0, &hr);
grabber->AddRef(); // crash here
grabber->setTexture(&texture);
grabber->QueryInterface(IID_IBaseFilter, (void**)&base);

graph->AddFilter(base, L"OpenGL texture video filter");
graph->RenderFile(path.c_str(), 0);

This crashes on the AddRef() due to an access violation. 由于访问冲突,这在AddRef()上崩溃。 I've already tried implementing the IUnknown of the class myself, and the best I got was to the AddFilter where it crashed because the IBaseFilter seemed to be invalid. 我已经尝试过自己实现该类的IUnknown,而我得到的最好的结果就是AddFilter崩溃了,因为IBaseFilter似乎无效。 After that I found even a Microsoft-issued example doing this the simple way and it seems to work for them. 之后,我什发现了一个由Microsoft发行的示例 ,该示例都以简单的方式执行此操作,并且似乎适用于他们。 I'm curious what might be wrong since I'm doing the same exact thing - even tried the smart pointers. 我很好奇可能做错了什么,因为我正在做同样的事情-甚至尝试了智能指针。

EDIT: The problem is in the CBaseFilter DECLARE_IUNKNOWN macro, the GetOwner()->AddRef fails. 编辑:问题是在CBaseFilter DECLARE_IUNKNOWN宏中,GetOwner()-> AddRef失败。 GetOwner itself seems to work. GetOwner本身似乎起作用。

GetOwner returns whatever you pass as the second parameter to the CBaseFilter constructor. GetOwner将您传递的任何内容作为第二个参数返回给CBaseFilter构造函数。 Normally NULL unless you are aggregating the object for some reason (if you are, you probably don't need to). 通常为NULL,除非您出于某种原因聚集对象(如果确实如此,则可能不需要)。

A crash can occur at that point if your release build is linking against Strmbasd.lib , which is the debug version of the DirectShow base class library. 如果发布版本与Strmbasd.lib链接,则崩溃可能会发生, Strmbasd.lib是DirectShow基类库的调试版本。

Change your project's release configuration to link against Strmbase.lib instead, which is the release version of the library. 更改项目的发行版本配置,改为链接到Strmbase.lib ,这是该库的发行版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM