0

WPFで拡張ビデオレンダラーを使用していますが、IEVRPresenterRegisterCallbackのインスタンスを作成すると、D3DERR_DRIVERINVALIDCALLという迷惑なエラーが発生することがあります。

MVVMデザインを使用して、ビューを切り替えると... 1つのビューには、特にこのプレゼンターが内部にあります...ビューを切り替えるときに約80%の時間実行されます。ビューを閉じると、すべてが破棄されます...同じビューに戻ると、オブジェクトが再作成されます。

問題は時々それがうまくいくことです...そして私は原因を突き止めましたが、解決策を見つけることができません。

        int hr;
        object comObject;
        Exception exception = null;

        // A COM object we query form our native library.
        IClassFactory factory = null;

        // Create our 'helper' class.
        var evrPresenter = new EVRPresenter();

        // Call the DLL export to create the class factory.
        if (ProcessBits == 64)
        {
            hr = DllGetClassObject64(EVR_PRESENTER_CLSID, IUNKNOWN_GUID, out comObject);
        }
        else
        {
            exception = new Exception(string.Format("{0} bit processes are unsupported", ProcessBits));
            goto bottom;
        }

        // Check if our call to our DLL failed.
        if (hr != 0 || comObject == null)
        {
            exception = new COMException("Could not create a new class factory.", hr);
            goto bottom;
        }

        // Cast the COM object that was returned to a COM interface type.
        factory = comObject as IClassFactory;

        if (factory == null)
        {
            exception = new Exception("Could not QueryInterface for the IClassFactory interface.");
            goto bottom;
        }

        // Get the GUID of the IMFVideoPresenter.
        Guid guidVideoPresenter = typeof(IMFVideoPresenter).GUID;

        // Creates a new instance of the IMFVideoPresenter.
        hr = factory.CreateInstance(null, ref guidVideoPresenter, out comObject);

        // QueryInterface for the IMFVideoPresenter.
        var presenter = comObject as IMFVideoPresenter;

        // QueryInterface for our callback registration interface.
        var registerCb = comObject as IEVRPresenterRegisterCallback;

        if (registerCb == null)
        {
            exception = new Exception("Could not QueryInterface for IEVRPresenterRegisterCallback.");
            goto bottom;
        }

        // Register the callback to the 'helper' class.
        registerCb.RegisterCallback(evrPresenter);

        // Populate the IMFVideoPresenter.
        evrPresenter.VideoPresenter = presenter;

    bottom:
        if (factory != null)
        {
            Marshal.FinalReleaseComObject(factory);
        }

        if (exception != null)
        {
            throw exception;
        }

        return evrPresenter;

facotry.CreateInstance(null、ref guidVideoPresenter、out comObject)が実行されると... comObjectはほとんどの場合IEVRPresenterRegisterCallbackを返しますが、それ以外の場合はnullを吐き出し、HRESULTはD3DERR_DRIVERINVALIDCALLであるため、非常にあいまいなエラーコードになります。

これが発生すると、アプリケーションは最終的に例外をキャッチし、ビデオを表示せずに続行します。

このタイプのデザインでこれまでにこのようなものを見た人はいますか?

乾杯。

4

0 に答える 0