diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-08-14 13:11:34 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-08-14 13:11:34 -0400 |
commit | e6521bb0434d88802aa28e75235bc8c19ebb9262 (patch) | |
tree | 0563a81b0fd47bb20c415923a2e31a66201a25bd | |
parent | cc92c879bfd989aa8de25fdc29fb8d9b2ec7a992 (diff) | |
parent | 7a431f892ec6e7e2283885c474b680081c983762 (diff) |
Merge branch 'master' into cairocanvas
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 17 | ||||
-rw-r--r-- | gtk2_ardour/curvetest.cc | 5 | ||||
-rw-r--r-- | gtk2_ardour/main.cc | 13 | ||||
-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 | 24 | ||||
-rw-r--r-- | libs/pbd/enums.cc | 2 | ||||
-rw-r--r-- | libs/pbd/pbd.cc | 67 | ||||
-rw-r--r-- | libs/pbd/pbd/pbd.h | 30 | ||||
-rw-r--r-- | libs/pbd/wscript | 1 |
10 files changed, 151 insertions, 45 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 8cff860d16..81c15ead95 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -293,21 +293,10 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) /* lets get this party started */ - try { - if (ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization, localedir)) { - throw failed_constructor (); - } - - setup_gtk_ardour_enums (); - setup_profile (); + setup_gtk_ardour_enums (); + setup_profile (); - SessionEvent::create_per_thread_pool ("GUI", 512); - - } catch (failed_constructor& err) { - error << string_compose (_("could not initialize %1."), PROGRAM_NAME) << endmsg; - // pass it on up - throw; - } + SessionEvent::create_per_thread_pool ("GUI", 512); /* we like keyboards */ diff --git a/gtk2_ardour/curvetest.cc b/gtk2_ardour/curvetest.cc index b3431e3f39..818a010f1d 100644 --- a/gtk2_ardour/curvetest.cc +++ b/gtk2_ardour/curvetest.cc @@ -32,11 +32,6 @@ using namespace PBD; int curvetest (string filename) { - // needed to initialize ID objects/counter used - // by Curve et al. - - PBD::ID::init (); - ifstream in (filename.c_str()); stringstream line; //Evoral::Parameter param(GainAutomation, -1.0, +1.0, 0.0); diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 21e5343979..e619c9d83b 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -482,10 +482,6 @@ int main (int argc, char *argv[]) exit (1); } - if (curvetest_file) { - return curvetest (curvetest_file); - } - cout << PROGRAM_NAME << VERSIONSTRING << _(" (built using ") @@ -513,7 +509,14 @@ int main (int argc, char *argv[]) /* some GUI objects need this */ - PBD::ID::init (); + if (!ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization, localedir)) { + error << string_compose (_("could not initialize %1."), PROGRAM_NAME) << endmsg; + exit (1); + } + + if (curvetest_file) { + return curvetest (curvetest_file); + } if (::signal (SIGPIPE, sigpipe_handler)) { cerr << _("Cannot xinstall SIGPIPE error handler") << endl; diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 5f64c4b6a3..eaf6b572fd 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 4c91956ffd..986d320aef 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -50,8 +50,6 @@ #undef check /* stupid Apple and their un-namespaced, generic Carbon macros */ #endif -#include <giomm.h> - #include <glibmm/fileutils.h> #include <glibmm/miscutils.h> @@ -60,6 +58,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" @@ -107,6 +106,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; @@ -215,21 +216,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 (); @@ -269,7 +268,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); @@ -282,13 +281,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 @@ -331,7 +330,9 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir EventTypeMap::instance().new_parameter(EnvelopeAutomation); EventTypeMap::instance().new_parameter(MidiCCAutomation); - return 0; + libardour_initialized = true; + + return true; } void @@ -365,7 +366,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 bfa593aea3..219271a7e1 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); } } @@ -1901,7 +1915,7 @@ LV2Plugin::Impl::designated_input (const char* uri, void** bufptrs[], void** buf return port; } -static bool lv2_filter (const string& str, void *arg) +static bool lv2_filter (const string& str, void * /* arg*/) { /* Not a dotfile, has a prefix before a period, suffix is "lv2" */ diff --git a/libs/pbd/enums.cc b/libs/pbd/enums.cc index 7081503cb1..87e8da4b71 100644 --- a/libs/pbd/enums.cc +++ b/libs/pbd/enums.cc @@ -20,8 +20,6 @@ #include "pbd/controllable.h" #include "pbd/enumwriter.h" -void setup_libpbd_enums () __attribute__ ((constructor)); - using namespace PBD; using namespace std; diff --git a/libs/pbd/pbd.cc b/libs/pbd/pbd.cc new file mode 100644 index 0000000000..1bf977c90a --- /dev/null +++ b/libs/pbd/pbd.cc @@ -0,0 +1,67 @@ +/* + Copyright (C) 2011 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <iostream> +#include <cstdlib> + +#include <giomm.h> + +#include <glibmm/thread.h> + +#include "pbd/pbd.h" +#include "pbd/debug.h" +#include "pbd/id.h" +#include "pbd/enumwriter.h" + +#include "i18n.h" + +extern void setup_libpbd_enums (); + +namespace { + +static bool libpbd_initialized = false; + +} + +bool +PBD::init () +{ + if (libpbd_initialized) { + return true; + } + + if (!Glib::thread_supported()) { + Glib::thread_init(); + } + + Gio::init (); + + PBD::ID::init (); + + setup_libpbd_enums (); + + libpbd_initialized = true; + return true; +} + +void +PBD::cleanup () +{ + EnumWriter::destroy (); +} diff --git a/libs/pbd/pbd/pbd.h b/libs/pbd/pbd/pbd.h new file mode 100644 index 0000000000..5b3745f0ed --- /dev/null +++ b/libs/pbd/pbd/pbd.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2011 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __libpbd_pbd_h__ +#define __libpbd_pbd_h__ + +namespace PBD { + + bool init (); + void cleanup (); + +} // namespace PBD + +#endif diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 0655e1ca48..ffbe0e0d19 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -56,6 +56,7 @@ libpbd_sources = [ 'openuri.cc', 'pathexpand.cc', 'pathscanner.cc', + 'pbd.cc', 'pool.cc', 'property_list.cc', 'pthread_utils.cc', |