diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/ardour.h | 10 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 27 | ||||
-rw-r--r-- | libs/ardour/lv2_plugin.cc | 22 |
3 files changed, 41 insertions, 18 deletions
diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 73413c4cc2..311611997f 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -50,7 +50,15 @@ namespace ARDOUR { extern PBD::Signal1<void,std::string> BootMessage; extern PBD::Signal0<void> GUIIdle; - int init (bool with_vst, bool try_optimization, const char* localedir); + /** + * @param with_vst true to enable VST Support + * @param try_optimization true to enable hardware optimized routines + * for mixing, finding peak values etc. + * @param localedir Directory to look for localisation files + * + * @return true if Ardour library was successfully initialized + */ + bool init (bool with_vst, bool try_optimization, const char* localedir); void init_post_engine (); int cleanup (); bool no_auto_connect (); diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 4e99bc767e..aac7709f90 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -51,8 +51,6 @@ #undef check /* stupid Apple and their un-namespaced, generic Carbon macros */ #endif -#include <giomm.h> - #include <glibmm/fileutils.h> #include <glibmm/miscutils.h> @@ -61,6 +59,7 @@ #include "pbd/cpus.h" #include "pbd/error.h" #include "pbd/id.h" +#include "pbd/pbd.h" #include "pbd/strsplit.h" #include "pbd/fpu.h" #include "pbd/file_utils.h" @@ -109,6 +108,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; @@ -217,21 +218,19 @@ lotsa_files_please () } } -int +bool ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir) { - if (!Glib::thread_supported()) { - Glib::thread_init(); + if (libardour_initialized) { + return true; } - // this really should be in PBD::init..if there was one - Gio::init (); + if (!PBD::init()) return false; #ifdef ENABLE_NLS (void) bindtextdomain(PACKAGE, localedir); #endif - PBD::ID::init (); SessionEvent::init_event_pool (); SessionObject::make_property_quarks (); @@ -271,7 +270,7 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir Config = new RCConfiguration; if (Config->load_state ()) { - return -1; + return false; } Config->set_use_windows_vst (use_windows_vst); @@ -284,13 +283,13 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir #ifdef WINDOWS_VST_SUPPORT if (Config->get_use_windows_vst() && fst_init (0)) { - return -1; + return false; } #endif #ifdef LXVST_SUPPORT if (Config->get_use_lxvst() && vstfx_init (0)) { - return -1; + return false; } #endif @@ -335,7 +334,9 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir ARDOUR::AudioEngine::create (); - return 0; + libardour_initialized = true; + + return true; } void @@ -366,7 +367,7 @@ ARDOUR::cleanup () #ifdef LXVST_SUPPORT vstfx_exit(); #endif - EnumWriter::destroy (); + PBD::cleanup (); return 0; } diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 95a29b7c8f..220ef9ca80 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1137,8 +1137,20 @@ LV2Plugin::write_from_ui(uint32_t index, const uint8_t* body) { if (!_from_ui) { - _from_ui = new RingBuffer<uint8_t>( - _session.engine().raw_buffer_size(DataType::MIDI) * NBUFS); + size_t rbs = _session.engine().raw_buffer_size(DataType::MIDI) * NBUFS; + /* buffer data communication from plugin UI to plugin instance. + * this buffer needs to potentially hold + * (port's minimumSize) * (audio-periods) / (UI-periods) + * bytes. + * + * e.g 48kSPS / 128fpp -> audio-periods = 375 Hz + * ui-periods = 25 Hz (SuperRapidScreenUpdate) + * default minimumSize = 32K (see LV2Plugin::allocate_atom_event_buffers() + * -> 15 * 32K + * it is safe to overflow (but the plugin state may be inconsistent). + */ + rbs = max((size_t) 32768 * 6, rbs); + _from_ui = new RingBuffer<uint8_t>(rbs); } if (!write_to(_from_ui, index, protocol, size, body)) { @@ -1165,8 +1177,10 @@ void LV2Plugin::enable_ui_emmission() { if (!_to_ui) { - _to_ui = new RingBuffer<uint8_t>( - _session.engine().raw_buffer_size(DataType::MIDI) * NBUFS); + /* see note in LV2Plugin::write_from_ui() */ + size_t rbs = _session.engine().raw_buffer_size(DataType::MIDI) * NBUFS; + rbs = max((size_t) 32768 * 8, rbs); + _to_ui = new RingBuffer<uint8_t>(rbs); } } |