Log in

View Full Version : Using Avisynth in a multithreaded application


omion
3rd April 2008, 09:53
I'm writing a program that will access multiple parts of one AVS file. Each thread has its own "AVIStreamOpenFromFile" call, and since there is no shared data, I figured that using a single-threaded DLL should work fine. That appears to not be the case, though...

Whenever I use the official single-threaded DLL, the program crashes after a short time. The multi-threaded DLL (from MT) seems to work fine, though. (I'm using the VfW interface, although the direct C-interface had a similar problem...)

Is there any reason that this shouldn't work? Surely, I can access the same DLL from multiple processes at the same time, so why shouldn't I be able to use it multiple times in the same process?

The other possibility is that, since I'm writing my own custom translation to the OCaml language, that code may be doing weird things. I suppose I just want to know if what I'm trying to do should be possible with the standard library.

tsp
3rd April 2008, 21:50
You can use avisynth in multiple processes at the same time because each process has it own seperate memory. the standard version of avisynt stores the framebuffers in a linked list to prevent to much memory allocation but the management of the list inside avisynth is not threadsafe so concurrent access from the same process can trigger a crash. This should be fixed in the avisynth.dll included in MT.

omion
3rd April 2008, 23:49
Thanks for the response. I thought there had to be something like that.