Video doesn't play in Windows VST

#1

Greetings,

I am playing video within an application I’m developing. The video runs perfect in Mac standalone, Mac plugin formats and Windows standalone. However, when testing in Windows VST, I am getting a crash deep within the windows video code. The video is played with JUCEs VideoComponent class. I can see the video begin to play for a split second, then it crashes on this call:

    while (SUCCEEDED (mediaEvent->GetEvent (&ec, &p1, &p2, 0)))
    {
        mediaEvent->FreeEventParams (ec, p1, p2);

        switch (ec)
        {
        case EC_REPAINT:
            component.repaint();
            break;

        case EC_COMPLETE:
            component.stop();
            break;

        case EC_USERABORT:
        case EC_ERRORABORT:
        case EC_ERRORABORTEX:
            component.close();
            break;

        default:
            break;
        }
    }
}

mediaEvent is NULL. In fact, looking a step up:

    static LRESULT CALLBACK wndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        if (auto* c = (DirectShowContext*) GetWindowLongPtr (hwnd, GWLP_USERDATA))
        {
            switch (msg)
            {
                case WM_NCHITTEST:          return HTTRANSPARENT;
                case WM_ERASEBKGND:         return 1;
                case WM_DISPLAYCHANGE:      c->displayResolutionChanged(); break;
                case graphEventID:          c->graphEventProc(); return 0;
                default:                    break;
            }
        }

        return DefWindowProc (hwnd, msg, wParam, lParam);
    }

all the fields within the DirectShowContext* c, are NULL.

As i said before, the video runs fine in Windows Media Player and even runs fine in a Windows standalone version of the application I’m developing.

This seems like a pretty deep issue, so, I wanted to post to see if playing videos within a Windows VST was even possible to begin with. Some more specs:

Movie file type: .wmv
VST in Ableton 9
Windows 7 Professional 64-Bit

There seems to be problems with playing videos in Windows VST in general. I tried another case using a WebComponent to play a video with both the iframe and video tags, neither of which were able to play the video in the VST but played in my Windows browser just fine.

Does anyone know if it should be possible to play videos in Windows VST, or, will it never work?

Thanks,

Collin

1 Like

#2

To follow up on Collin’s post, we discovered that if EC_USERABORT, EC_ERRORABORT, or EC_ERRORABORTEX events are processed by this loop, calling component.close() will result in mediaEvent being set to nullptr. In the next run of the loop, mediaEvent->GetEvent() is called, but since mediaEvent is null this naturally causes a memory access exception and crash.

This is easy to remedy by changing the code so that EC_USERABORT, EC_ERRORABORT, or EC_ERRORABORTEX events also break the while loop.

However we also discovered that these events may materialize in situations where you might not want to completely abort playing the video, e.g. if the audio driver is in exclusive mode or there is a recoverable video error (e.g. a single corrupt video frame in an otherwise playable stream).

In any case, the crash should be easy to fix and we would be happy to submit a PR if desired.

0 Likes