SetD3DDevice hangs when playing some video files. (m_staticLock problem)

Aug 10, 2014 at 10:02 AM
Some video files I play hang in the VMR9Allocator (see below).
All I see is a black Window, no error notifications are sent to MediaURIPlayer.
When this happens, all other video files fail to play afterwards because m_staticLock is locked by the lock (m_staticLock){} line in InitializeDevice()
If I try playing another video in a new MediaURIPlayer instance, that also fails (due to m_staticLock).
I have to restart the application to get MediaURIPlayer playing video's again.
Funny thing is, if I play a good video first, then a video that causes the hang, sometimes it plays fine! If I close it and play it again, it hangs. Have to restart the app..

I checked the pointers pDevice and pMonitor, they are not null, the pointer address matches previous calls to InitializeDevice()

Quick Fix:
If I remove the "lock (m_staticLock)" line, other files now play fine afterwards. No need to restart the app.
But I don't know if this will cause problems or leaks though...

Source: VMR9Allocator.cs
Function: InitializeDevice(IntPtr userId, ref VMR9AllocationInfo lpAllocInfo, ref int lpNumBuffers)
             lock (m_staticLock) // COMMENT THIS LINE OUT
                    /* These two pointers are passed to the the helper
                     * to create our D3D surfaces */
                    Debug("InitializeDevice GetPointers......");
                    var pDevice = GetComPointer(m_device);
                    var pMonitor = GetAdapterMonitor(0);
                    /* Setup our D3D Device with our renderer */
                    hr = m_allocatorNotify.SetD3DDevice(pDevice, pMonitor); // <<< HANG