From c86210a9d5bdb7b36ad58552a1f99f53d48781b3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 10 Sep 2008 21:27:39 +0000 Subject: merge 2.0-ongoing into 3.0 @ 3581 - 3710 git-svn-id: svn://localhost/ardour2/branches/3.0@3712 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/lv2_plugin.h | 17 +++++++++--- libs/ardour/ardour/region.h | 2 +- libs/ardour/audio_unit.cc | 13 +++++++-- libs/ardour/audioengine.cc | 59 +++++++++++++++++++++++++---------------- libs/ardour/lv2_plugin.cc | 39 ++++++++++++++++++++++++--- libs/ardour/rb_effect.cc | 32 +++++++++++++++------- libs/ardour/region.cc | 2 +- libs/ardour/sndfilesource.cc | 12 ++++++--- 8 files changed, 129 insertions(+), 47 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index d20ece65bd..b3711c5588 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -60,9 +60,14 @@ class LV2Plugin : public ARDOUR::Plugin int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const; uint32_t nth_parameter (uint32_t port, bool& ok) const; + const void* extension_data(const char* uri) { return _instance->lv2_descriptor->extension_data(uri); } + SLV2Plugin slv2_plugin() { return _plugin; } + SLV2UI slv2_ui() { return _ui; } SLV2Port slv2_port(uint32_t i) { return slv2_plugin_get_port_by_index(_plugin, i); } + const LV2_Feature* const* features() { return _features; } + std::set automatable() const; void activate () { @@ -104,14 +109,14 @@ class LV2Plugin : public ARDOUR::Plugin int set_state(const XMLNode& node); bool save_preset(std::string name); - bool has_editor() const { return false; } + bool has_editor() const; - int require_output_streams (uint32_t); - private: void* _module; LV2World& _world; + LV2_Feature** _features; SLV2Plugin _plugin; + SLV2UI _ui; SLV2Value _name; SLV2Value _author; SLV2Instance _instance; @@ -123,6 +128,11 @@ class LV2Plugin : public ARDOUR::Plugin bool _was_activated; vector _port_is_input; + typedef struct { const void* (*extension_data)(const char* uri); } LV2_DataAccess; + LV2_DataAccess _data_access_extension_data; + LV2_Feature _data_access_feature; + LV2_Feature _instance_access_feature; + void init (LV2World& world, SLV2Plugin plugin, nframes_t rate); void run (nframes_t nsamples); void latency_compute_run (); @@ -149,6 +159,7 @@ struct LV2World { SLV2Value integer; SLV2Value toggled; SLV2Value srate; + SLV2Value gtk_gui; }; diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 00315846b2..32f47d42d7 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -217,7 +217,7 @@ class Region : public Automatable, public boost::enable_shared_from_this const SourceList& master_sources() const { return _master_sources; } std::vector master_source_names(); - void set_master_sources (SourceList&); + void set_master_sources (const SourceList&); /* serialization */ diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 4862ddcd12..9c7ea0f13f 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -1081,10 +1081,19 @@ AUPluginInfo::cached_io_configuration (const std::string& unique_id, ARDOUR::BootMessage (string_compose (_("Checking AudioUnit: %1"), name)); - if (CAAudioUnit::Open (comp, unit) != noErr) { + try { + + if (CAAudioUnit::Open (comp, unit) != noErr) { + return false; + } + + } catch (...) { + + warning << string_compose (_("Could not load AU plugin %1 - ignored"), name) << endmsg; return false; - } + } + if ((ret = unit.GetChannelInfo (&channel_info, cnt)) < 0) { return false; } diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 76c0de9b24..6a76e98c3c 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -95,6 +95,7 @@ AudioEngine::~AudioEngine () if (_running) { jack_client_close (_jack); + _jack = 0; } stop_metering_thread (); @@ -121,6 +122,11 @@ _thread_init_callback (void *arg) int AudioEngine::start () { + if (!_jack) { + error << _("AudioEngine::start() called while disconnected from JACK") << endmsg; + return -1; + } + if (!_running) { if (session) { @@ -179,17 +185,13 @@ AudioEngine::start () int AudioEngine::stop (bool forever) { - if (_running) { - _running = false; - stop_metering_thread (); + if (_jack) { if (forever) { - jack_client_t* foo = _jack; - _jack = 0; - jack_client_close (foo); + disconnect_from_jack (); } else { jack_deactivate (_jack); + Stopped(); /* EMIT SIGNAL */ } - Stopped(); /* EMIT SIGNAL */ } return _running ? -1 : 0; @@ -204,11 +206,13 @@ AudioEngine::get_sync_offset (nframes_t& offset) const jack_position_t pos; - (void) jack_transport_query (_jack, &pos); - - if (pos.valid & JackVideoFrameOffset) { - offset = pos.video_offset; - return true; + if (_jack) { + (void) jack_transport_query (_jack, &pos); + + if (pos.valid & JackVideoFrameOffset) { + offset = pos.video_offset; + return true; + } } #endif @@ -252,7 +256,7 @@ int AudioEngine::_xrun_callback (void *arg) { AudioEngine* ae = static_cast (arg); - if (ae->jack()) { + if (ae->connected()) { ae->Xrun (); /* EMIT SIGNAL */ } return 0; @@ -262,7 +266,7 @@ int AudioEngine::_graph_order_callback (void *arg) { AudioEngine* ae = static_cast (arg); - if (ae->jack()) { + if (ae->connected()) { ae->GraphReordered (); /* EMIT SIGNAL */ } return 0; @@ -894,7 +898,8 @@ AudioEngine::halted (void *arg) ae->_running = false; ae->_buffer_size = 0; ae->_frame_rate = 0; - ae->_jack = 0; + + cerr << "!!! HALTED !!!\n"; if (was_running) { ae->Halted(); /* EMIT SIGNAL */ @@ -1067,7 +1072,6 @@ AudioEngine::update_total_latency (const Port& port) void AudioEngine::transport_stop () { - // cerr << "tell JACK to stop\n"; if (_jack) { jack_transport_stop (_jack); } @@ -1211,7 +1215,7 @@ AudioEngine::connect_to_jack (string client_name) { jack_client_name = client_name; - if ((_jack = jack_client_new (client_name.c_str())) == NULL) { + if ((_jack = jack_client_new (client_name.c_str())) == 0) { return -1; } @@ -1223,29 +1227,36 @@ AudioEngine::connect_to_jack (string client_name) int AudioEngine::disconnect_from_jack () { - if (_jack == 0) { + if (!_jack) { return 0; } - jack_client_close (_jack); + + if (_running) { + stop_metering_thread (); + } + + { + Glib::Mutex::Lock lm (_process_lock); + jack_client_close (_jack); + _jack = 0; + } _buffer_size = 0; _frame_rate = 0; if (_running) { - stop_metering_thread (); _running = false; Stopped(); /* EMIT SIGNAL */ } - _jack = 0; return 0; } int AudioEngine::reconnect_to_jack () { - if (_jack) { + if (_running) { disconnect_from_jack (); /* XXX give jackd a chance */ Glib::usleep (250000); @@ -1336,7 +1347,9 @@ void AudioEngine::update_total_latencies () { #ifdef HAVE_JACK_RECOMPUTE_LATENCIES - jack_recompute_total_latencies (_jack); + if (_jack) { + jack_recompute_total_latencies (_jack); + } #endif } diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index a38c851c21..f6bb2ec4dd 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -43,10 +43,11 @@ using namespace std; using namespace ARDOUR; using namespace PBD; - + LV2Plugin::LV2Plugin (AudioEngine& e, Session& session, LV2World& world, SLV2Plugin plugin, nframes_t rate) : Plugin (e, session) , _world(world) + , _features(NULL) { init (world, plugin, rate); } @@ -54,6 +55,7 @@ LV2Plugin::LV2Plugin (AudioEngine& e, Session& session, LV2World& world, SLV2Plu LV2Plugin::LV2Plugin (const LV2Plugin &other) : Plugin (other) , _world(other._world) + , _features(NULL) { init (other._world, other._plugin, other._sample_rate); @@ -68,12 +70,13 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, nframes_t rate) { _world = world; _plugin = plugin; + _ui = NULL; _control_data = 0; _shadow_data = 0; _latency_control_port = 0; _was_activated = false; - - _instance = slv2_plugin_instantiate(plugin, rate, NULL); + + _instance = slv2_plugin_instantiate(plugin, rate, _features); _name = slv2_plugin_get_name(plugin); assert(_name); _author = slv2_plugin_get_author_name(plugin); @@ -90,6 +93,18 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, nframes_t rate) slv2_value_free(_author); throw failed_constructor(); } + + _instance_access_feature.URI = "http://lv2plug.in/ns/ext/instance-access"; + _instance_access_feature.data = (void*)_instance->lv2_handle; + + _data_access_extension_data.extension_data = _instance->lv2_descriptor->extension_data; + _data_access_feature.URI = "http://lv2plug.in/ns/ext/data-access"; + _data_access_feature.data = &_data_access_extension_data; + + _features = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * 3); + _features[0] = &_instance_access_feature; + _features[1] = &_data_access_feature; + _features[2] = NULL; _sample_rate = rate; @@ -124,6 +139,17 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, nframes_t rate) _defaults[i] = 0.0f; } } + + SLV2UIs uis = slv2_plugin_get_uis(_plugin); + if (slv2_uis_size(uis) > 0) { + for (unsigned i=0; i < slv2_uis_size(uis); ++i) { + SLV2UI ui = slv2_uis_get_at(uis, i); + if (slv2_ui_is_a(ui, _world.gtk_gui)) { + _ui = ui; + break; + } + } + } latency_compute_run (); } @@ -243,6 +269,12 @@ LV2Plugin::save_preset (string name) { return Plugin::save_preset (name, "lv2"); } + +bool +LV2Plugin::has_editor() const +{ + return (_ui != NULL); +} int LV2Plugin::set_state(const XMLNode& node) @@ -536,6 +568,7 @@ LV2World::LV2World() integer = slv2_value_new_uri(world, SLV2_NAMESPACE_LV2 "integer"); toggled = slv2_value_new_uri(world, SLV2_NAMESPACE_LV2 "toggled"); srate = slv2_value_new_uri(world, SLV2_NAMESPACE_LV2 "sampleRate"); + gtk_gui = slv2_value_new_uri(world, "http://lv2plug.in/ns/extensions/ui#GtkUI"); } LV2World::~LV2World() diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index 9d8ac311b7..d0a8a3abbf 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -60,8 +60,15 @@ RBEffect::~RBEffect () } int -RBEffect::run (boost::shared_ptr region) +RBEffect::run (boost::shared_ptr r) { + boost::shared_ptr region = boost::dynamic_pointer_cast (r); + + if (!region) { + error << "RBEffect::run() passed a non-audio region! WTF?" << endmsg; + return -1; + } + SourceList nsrcs; nframes_t done; int ret = -1; @@ -158,9 +165,6 @@ RBEffect::run (boost::shared_ptr region) stretcher.setExpectedInputDuration(read_duration); stretcher.setDebugLevel(1); - stretcher.setExpectedInputDuration(duration); - stretcher.setDebugLevel(1); - /* the name doesn't need to be super-precise, but allow for 2 fractional digits just to disambiguate close but not identical FX */ @@ -288,8 +292,12 @@ RBEffect::run (boost::shared_ptr region) for (uint32_t i = 0; i < nsrcs.size(); ++i) { - if (nsrcs[i]->write(buffers[i], this_read) != - this_read) { + boost::shared_ptr asrc = boost::dynamic_pointer_cast(nsrcs[i]); + if (!asrc) { + continue; + } + + if (asrc->write(buffers[i], this_read) != this_read) { error << string_compose (_("error writing tempo-adjusted data to %1"), nsrcs[i]->name()) << endmsg; goto out; } @@ -305,7 +313,12 @@ RBEffect::run (boost::shared_ptr region) for (uint32_t i = 0; i < nsrcs.size(); ++i) { - if (nsrcs[i]->write(buffers[i], this_read) != + boost::shared_ptr asrc = boost::dynamic_pointer_cast(nsrcs[i]); + if (!asrc) { + continue; + } + + if (asrc->write(buffers[i], this_read) != this_read) { error << string_compose (_("error writing tempo-adjusted data to %1"), nsrcs[i]->name()) << endmsg; goto out; @@ -334,14 +347,13 @@ RBEffect::run (boost::shared_ptr region) /* now reset ancestral data for each new region */ - for (vector >::iterator x = results.begin(); x != results.end(); ++x) { - + for (vector >::iterator x = results.begin(); x != results.end(); ++x) { (*x)->set_ancestral_data (read_start, read_duration, stretch, shift); - (*x)->set_master_sources (region->get_master_sources()); + (*x)->set_master_sources (region->master_sources()); } out: diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 6676222b54..42564a8b5e 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1406,7 +1406,7 @@ Region::master_source_names () } void -Region::set_master_sources (SourceList& srcs) +Region::set_master_sources (const SourceList& srcs) { _master_sources = srcs; } diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index b6efe27d36..ed63fb6132 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -160,8 +160,12 @@ SndFileSource::SndFileSource (Session& s, ustring path, SampleFormat sfmt, Heade memset (_broadcast_info, 0, sizeof (*_broadcast_info)); snprintf_bounded_null_filled (_broadcast_info->description, sizeof (_broadcast_info->description), "BWF %s", _name.c_str()); - snprintf_bounded_null_filled (_broadcast_info->originator, sizeof (_broadcast_info->originator), "ardour %s)", Glib::get_real_name().c_str()); - + snprintf_bounded_null_filled (_broadcast_info->originator, sizeof (_broadcast_info->originator), "ardour %d.%d.%d %s", + libardour3_major_version, + libardour3_minor_version, + libardour3_micro_version, + Glib::get_real_name().c_str()); + _broadcast_info->version = 1; _broadcast_info->time_reference_low = 0; _broadcast_info->time_reference_high = 0; @@ -551,14 +555,14 @@ SndFileSource::setup_broadcast_info (nframes_t when, struct tm& now, time_t tnow snprintf_bounded_null_filled (_broadcast_info->origination_date, sizeof (_broadcast_info->origination_date), "%4d-%02d-%02d", 1900 + now.tm_year, - now.tm_mon + 1, // move from 0..11 to 1..12 + now.tm_mon + 1, // shift range from 0..11 to 1..12 now.tm_mday); snprintf_bounded_null_filled (_broadcast_info->origination_time, sizeof (_broadcast_info->origination_time), "%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec); - + /* now update header position taking header offset into account */ set_header_timeline_position (); -- cgit v1.2.3