mltframework / mlt

MLT Multimedia Framework
https://www.mltframework.org
GNU Lesser General Public License v2.1
1.48k stars 314 forks source link

Library FFTW's fftw_plan_dft_r2c_1d is not thread safe. #743

Open andre-caldas opened 2 years ago

andre-caldas commented 2 years ago

The only thread-safe function in FFTW is fftw_execute.

But the FFT filter calls fftw_plan_dft_r2c_1d. This makes MLT non-thread safe.

One solution for this problem is making programs linking to MLT call void fftw_make_planner_thread_safe(void);. Maybe, through some initialization method.

ddennedy commented 2 years ago

The way the framework is typically used (through a consumer based on mlt_consumer), this function is only called from one thread. If an app is going to read frames directly from a producer as we discussed on the forum, then it can do something to ensure only one thread is performing this task. That does not completely solve the case when the framework consumer is running and the app chooses to do something with the filter. We can add a mutex in the filter, or the app can stop the MLT consumer when it wants to run its task - perhaps in a manner to block restarting it such as from a modal dialog.