Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ DIrectshow功能在系统启动时被阻止_C++_Windows_Directx_Media Player_Directshow - Fatal编程技术网

C++ DIrectshow功能在系统启动时被阻止

C++ DIrectshow功能在系统启动时被阻止,c++,windows,directx,media-player,directshow,C++,Windows,Directx,Media Player,Directshow,我有一个基于Directshow的mediaplayer应用程序。在正常的播放过程中,它工作得非常好,没有任何问题。但有时,当Mediaplayer在系统启动后启动时,我会遇到一个问题 HRESULT CSDirectShow::RenderOutputPins (IBaseFilter* pFilter) { const char* funcName = "CSDirectShow::RenderOutputPins()"; HRESULT hr = S_OK;

我有一个基于Directshow的mediaplayer应用程序。在正常的播放过程中,它工作得非常好,没有任何问题。但有时,当Mediaplayer在系统启动后启动时,我会遇到一个问题

HRESULT CSDirectShow::RenderOutputPins (IBaseFilter* pFilter)
{
    const char* funcName = "CSDirectShow::RenderOutputPins()";
    HRESULT     hr = S_OK;

    // Enumerate all pins on the source filter,
    //  looking for the output pins so that I can call Render() on them
    //
    CComPtr< IEnumPins > pEnumPin;
    if (!FAILED (pFilter->EnumPins (&pEnumPin)))
    {
        while (true)
        {
            // get the next pin
            //

            CComPtr< IPin > pPin;
            if (pEnumPin->Next (1L, &pPin, NULL) != S_OK) break;
            // I'm not interested in connected pins
            //  if this pin is an unconnected output pin, then render it.
            //
            CComPtr< IPin > pConnectedPin;
            if (pPin->ConnectedTo (&pConnectedPin) == VFW_E_NOT_CONNECTED)
            {
                PIN_DIRECTION pinDirection;
                PIN_INFO pinInfo;
                //Get the information of the pin
                if (pPin->QueryDirection (&pinDirection) == S_OK
                                            && pinDirection == PINDIR_OUTPUT 
                                            && pPin->QueryPinInfo(&pinInfo) == S_OK 
                                            && strstr((char*)pinInfo.achName,"~")==NULL)
                {
                    if (FAILED (hr = m_pGB->Render (pPin))) 
                    {
                        SafeRelease(&pinInfo.pFilter);
                        return hr;
                    }
                }
                SafeRelease(&pinInfo.pFilter);
            }
        }
    }
    TraceMsg ("%s: exit",funcName);
    return S_OK;
    }
HRESULT CSDirectShow::RenderOutputPins(IBaseFilter*pFilter)
{
const char*funcName=“CSDirectShow::RenderOutputPins()”;
HRESULT hr=S_正常;
//枚举源筛选器上的所有管脚,
//正在查找输出管脚,以便对其调用Render()
//
CComPtrpEnumPin;
如果(!失败(pFilter->EnumPins(&pEnumPin)))
{
while(true)
{
//获取下一个pin码
//
CComPtrpPin;
如果(pEnumPin->Next(1L,&pPin,NULL)!=S_OK)中断;
//我对连接管脚不感兴趣
//如果此管脚是未连接的输出管脚,则渲染它。
//
CComPtrpConnectedPin;
如果(pPin->ConnectedTo(&pConnectedPin)=VFW\u E\u未连接)
{
销方向销方向;
PIN_INFO pinInfo;
//获取pin的信息
如果(pPin->QueryDirection(&pinDirection)==S\u正常
&&pinDirection==PINDIR\u输出
&&pPin->QueryPinInfo(&pinInfo)==S\u正常
&&strstr((char*)pinInfo.achName,“~”==NULL)
{
如果(失败(hr=m_pGB->渲染(pPin)))
{
安全释放(和pinInfo.pFilter);
返回人力资源;
}
}
安全释放(和pinInfo.pFilter);
}
}
}
TraceMsg(“%s:exit”,funcName);
返回S_OK;
}

当调用m_pGB->Render(pPin)时,此函数将永远不会返回,并且在内部被阻止。我使用日志进行了确认。只有在启动后立即启动应用程序时才会发生此问题。当我关闭并重新启动应用程序出现问题时,它就像一个魔咒。由于应用程序设计为在系统启动后自动启动,因此这种行为已成为一个更大的问题。请帮助IGraphBuilder。Render调用在内部做了很多工作,具体地说,它涉及到可能合适的筛选器的枚举,该筛选器反过来尝试加载在DirectShow环境中注册的其他DLL。这样的文件可能缺少依赖项,或者依赖于远程或暂时无法访问的驱动程序(仅举一个例子)

如果遇到死锁,可以进一步对其进行故障排除(调试),并获取有关锁定状态和渲染调用期间活动的详细信息

如果问题是由以不太好的方式向系统注册的第三方过滤器(特别是编解码器包,一次注册一组过滤器,而不考虑太多兼容性)引起的,您可能可以识别它们并卸载它们

如果您想改进您这边的播放器,您应该避免渲染调用,并以较小的增量构建过滤器图-添加特定的过滤器和连接管脚,而不让大任务任由Intelligent Connect摆布,Intelligent Connect通常运行良好,但对上述兼容性问题很敏感