VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / utils / ThreadSafeFFTW.hpp
blob15cd6913162757f322b7042a8a7da39dc1895399
1 /*
2 * Thread-safe fftw
3 * Copyright (C) 2018-2022 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef THREAD_SAFE_FFTW_HPP_INCLUDED
19 #define THREAD_SAFE_FFTW_HPP_INCLUDED
21 #include "CarlaDefines.h"
23 #ifdef CARLA_OS_UNIX
24 // --------------------------------------------------------------------------------------------------------------------
25 // Thread-safe fftw
27 #include "CarlaLibUtils.hpp"
29 class ThreadSafeFFTW
31 public:
32 typedef void (*void_func)(void);
34 ThreadSafeFFTW()
35 : libfftw3(nullptr),
36 libfftw3f(nullptr),
37 libfftw3l(nullptr),
38 libfftw3q(nullptr)
40 if ((libfftw3 = lib_open("libfftw3_threads.so.3")) != nullptr)
41 if (const void_func func = lib_symbol<void_func>(libfftw3, "fftw_make_planner_thread_safe"))
42 func();
44 if ((libfftw3f = lib_open("libfftw3f_threads.so.3")) != nullptr)
45 if (const void_func func = lib_symbol<void_func>(libfftw3f, "fftwf_make_planner_thread_safe"))
46 func();
48 if ((libfftw3l = lib_open("libfftw3l_threads.so.3")) != nullptr)
49 if (const void_func func = lib_symbol<void_func>(libfftw3l, "fftwl_make_planner_thread_safe"))
50 func();
52 if ((libfftw3q = lib_open("libfftw3q_threads.so.3")) != nullptr)
53 if (const void_func func = lib_symbol<void_func>(libfftw3q, "fftwq_make_planner_thread_safe"))
54 func();
57 ~ThreadSafeFFTW()
59 if (libfftw3 != nullptr)
61 lib_close(libfftw3);
62 libfftw3 = nullptr;
65 if (libfftw3f != nullptr)
67 lib_close(libfftw3f);
68 libfftw3f = nullptr;
71 if (libfftw3l != nullptr)
73 lib_close(libfftw3l);
74 libfftw3l = nullptr;
77 if (libfftw3q != nullptr)
79 lib_close(libfftw3q);
80 libfftw3q = nullptr;
84 private:
85 lib_t libfftw3;
86 lib_t libfftw3f;
87 lib_t libfftw3l;
88 lib_t libfftw3q;
90 CARLA_DECLARE_NON_COPYABLE(ThreadSafeFFTW)
92 #endif
94 // --------------------------------------------------------------------------------------------------------------------
96 #endif // THREAD_SAFE_FFTW_HPP_INCLUDED