The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL from .Net C++ WinForms - threading issue
awdorrin


Joined: 17 Jun 2016
Posts: 2
I have been working on building a video player object that I can embed into a .Net application.
The intent is for a component that I can drop on a C# form.
Currently using a .Net C++ (managed) dll to call a native C++ class that interfaces to SDL and FFMPEG.

I am passing in a handle of a windows forms panel into the .Net DLL class and using SetWindowPos() and SetParent() to get the SDL window in the correct location.

Things were working well, but I had the decoding/rendering loop launched from a form button, which meant it was on the GUI thread.
I then moved the decoding/rendering code into its own thread, and ran into some issues.

I can move the window around the screen and the video keeps playing, but the moment I try to resize the video frame, the video stops playing.
The last frame displayed will resize as the window is resized, but no more video updates.

Interesting thing is, if I put break points in the decoding/rendering thread, it is still chugging away and runs until it reaches the end of the video file.

I believe this is some sort of cross-thread conflict, but I'm stumped as to what the cause might be.

Any ideas would be greatly appreciated!

Thanks
-Al
awdorrin


Joined: 17 Jun 2016
Posts: 2
So over 1000 views, yet not one suggestion...

Seems this has something to do with how SDL implements its threads.
I am guessing that by I creating an instance of a window/renderer in one thread, and try to then use (update) in another thread, the bug rears its head.

No offense to the developers of SDL, but it seems that SDL is not the right tool for the job...