#include <cstdlib>
#include <cstring>
-#include <giomm/file.h>
+#include <glib/gstdio.h>
#include <glib/gprintf.h>
#include <glibmm.h>
#include <boost/utility.hpp>
+#include "pbd/clear_dir.h"
#include "pbd/pathscanner.h"
#include "pbd/compose.h"
#include "pbd/error.h"
#include "ardour/types.h"
#include "ardour/utils.h"
#include "ardour/worker.h"
-#include "ardour/lv2_bundled_search_path.h"
+#include "ardour/search_paths.h"
#include "i18n.h"
#include <locale.h>
return g_strndup(abs_path.c_str(), abs_path.length());
}
-static void
-remove_directory(const std::string& path)
-{
- if (!Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) {
- warning << string_compose("\"%1\" is not a directory", path) << endmsg;
- return;
- }
-
- Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path(path);
- Glib::RefPtr<Gio::FileEnumerator> e = dir->enumerate_children();
- Glib::RefPtr<Gio::FileInfo> fi;
- while ((fi = e->next_file())) {
- if (fi->get_type() == Gio::FILE_TYPE_DIRECTORY) {
- remove_directory(fi->get_name());
- } else {
- dir->get_child(fi->get_name())->remove();
- }
- }
- dir->remove();
-}
-
void
LV2Plugin::add_state(XMLNode* root) const
{
} else {
// State is identical, decrement version and nuke directory
lilv_state_free(state);
- remove_directory(new_dir);
+ PBD::remove_directory(new_dir);
--_state_version;
}
if (state) {
lilv_state_restore(state, _impl->instance, set_port_value, this, 0, NULL);
lilv_state_free(state);
+ Plugin::load_preset(r);
}
lilv_node_free(pset);
lilv_state_free(state);
- return Glib::filename_to_uri(Glib::build_filename(bundle, file_name));
+ std::string uri = Glib::filename_to_uri(Glib::build_filename(bundle, file_name));
+ LilvNode *node_bundle = lilv_new_uri(_world.world, Glib::filename_to_uri(Glib::build_filename(bundle, "/")).c_str());
+ LilvNode *node_preset = lilv_new_uri(_world.world, uri.c_str());
+ lilv_world_load_bundle(_world.world, node_bundle);
+ lilv_world_load_resource(_world.world, node_preset);
+ lilv_node_free(node_bundle);
+ lilv_node_free(node_preset);
+ return uri;
}
void
name + ".ttl"
)
);
- unlink(preset_file.c_str());
+ ::g_unlink(preset_file.c_str());
}
bool
uint32_t size,
const uint8_t* body)
{
- const uint32_t buf_size = sizeof(UIMessage) + size;
- uint8_t buf[buf_size];
+ const uint32_t buf_size = sizeof(UIMessage) + size;
+ vector<uint8_t> buf(buf_size);
- UIMessage* msg = (UIMessage*)buf;
+ UIMessage* msg = (UIMessage*)&buf[0];
msg->index = index;
msg->protocol = protocol;
msg->size = size;
memcpy(msg + 1, body, size);
- return (dest->write(buf, buf_size) == buf_size);
+ return (dest->write(&buf[0], buf_size) == buf_size);
}
bool
* 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).
+ *
+ * it is NOT safe to overflow (msg.size will be misinterpreted)
*/
- rbs = max((size_t) 32768 * 6, rbs);
+ uint32_t bufsiz = 32768;
+ if (_atom_ev_buffers && _atom_ev_buffers[0]) {
+ bufsiz = lv2_evbuf_get_capacity(_atom_ev_buffers[0]);
+ }
+ rbs = max((size_t) bufsiz * 8, rbs);
_from_ui = new RingBuffer<uint8_t>(rbs);
}
{
if (!_to_ui) {
/* see note in LV2Plugin::write_from_ui() */
+ uint32_t bufsiz = 32768;
+ if (_atom_ev_buffers && _atom_ev_buffers[0]) {
+ bufsiz = lv2_evbuf_get_capacity(_atom_ev_buffers[0]);
+ }
size_t rbs = _session.engine().raw_buffer_size(DataType::MIDI) * NBUFS;
- rbs = max((size_t) 32768 * 8, rbs);
+ rbs = max((size_t) bufsiz * 8, rbs);
_to_ui = new RingBuffer<uint8_t>(rbs);
}
}
error << "Error reading from Plugin=>UI RingBuffer" << endmsg;
break;
}
- uint8_t body[msg.size];
- if (_to_ui->read(body, msg.size) != msg.size) {
+ vector<uint8_t> body(msg.size);
+ if (_to_ui->read(&body[0], msg.size) != msg.size) {
error << "Error reading from Plugin=>UI RingBuffer" << endmsg;
break;
}
- sink(controller, msg.index, msg.size, msg.protocol, body);
+ sink(controller, msg.index, msg.size, msg.protocol, &body[0]);
read_space -= sizeof(msg) + msg.size;
}
error << "Error reading from UI=>Plugin RingBuffer" << endmsg;
break;
}
- uint8_t body[msg.size];
- if (_from_ui->read(body, msg.size) != msg.size) {
+ vector<uint8_t> body(msg.size);
+ if (_from_ui->read(&body[0], msg.size) != msg.size) {
error << "Error reading from UI=>Plugin RingBuffer" << endmsg;
break;
}
if (msg.protocol == urids.atom_eventTransfer) {
LV2_Evbuf* buf = _ev_buffers[msg.index];
LV2_Evbuf_Iterator i = lv2_evbuf_end(buf);
- const LV2_Atom* const atom = (const LV2_Atom*)body;
+ const LV2_Atom* const atom = (const LV2_Atom*)&body[0];
if (!lv2_evbuf_write(&i, nframes, 0, atom->type, atom->size,
(const uint8_t*)(atom + 1))) {
error << "Failed to write data to LV2 event buffer\n";
vector<string *> *plugin_objects = scanner (ARDOUR::lv2_bundled_search_path().to_string(), lv2_filter, 0, true, true);
if (plugin_objects) {
for ( vector<string *>::iterator x = plugin_objects->begin(); x != plugin_objects->end (); ++x) {
-#ifdef WINDOWS
+#ifdef PLATFORM_WINDOWS
string uri = "file:///" + **x + "/";
#else
string uri = "file://" + **x + "/";
PluginInfoList* plugs = new PluginInfoList;
const LilvPlugins* plugins = lilv_world_get_all_plugins(_world.world);
- info << "LV2: Discovering " << lilv_plugins_size(plugins) << " plugins" << endmsg;
+ if (!Config->get_show_plugin_scan_window()) {
+ info << "LV2: Discovering " << lilv_plugins_size(plugins) << " plugins" << endmsg;
+ }
LILV_FOREACH(plugins, i, plugins) {
const LilvPlugin* p = lilv_plugins_get(plugins, i);
info->name = string(lilv_node_as_string(name));
lilv_node_free(name);
+ ARDOUR::PluginScanMessage(_("LV2"), info->name, false);
const LilvPluginClass* pclass = lilv_plugin_get_class(p);
const LilvNode* label = lilv_plugin_class_get_label(pclass);