From 9d340af10da0bdb4e20681918dac6dde987c8e5e Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Thu, 25 Jul 2013 21:38:59 +1000 Subject: Prevent libardour from being initialized more than once This is not thread safe of course, it is not intended to be. This was implemented as at one stage ARDOUR::init was being called multiple times in the testsuite which was causing a subtle bug that took some time to track down. --- libs/ardour/globals.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libs/ardour/globals.cc') diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 5e3553ad8a..78994c4101 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -107,6 +107,8 @@ using namespace ARDOUR; using namespace std; using namespace PBD; +bool libardour_initialized = false; + compute_peak_t ARDOUR::compute_peak = 0; find_peaks_t ARDOUR::find_peaks = 0; apply_gain_to_buffer_t ARDOUR::apply_gain_to_buffer = 0; @@ -218,6 +220,10 @@ lotsa_files_please () bool ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir) { + if (libardour_initialized) { + return true; + } + if (!Glib::thread_supported()) { Glib::thread_init(); } @@ -331,6 +337,8 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir EventTypeMap::instance().new_parameter(EnvelopeAutomation); EventTypeMap::instance().new_parameter(MidiCCAutomation); + libardour_initialized = true; + return true; } -- cgit v1.2.3