summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-14 04:03:14 +0000
committerDavid Robillard <d@drobilla.net>2008-08-14 04:03:14 +0000
commit58e8d1cddd520ae0ddf39f16210f1500868a2b2e (patch)
tree3da3105ec9c526f36352295b6d75c390e05c26b5 /src
parent2ad7b1dab1cbbc9a35fe84ce784179d78fba3a29 (diff)
downloadingen-58e8d1cddd520ae0ddf39f16210f1500868a2b2e.tar.gz
ingen-58e8d1cddd520ae0ddf39f16210f1500868a2b2e.tar.bz2
ingen-58e8d1cddd520ae0ddf39f16210f1500868a2b2e.zip
Lock RDF world mutex in all places slv2 or redland is accessed (fix random segfaults usually on patch loading).
git-svn-id: http://svn.drobilla.net/lad/ingen@1367 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/libs/client/NodeModel.cpp2
-rw-r--r--src/libs/client/PluginModel.cpp8
-rw-r--r--src/libs/client/PluginModel.hpp3
-rw-r--r--src/libs/client/PluginUI.cpp2
-rw-r--r--src/libs/engine/ConnectionImpl.cpp3
-rw-r--r--src/libs/engine/InputPort.cpp26
-rw-r--r--src/libs/engine/InputPort.hpp1
-rw-r--r--src/libs/engine/LADSPANode.cpp6
-rw-r--r--src/libs/engine/LV2Node.cpp4
-rw-r--r--src/libs/engine/NodeBase.cpp29
-rw-r--r--src/libs/engine/PatchImpl.cpp3
-rw-r--r--src/libs/engine/PortImpl.cpp6
-rw-r--r--src/libs/gui/PatchCanvas.cpp2
13 files changed, 71 insertions, 24 deletions
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index d1c6c271..7cee66f9 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -167,7 +167,7 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max)
if (!_min_values) {
- Glib::Mutex::Lock(PluginModel::rdf_world()->mutex());
+ Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex());
uint32_t num_lv2_ports = slv2_plugin_get_num_ports(_plugin->slv2_plugin());
_min_values = new float[num_lv2_ports];
diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp
index 8c2705da..db62b3bf 100644
--- a/src/libs/client/PluginModel.cpp
+++ b/src/libs/client/PluginModel.cpp
@@ -50,9 +50,9 @@ PluginModel::ui(Ingen::Shared::World* world, SharedPtr<NodeModel> node) const
if (_type != LV2)
return SharedPtr<PluginUI>();
- Glib::Mutex::Lock(_rdf_world->mutex());
-
- return PluginUI::create(world, node, _slv2_plugin);
+ Glib::Mutex::Lock lock(_rdf_world->mutex());
+ SharedPtr<PluginUI> ret = PluginUI::create(world, node, _slv2_plugin);
+ return ret;
}
@@ -69,6 +69,8 @@ PluginModel::icon_path() const
string
PluginModel::get_lv2_icon_path(SLV2Plugin plugin)
{
+ Glib::Mutex::Lock lock(_rdf_world->mutex());
+
string result;
SLV2Value svg_icon_pred = slv2_value_new_uri(_slv2_world,
"http://ll-plugins.nongnu.org/lv2/namespace#svgIcon");
diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp
index 4e2bfab1..a7adc735 100644
--- a/src/libs/client/PluginModel.hpp
+++ b/src/libs/client/PluginModel.hpp
@@ -55,6 +55,7 @@ public:
, _name(name)
{
#ifdef HAVE_SLV2
+ Glib::Mutex::Lock lock(_rdf_world->mutex());
SLV2Value plugin_uri = slv2_value_new_uri(_slv2_world, uri.c_str());
_slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, plugin_uri);
slv2_value_free(plugin_uri);
@@ -89,10 +90,12 @@ public:
SLV2Plugin slv2_plugin() { return _slv2_plugin; }
SLV2Port slv2_port(uint32_t index) {
+ Glib::Mutex::Lock lock(_rdf_world->mutex());
return slv2_plugin_get_port_by_index(_slv2_plugin, index);
}
static void set_slv2_world(SLV2World world) {
+ Glib::Mutex::Lock lock(_rdf_world->mutex());
_slv2_world = world;
_slv2_plugins = slv2_world_get_all_plugins(_slv2_world);
}
diff --git a/src/libs/client/PluginUI.cpp b/src/libs/client/PluginUI.cpp
index b341bb0f..f2f591bd 100644
--- a/src/libs/client/PluginUI.cpp
+++ b/src/libs/client/PluginUI.cpp
@@ -107,6 +107,7 @@ PluginUI::PluginUI(Ingen::Shared::World* world,
PluginUI::~PluginUI()
{
+ Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex());
slv2_ui_instance_free(_instance);
}
@@ -116,6 +117,7 @@ PluginUI::create(Ingen::Shared::World* world,
SharedPtr<NodeModel> node,
SLV2Plugin plugin)
{
+ Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex());
SharedPtr<PluginUI> ret;
SLV2Value gtk_gui_uri = slv2_value_new_uri(world->slv2_world,
diff --git a/src/libs/engine/ConnectionImpl.cpp b/src/libs/engine/ConnectionImpl.cpp
index a6f573a8..d226b4dd 100644
--- a/src/libs/engine/ConnectionImpl.cpp
+++ b/src/libs/engine/ConnectionImpl.cpp
@@ -92,6 +92,8 @@ ConnectionImpl::set_buffer_size(size_t size)
void
ConnectionImpl::prepare_poly(uint32_t poly)
{
+ _src_port->prepare_poly(poly);
+
if (type() == DataType::CONTROL || type() == DataType::AUDIO)
_must_mix = (poly > 1) && (
(_src_port->poly() != _dst_port->poly())
@@ -110,6 +112,7 @@ ConnectionImpl::prepare_poly(uint32_t poly)
void
ConnectionImpl::apply_poly(Raul::Maid& maid, uint32_t poly)
{
+ _src_port->apply_poly(maid, poly);
if (poly == 1 && _local_buffer && !_must_mix) {
maid.push(_local_buffer);
_local_buffer = NULL;
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp
index b778579d..cf5501ca 100644
--- a/src/libs/engine/InputPort.cpp
+++ b/src/libs/engine/InputPort.cpp
@@ -57,6 +57,19 @@ InputPort::set_buffer_size(size_t size)
bool
+InputPort::prepare_poly(uint32_t poly)
+{
+ PortImpl::prepare_poly(poly);
+
+ for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
+ ((ConnectionImpl*)c->get())->prepare_poly(poly);
+
+ connect_buffers();
+ return true;
+}
+
+
+bool
InputPort::apply_poly(Raul::Maid& maid, uint32_t poly)
{
if (!_polyphonic || !_parent->polyphonic())
@@ -65,7 +78,18 @@ InputPort::apply_poly(Raul::Maid& maid, uint32_t poly)
for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
((ConnectionImpl*)c->get())->apply_poly(maid, poly);
- return PortImpl::apply_poly(maid, poly);
+ PortImpl::apply_poly(maid, poly);
+ assert(this->poly() == poly);
+
+ if (_connections.size() == 1) {
+ ConnectionImpl* c = _connections.begin()->get();
+ for (uint32_t i=0; i < _poly; ++i)
+ _buffers->at(i)->join(c->buffer(i));
+ }
+
+ connect_buffers();
+
+ return true;
}
diff --git a/src/libs/engine/InputPort.hpp b/src/libs/engine/InputPort.hpp
index ffba2a30..2617882f 100644
--- a/src/libs/engine/InputPort.hpp
+++ b/src/libs/engine/InputPort.hpp
@@ -64,6 +64,7 @@ public:
const Connections& connections() { return _connections; }
+ bool prepare_poly(uint32_t poly);
bool apply_poly(Raul::Maid& maid, uint32_t poly);
void pre_process(ProcessContext& context);
diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
index e922de7c..83c3d6af 100644
--- a/src/libs/engine/LADSPANode.cpp
+++ b/src/libs/engine/LADSPANode.cpp
@@ -99,9 +99,7 @@ LADSPANode::apply_poly(Raul::Maid& maid, uint32_t poly)
assert(poly <= _instances->size());
_polyphony = poly;
- NodeBase::apply_poly(maid, poly);
-
- return true;
+ return NodeBase::apply_poly(maid, poly);
}
@@ -272,7 +270,7 @@ void
LADSPANode::process(ProcessContext& context)
{
NodeBase::pre_process(context);
-
+
for (uint32_t i=0; i < _polyphony; ++i)
_descriptor->run((*_instances)[i], context.nframes());
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp
index 59d30c7e..974c5858 100644
--- a/src/libs/engine/LV2Node.cpp
+++ b/src/libs/engine/LV2Node.cpp
@@ -108,9 +108,7 @@ LV2Node::apply_poly(Raul::Maid& maid, uint32_t poly)
assert(poly <= _instances->size());
_polyphony = poly;
- NodeBase::apply_poly(maid, poly);
-
- return true;
+ return NodeBase::apply_poly(maid, poly);
}
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
index a6bfa9ce..f8891f68 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -122,9 +122,14 @@ NodeBase::apply_poly(Raul::Maid& maid, uint32_t poly)
if (!_polyphonic)
return true;
- if (_ports)
- for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->apply_poly(maid, poly);
+ for (size_t i=0; i < num_ports(); ++i) {
+ _ports->at(i)->apply_poly(maid, poly);
+ assert(_ports->at(i)->poly() == poly);
+ }
+
+ for (uint32_t i=0; i < num_ports(); ++i)
+ for (uint32_t j=0; j < _polyphony; ++j)
+ set_port_buffer(j, i, _ports->at(i)->buffer(j));
return true;
}
@@ -202,9 +207,21 @@ NodeBase::pre_process(ProcessContext& context)
assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
// Mix down any ports with multiple inputs
- if (_ports)
- for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->pre_process(context);
+ for (size_t i=0; i < num_ports(); ++i)
+ _ports->at(i)->pre_process(context);
+
+ // Connect port buffers (FIXME: NOT NECESSARY!)
+ if (polyphonic()) {
+ for (uint32_t i=0; i < _polyphony; ++i) {
+ for (uint32_t j=0; j < num_ports(); ++j) {
+ assert(_ports->at(j)->poly() == _polyphony);
+ set_port_buffer(i, j, _ports->at(j)->buffer(i));
+ }
+ }
+ } else {
+ for (uint32_t j=0; j < num_ports(); ++j)
+ set_port_buffer(0, j, _ports->at(j)->buffer(0));
+ }
}
diff --git a/src/libs/engine/PatchImpl.cpp b/src/libs/engine/PatchImpl.cpp
index 2d33dd0d..aedaacbf 100644
--- a/src/libs/engine/PatchImpl.cpp
+++ b/src/libs/engine/PatchImpl.cpp
@@ -123,9 +123,6 @@ PatchImpl::apply_internal_poly(Raul::Maid& maid, uint32_t poly)
for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
(*i)->apply_poly(maid, poly);
- for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i)
- PtrCast<ConnectionImpl>(*i)->apply_poly(maid, poly);
-
_internal_poly = poly;
return true;
diff --git a/src/libs/engine/PortImpl.cpp b/src/libs/engine/PortImpl.cpp
index 9061ffc5..9b609323 100644
--- a/src/libs/engine/PortImpl.cpp
+++ b/src/libs/engine/PortImpl.cpp
@@ -58,6 +58,8 @@ PortImpl::PortImpl(NodeImpl* const node,
if (node->parent() == NULL)
_polyphonic = false;
+ else
+ _polyphonic = true;
if (type == DataType::EVENT)
_broadcast = true; // send activity blips
@@ -117,8 +119,8 @@ PortImpl::apply_poly(Raul::Maid& maid, uint32_t poly)
}
_poly = poly;
-
- connect_buffers();
+ assert(_buffers->size() >= poly);
+ assert(this->poly() == poly);
return true;
}
diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp
index 48ad1366..5d85ac30 100644
--- a/src/libs/gui/PatchCanvas.cpp
+++ b/src/libs/gui/PatchCanvas.cpp
@@ -216,7 +216,7 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
void
PatchCanvas::build_plugin_menu()
{
- Glib::Mutex::Lock(PluginModel::rdf_world()->mutex());
+ Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex());
_menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem("Plugin",
*(manage(new Gtk::Image(Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU)))));