sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 641 forks source link

Cannot play video after some time #953

Closed astrowalker closed 6 years ago

astrowalker commented 6 years ago

What I do

I load movie to media engine and wait some time (displaying static screen with text), after 10 seconds, a minute or two, I start playback (Play in media engine).

What happens

When the time is short (like 10 seconds), everything is fine.

When the time is longer (say one minute) program crashes because of the unhandled exception:

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.Threading.Thread' to type 'SharpDX.ComObjectShadow'.
   at SharpDX.CppObjectShadow.ToShadow[T](IntPtr thisPtr)
   at SharpDX.ComObjectShadow.ComObjectVtbl.AddRefImpl(IntPtr thisObject)

When the time is even longer (say 2 minutes) I got decoding error from media engine (error=3) -- I check for errors when OnVideoStreamTick returns false.

I don't use any threads/tasks, anything fancy. My "waiting" is running RenderLoop and checking constantly how much time passed.

Environment

Windows 10, VS 2015, SharpDX 4.0.1 (I also tested 4.1.0-ci184, same effects).

astrowalker commented 6 years ago

My mistake, the waiting period and the text on the welcome screen (before movie) is displayed according to configuration. I don't entirely understand it, but anyway, ConfigurationSection and alike types are not thread-safe, I assume since I only read (at start) configuration files and I have single thread, everything is OK. Apparently not -- after storing configs in local data everything works.