locked
PlayToSource->Next problems (two problems, unknown if related)

    Question

  • I'm encountering an error that sporadically occurs when switching from one video to the next using PlayTo.  I set the Next using (basically):

    MyMediaElementA->PlayToSource->Next = MyMediaElementB->PlayToSource;

    This frequently works, but sometimes instead of playing one video then the next, it plays the first video, then a few frames of the second video, and then switches back to the first video.  I tried using the sample PlayTo Receiver app in debug mode, and got the following errors:

    First-chance exception at 0x777E4B32 (KernelBase.dll) in PlayToreceiver.exe: 0x000006F7: The stub received bad data.
    First-chance exception at 0x777E4B32 in PlayToreceiver.exe: Microsoft C++ exception: _com_error at memory location 0x03A9F068.

    Any idea what is causing this, and how I can fix it?

    Second problem:

    If I use PlayTo first without a Next, and then start again with a second video, I get a "null pointer error" at the same line:

    First-chance exception at 0x5AC1DF48 (Windows.UI.Xaml.dll) in DraftUX.exe: 0xC0000005: Access violation reading location 0x00000000.
    Unhandled exception at 0x5AC1DF48 (Windows.UI.Xaml.dll) in DraftUX.exe: 0xC0000005: Access violation reading location 0x00000000.

    I have checked the variables I'm using on that line, and the only thing I can find with the value nullptr is the property Next, which is what I'm trying to set.  Looking at the stack trace, the NPE is actually happening in code that is not mine:

    Not Flagged > 6660 0 Worker Thread SHCore.dll!_SHWaitForThreadWithWakeMask@12() Windows.UI.Xaml.dll!MediaEngineHost::SwapMediaEngine Normal
    Windows.UI.Xaml.dll!MediaEngineHost::SwapMediaEngine(struct IMFMediaEngineEx *)
    Windows.UI.Xaml.dll!MediaEngineHost::Connect(struct IMFSharingEngineClassFactory *)
    Windows.UI.Xaml.dll!MediaEngineHost::MediaEngineNotify::Connect(struct IMFSharingEngineClassFactory *)
    MFMediaEngine.dll!CPlayToSource::_ConnectWithLockReleased(struct ISharedRenderer *,bool)
    MFMediaEngine.dll!CPlayToSource::ConnectPreroll(struct ISharedRenderer *)
    MFMediaEngine.dll!CPlayToSource::put_Next(struct Windows::Media::PlayTo::IPlayToSource *)
    (stack trace enters my code here)

    Again, if you know what is going on and how I can fix this, I'd appreciate suggestions.  Thanks!

    Cheers,
    Andrea

                       

    Andrea Mantler


    • Edited by Andrea Mantler Wednesday, January 09, 2013 11:21 PM removed some extra spaces
    Wednesday, January 09, 2013 11:20 PM

All replies

  • It sounds like there is a problem with queuing of the 2 videos in your application. Can you take a look at this quickstart sample: http://aka.ms/j2jvzn and see if it helps? The quickstart sample queues images, but you can tweak it to change to video if you want and see if that takes care of the problem.

    Maybe the following statement in the quickstart sample applies to your scenario as well regarding the NULL pointer exception, so you can see if you are running into that same issue and follow a similar approach.

    "Because image objects are created and destroyed for each image of the slide show, we use a temporary image object that is never destroyed in the SourceRequested event. This is because we do not know if the timeout will expire before the user selects a Play To receiver. If that occurred, then the current image would be destroyed and we would pass a null reference to Play To. Instead, we pass Play To a reference to image object that is never destroyed and update the image source to the currently displayed image once the user selects a Play To receiver. We know that has occurred when the state of the image changes to Connected."

    If that still does not help, can you upload your project that reproduces the issue to a location (maybe SkyDrive?) and I can take a look.

    Thanks,

    Prashant.

    Friday, January 11, 2013 8:13 PM
    Moderator
  • Thanks!  I started having another look at that example on Friday, and intended to get back to it today, but my priorities got shuffled, and I won't be back to this for a b it.  I will be back eventually, though, and let you know if that answers my question, or if things still aren't working.

    Thanks!
    Andrea


    Andrea Mantler

    Monday, January 14, 2013 8:23 PM
  • So, that isn't the issue.  I had read that quickstart before, and went back and re-read it now, but it hasn't solved my problem.  Neither of the MediaElements are null, both of their sources are set and so their PlayToSources exist and are non-null.  The problem seems to be sporadic, and unrelated to anything I'm doing.  I've been doing lots of testing the last few days, and, even though I repeat the same steps, sometimes I get the null pointer error, and sometimes I don't.  The call stack above where I set the MediaElement PlayToSource->Next is always:

    Windows.UI.Xaml.dll!MediaEngineHost::SwapMediaEngine(IMFMediaEngineEx * pNewEngine) Line 4268 C++
    Windows.UI.Xaml.dll!MediaEngineHost::Connect(IMFSharingEngineClassFactory * pFactory) Line 4152 C++
    MFMediaEngine.dll!CPlayToSource::_ConnectWithLockReleased(struct ISharedRenderer *,bool) Unknown
    MFMediaEngine.dll!CPlayToSource::ConnectPreroll(struct ISharedRenderer *) Unknown
    MFMediaEngine.dll!CPlayToSource::put_Next(struct Windows::Media::PlayTo::IPlayToSource *) Unknown
    MyProgram.exe!Windows::Media::PlayTo::IPlayToSource::Next::set(Windows::Media::PlayTo::PlayToSource ^ __param0) C++

    The order of events is:

    current player transitions from disconnected to connected
    next player transitions  from disconnected to connected
    current player transitions form connected to rendering
    playto is transferred
    the (now) previous (formerly current) player transitions from rendering to disconnected
    I try to hook up the new current (formerly next) player's PlayToSource->Next to the new next player's PlayToSource, and, despite the fact that it's still playing (I've been using 2 minute videos for this test, to be on the safe side), I get the "Access violation reading location 0x0000000000000000."

    The call stack places the NPE inside calls made from the Next::set method, so I think the problem is somewhere in there, rather than my code.  Is there anything I can do, besides assume that PlayToSource->Next is unreliable?

    Thanks!

          

    Andrea Mantler

    Friday, July 19, 2013 12:17 AM