summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-03-17 15:24:36 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-03-17 15:24:36 +0000
commitd44bf70a614ada08e100dab917b4498197177be7 (patch)
tree91fdcaab78e0a24171cc7788b3de6b767a6123b7 /libs
parent22b3c2de96e561471fe615241f0d2f6d2774abc0 (diff)
VST chunk save/restore patch from Martin Profittlich
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4865 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/vst_plugin.cc58
1 files changed, 23 insertions, 35 deletions
diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc
index e29f6dc3dd..ec30087ee1 100644
--- a/libs/ardour/vst_plugin.cc
+++ b/libs/ardour/vst_plugin.cc
@@ -147,49 +147,21 @@ VSTPlugin::get_state()
/* fetch the current chunk */
- void* data;
+ guchar* data;
long data_size;
if ((data_size = _plugin->dispatcher (_plugin, 23 /* effGetChunk */, 0, 0, &data, false)) == 0) {
return *root;
}
- /* save it to a file */
-
- Glib::ustring path = Glib::build_filename (get_user_ardour_path (), "vst");
- struct stat sbuf;
-
- if (stat (path.c_str(), &sbuf)) {
- if (errno == ENOENT) {
- if (g_mkdir_with_parents (path.c_str(), 0600)) {
- error << string_compose (_("cannot create VST chunk directory: %1"),
- strerror (errno))
- << endmsg;
- return *root;
- }
-
- } else {
-
- warning << string_compose (_("cannot check VST chunk directory: %1"), strerror (errno))
- << endmsg;
- return *root;
- }
-
- } else if (!S_ISDIR (sbuf.st_mode)) {
- error << string_compose (_("%1 exists but is not a directory"), path)
- << endmsg;
- return *root;
- }
-
- path = Glib::build_filename (path, "something");
-
/* store information */
XMLNode* chunk_node = new XMLNode (X_("chunk"));
- chunk_node->add_property ("path", path);
-
+ gchar * encoded_data = g_base64_encode (data, data_size);
+ chunk_node->add_content (encoded_data);
+ g_free (encoded_data);
+
root->add_child_nocopy (*chunk_node);
-
} else {
XMLNode* parameters = new XMLNode ("parameters");
@@ -221,10 +193,26 @@ VSTPlugin::set_state(const XMLNode& node)
XMLNode* child;
- if ((child = find_named_node (node, X_("chunks"))) != 0) {
+ if ((child = find_named_node (node, X_("chunk"))) != 0) {
- return 0;
+ XMLPropertyList::const_iterator i;
+ XMLNodeList::const_iterator n;
+ for (n = child->children ().begin (); n != child->children ().end (); ++n) {
+ if ((*n)->is_content ()) {
+ gsize chunk_size = 0;
+ guchar * data = g_base64_decode ((*n)->content ().c_str (), &chunk_size);
+ if (_plugin->dispatcher (_plugin, 24 /* effSetChunk */, 0, chunk_size, data, 0) == 0) {
+ g_free (data);
+ return 0;
+ } else {
+ g_free (data);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
} else if ((child = find_named_node (node, X_("parameters"))) != 0) {
XMLPropertyList::const_iterator i;