#include "pbd/stacktrace.h"
#include "pbd/convert.h"
#include "pbd/localtime_r.h"
+#include "pbd/unwind.h"
#include "ardour/amp.h"
#include "ardour/async_midi_port.h"
#include "control_protocol/control_protocol.h"
+#include "LuaBridge/LuaBridge.h"
+
#include "i18n.h"
#include <locale.h>
node->add_child_copy (*_extra_xml);
}
+ {
+ Glib::Threads::Mutex::Lock lm (lua_lock);
+ std::string saved;
+ {
+ luabridge::LuaRef savedstate ((*_lua_save)());
+ saved = savedstate.cast<std::string>();
+ }
+ lua.collect_garbage ();
+ lm.release ();
+
+ gchar* b64 = g_base64_encode ((const guchar*)saved.c_str (), saved.size ());
+ std::string b64s (b64);
+ g_free (b64);
+
+ XMLNode* script_node = new XMLNode (X_("Script"));
+ script_node->add_property (X_("lua"), LUA_VERSION);
+ script_node->add_content (b64s);
+ node->add_child_nocopy (*script_node);
+ }
+
return *node;
}
ControlProtocolManager::instance().set_state (*child, version);
}
+ if ((child = find_named_node (node, "Script"))) {
+ for (XMLNodeList::const_iterator n = child->children ().begin (); n != child->children ().end (); ++n) {
+ if (!(*n)->is_content ()) { continue; }
+ gsize size;
+ guchar* buf = g_base64_decode ((*n)->content ().c_str (), &size);
+ try {
+ Glib::Threads::Mutex::Lock lm (lua_lock);
+ (*_lua_load)(std::string ((const char*)buf, size));
+ } catch (luabridge::LuaException const& e) {
+ cerr << "LuaException:" << e.what () << endl;
+ }
+ g_free (buf);
+ }
+ }
+
update_route_record_state ();
/* here beginneth the second phase ... */
XMLTree tree;
- tree.set_root (&get_template());
+ {
+ PBD::Unwinder<std::string> uw (_template_state_dir, template_dir_path);
+ tree.set_root (&get_template());
+ }
+
if (!tree.write (template_file_path)) {
error << _("template not saved") << endmsg;
return -1;
}
- if (!ARDOUR::Profile->get_trx()) {
- /* copy plugin state directory */
-
- std::string template_plugin_state_path (Glib::build_filename (template_dir_path, X_("plugins")));
-
- if (g_mkdir_with_parents (template_plugin_state_path.c_str(), 0755) != 0) {
- error << string_compose(_("Could not create directory for Session template plugin state\"%1\" (%2)"),
- template_plugin_state_path, g_strerror (errno)) << endmsg;
- return -1;
- }
- copy_files (plugins_dir(), template_plugin_state_path);
- }
-
store_recent_templates (template_file_path);
return 0;
case ControllableDescriptor::RemoteControlID:
r = route_by_remote_id (desc.rid());
break;
+
+ case ControllableDescriptor::SelectionCount:
+ r = route_by_selected_count (desc.selection_id());
+ break;
}
if (!r) {
}
case ControllableDescriptor::PanDirection:
- {
- c = r->pannable()->pan_azimuth_control;
+ c = r->pan_azimuth_control();
break;
- }
case ControllableDescriptor::PanWidth:
- {
- c = r->pannable()->pan_width_control;
+ c = r->pan_width_control();
break;
- }
case ControllableDescriptor::PanElevation:
- {
- c = r->pannable()->pan_elevation_control;
+ c = r->pan_elevation_control();
break;
- }
case ControllableDescriptor::Balance:
/* XXX simple pan control */
break;
}
- case ControllableDescriptor::SendGain:
- {
+ case ControllableDescriptor::SendGain: {
uint32_t send = desc.target (0);
-
- /* revert to zero-based counting */
-
if (send > 0) {
--send;
}
-
- boost::shared_ptr<Processor> p = r->nth_send (send);
-
- if (p) {
- boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
- boost::shared_ptr<Amp> a = s->amp();
-
- if (a) {
- c = s->amp()->gain_control();
- }
- }
+ c = r->send_level_controllable (send);
break;
}
} else if (p == "click-gain") {
if (_click_gain) {
- _click_gain->set_gain (Config->get_click_gain(), this);
+ _click_gain->gain_control()->set_value (Config->get_click_gain(), Controllable::NoGroup);
}
} else if (p == "send-mtc") {