locked
Problem with start MFMediaSession twice. RRS feed

  • Question

  • I am developing a custom sink filter.

    I have a problem with runing media session twice in topoedit. I get "Error handling media event" after second start.

    Trying to find out the point, I've builded a Media Foundation WavSink and WriteWavFile samples.

    And I've modifyed WriteWavFile as follows to start media session twice :

    In main.cpp's function RunMediaSession() I've replaced MESessionStopped handler event

      case MESessionStopped:
      TRACE((L"MESessionStopped"));
      wprintf(L"Attempting rerun the media session.\n");

      PROPVARIANT var;
      var.vt = VT_I8;
      var.hVal.QuadPart = 0;
      hr = pSession->Start( NULL, &var );

      break;

    I was expecting media session to start twice, but I after this code worked out I get a Media Event with

      hrStatus  = -1072875854

    Am I doing somthing wrong? What does it mean hrStatus  = -1072875854? Does wav sink filter support multiply start?

    ps: used topology: [WavSourceSample] -> [WavSinkSample].

    Sanks.


    Fed)'io
    Thursday, May 21, 2009 8:37 AM

Answers

  • -1072875854 = c00d36b2 = MF_E_INVALIDREQUEST.

    This is a generic 'function call not valid in the current state' error.  You might get this error if you try to call Start without a topology, or trying to call Start after a sink has been finalized.

    In this case, the error is sent by the WavSink sample.  On a start after stop, sinks are reinitialized with the current media type.  The WavSink returns MF_E_INVALIDREQUEST if a media type is set after it starts for the first time.  The WavSink does not support format changes so this is generally a good thing, but ideally it would accept setting the same type again. 

    You can fix this yourself in CWavStream::SetCurrentMediaType -- before ValidateOperation, check if there is a current type.  If there is, use the IMFMediaType::IsEqual function to compare the current type with the input type.  If it returns S_OK, the media types are identical and SetCurrentMediaType can return S_OK.

    Hope this helps.
    Tuesday, June 2, 2009 9:31 PM