get_scale_points(uint32_t port_index) const;
void set_insert_id(PBD::ID id);
+ void set_state_dir (const std::string& d = "");
int set_state (const XMLNode& node, int version);
bool save_preset (std::string uri);
framepos_t _next_cycle_start; ///< Expected start frame of next run cycle
double _next_cycle_speed; ///< Expected start frame of next run cycle
PBD::ID _insert_id;
+ std::string _plugin_state_dir;
uint32_t _patch_port_in_index;
uint32_t _patch_port_out_index;
URIMap& _uri_map;
#include "ardour/debug.h"
#include "ardour/lv2_plugin.h"
#include "ardour/session.h"
+#include "ardour/template_utils.h"
#include "ardour/tempo.h"
#include "ardour/types.h"
#include "ardour/utils.h"
const std::string
LV2Plugin::plugin_dir() const
{
- return Glib::build_filename(_session.plugins_dir(), _insert_id.to_s());
+ if (!_plugin_state_dir.empty ()){
+ return Glib::build_filename(_plugin_state_dir, _insert_id.to_s());
+ } else {
+ return Glib::build_filename(_session.plugins_dir(), _insert_id.to_s());
+ }
}
/** Directory for files created by the plugin (except during save). */
}
}
+ if (!_plugin_state_dir.empty()) {
+ root->add_property("template-dir", _plugin_state_dir);
+ }
+
if (_has_state_interface) {
// Provisionally increment state version and create directory
const std::string new_dir = state_dir(++_state_version);
}
}
+void
+LV2Plugin::set_state_dir (const std::string& d)
+{
+ _plugin_state_dir = d;
+}
+
int
LV2Plugin::set_state(const XMLNode& node, int version)
{
set_parameter(port_id, atof(value));
}
+ if ((prop = node.property("template-dir")) != 0) {
+ // portable templates, strip absolute path
+ set_state_dir (Glib::build_filename (
+ ARDOUR::user_route_template_directory (),
+ Glib::path_get_basename (prop->value ())));
+ }
+
_state_version = 0;
if ((prop = node.property("state-dir")) != 0) {
if (sscanf(prop->value().c_str(), "state%u", &_state_version) != 1) {
prop->value()) << endmsg;
}
- // TODO: special case track-templates
- // (state must be saved with the template)
std::string state_file = Glib::build_filename(
plugin_dir(),
Glib::build_filename(prop->value(), "state.ttl"));
_impl->state = state;
}
+ if (!_plugin_state_dir.empty ()) {
+ // force save with session, next time (increment counter)
+ lilv_state_free (_impl->state);
+ _impl->state = NULL;
+ set_state_dir ("");
+ }
+
latency_compute_run();
#endif
int
Route::save_as_template (const string& path, const string& name)
{
+ {
+ // would be nice to use foreach_processor()
+ Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
+ std::string state_dir = path.substr (0, path.find_last_of ('.')); // strip template_suffix
+ for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (*i);
+ if (pi) {
+ pi->set_state_dir (state_dir);
+ }
+ }
+ }
+
XMLNode& node (state (false));
+
+ {
+ Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
+ for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (*i);
+ if (pi) {
+ pi->set_state_dir ();
+ }
+ }
+ }
+
XMLTree tree;
IO::set_name_in_state (*node.children().front(), name);