본문 바로가기

IT/Multimedia

[펌]DirectShow & DirectX - Debug 중 "Protection Error"를 만나다!

DirectShow & DirectX - Debug 중 "Protection Error"를 만나다!

    진행중인 프로젝트에서 캡처 보드로 부터의 영상을 프로그램에 보여주기 위한 모듈을 별도의 dll로 제작하였다.

    하나의 View만 사용할 때는 문제가 없다가 동시에 두개 이상의 View를 보여주기 위해 dll을 수정하고 디버깅을 하던중 다음의 창을 보게 되었다.


    첫번째 View를 초기화 완료하고 두번째 View를 똑같은 과정으로 초기화 하는중에 영상 출력 Graph를 생성하는 루틴에서 문제의 다음 창과 조우하였다.


    사용자 삽입 이미지



    이 문제와 관련은 없지만 참고로 DirectShow나 DirectX의 Dubug용 Library를 로드하기 위해서는 다음의 함수를 사용해야 한다.

    (그러나 아래 설명에서 처럼 대부분의 DirectShow 응용 프로그램이 Strmbase.lib 을 사용하기 때문에 별도로 DbgInitialise를 할 필요는 없어 보인다.)


    DbgInitialise


    Initializes the debug library. Ignored in retail builds.

    Syntax

    void DbgInitialise(
        HINSTANCE hInst
    );

    Parameters

    hInst

    Handle to the module instance.

    Remarks

    In an executable, call this method before using the DirectShow debug facilities. Before the executable quits, call the DbgTerminate function to clean up the debug library.

    In a DLL that links to the base-class library (Strmbase.lib), it is not necessary to call this function. The function is called automatically when the DLL is loaded.


    구체적으로 다음의 함수에서 Protection Error가 발생했다.


    ICaptureGraphBuilder2::RenderStream


    The RenderStream method connects an output pin on a source filter to a sink filter, optionally through an intermediate filter.

    Syntax

    HRESULT RenderStream(
      const GUID *pCategory,
      const GUID *pType,
      IUnknown *pSource,
      IBaseFilter *pIntermediate,
      IBaseFilter *pSink
    );

    이유는 ....


    헉 ㅠ.ㅠ; USB PC 카메라들을 사용하여 테스트하고 있는데, PC에 연결되지 않은 카메라(두번째 View) Driver를 사용하여 Graph 필터를 만들려고 해서 발생한 문제였다. PC에 해당 카메라를 연결하니 바로 해결되었다.


    뭐 ... --; 이런 경우에도 Protection Error가 발생할 수 있음을 기억하자...


    그럼 추가로 구글링을 해볼까?!


    Keyword : DirectShow Protection Error


    Visual Studion 2005 Debugger Halts on DirectShow mixed debugging - Graph Filter들 중에 Debugger가 활성화 되어 있는지 체크하는 Filter가 있기때문 이다는 요지이다. 따라서 해당 필터(Nero Digital AVC Video Enc) 를 제거해줌으로서(--;) 문제를 해결하였다고 한다.


    그외 대부분 일부 filter때문이라는 비슷한 의견이다.


원본 위치 <http://www.codeforum.net/blog/pitoosung/category/프로그래밍?page=2&TSSESSION=26b94d00515facab38d5e38c674a88d6>