diff options
Diffstat (limited to 'src/server/events')
-rw-r--r-- | src/server/events/Connect.cpp | 39 | ||||
-rw-r--r-- | src/server/events/Connect.hpp | 6 | ||||
-rw-r--r-- | src/server/events/CreateNode.cpp | 6 | ||||
-rw-r--r-- | src/server/events/CreateNode.hpp | 5 | ||||
-rw-r--r-- | src/server/events/CreatePort.cpp | 19 | ||||
-rw-r--r-- | src/server/events/CreatePort.hpp | 5 | ||||
-rw-r--r-- | src/server/events/Delete.cpp | 4 | ||||
-rw-r--r-- | src/server/events/Disconnect.cpp | 20 | ||||
-rw-r--r-- | src/server/events/Disconnect.hpp | 11 | ||||
-rw-r--r-- | src/server/events/DisconnectAll.cpp | 8 | ||||
-rw-r--r-- | src/server/events/Move.cpp | 11 | ||||
-rw-r--r-- | src/server/events/SetMetadata.cpp | 13 | ||||
-rw-r--r-- | src/server/events/SetMetadata.hpp | 3 |
13 files changed, 78 insertions, 72 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index e0f09a3d..b67eacbc 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -16,9 +16,13 @@ */ #include <string> + #include <boost/format.hpp> +#include <glibmm/thread.h> + #include "raul/Maid.hpp" #include "raul/Path.hpp" + #include "ClientBroadcaster.hpp" #include "Connect.hpp" #include "ConnectionImpl.hpp" @@ -40,7 +44,11 @@ namespace Ingen { namespace Server { namespace Events { -Connect::Connect(Engine& engine, SharedPtr<Request> request, SampleCount timestamp, const Path& src_port_path, const Path& dst_port_path) +Connect::Connect(Engine& engine, + SharedPtr<Request> request, + SampleCount timestamp, + const Path& src_port_path, + const Path& dst_port_path) : QueuedEvent(engine, request, timestamp) , _src_port_path(src_port_path) , _dst_port_path(dst_port_path) @@ -50,12 +58,13 @@ Connect::Connect(Engine& engine, SharedPtr<Request> request, SampleCount timesta , _compiled_patch(NULL) , _port_listnode(NULL) , _buffers(NULL) -{ -} +{} void Connect::pre_process() { + Glib::RWLock::ReaderLock rlock(_engine.engine_store()->lock()); + PortImpl* src_port = _engine.engine_store()->find_port(_src_port_path); PortImpl* dst_port = _engine.engine_store()->find_port(_dst_port_path); if (!src_port || !dst_port) { @@ -122,15 +131,23 @@ Connect::pre_process() _port_listnode = new InputPort::Connections::Node(_connection); - // Need to be careful about patch port connections here and adding a node's - // parent as a dependant/provider, or adding a patch as it's own provider... - if (src_node != dst_node && src_node->parent() == dst_node->parent()) { - dst_node->providers()->push_back(new Raul::List<NodeImpl*>::Node(src_node)); - src_node->dependants()->push_back(new Raul::List<NodeImpl*>::Node(dst_node)); - } + rlock.release(); + + { + Glib::RWLock::ReaderLock wlock(_engine.engine_store()->lock()); - _patch->add_connection(_connection); - _dst_input_port->increment_num_connections(); + /* Need to be careful about patch port connections here and adding a + node's parent as a dependant/provider, or adding a patch as its own + provider... + */ + if (src_node != dst_node && src_node->parent() == dst_node->parent()) { + dst_node->providers()->push_back(new Raul::List<NodeImpl*>::Node(src_node)); + src_node->dependants()->push_back(new Raul::List<NodeImpl*>::Node(dst_node)); + } + + _patch->add_connection(_connection); + _dst_input_port->increment_num_connections(); + } /*if ((_dst_input_port->num_connections() == 1 && (_connection->must_mix() || _connection->must_queue())) diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp index 1cc98729..d250b791 100644 --- a/src/server/events/Connect.hpp +++ b/src/server/events/Connect.hpp @@ -49,7 +49,11 @@ namespace Events { class Connect : public QueuedEvent { public: - Connect(Engine& engine, SharedPtr<Request> request, SampleCount timestamp, const Raul::Path& src_port_path, const Raul::Path& dst_port_path); + Connect(Engine& engine, + SharedPtr<Request> request, + SampleCount timestamp, + const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); void pre_process(); void execute(ProcessContext& context); diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp index 39d5f86d..7722caee 100644 --- a/src/server/events/CreateNode.cpp +++ b/src/server/events/CreateNode.cpp @@ -57,7 +57,6 @@ CreateNode::CreateNode( , _node_already_exists(false) , _polyphonic(false) , _properties(properties) - , _lock(engine.engine_store()->lock(), Glib::NOT_LOCK) { const Resource::Properties::const_iterator p = properties.find( engine.world()->uris()->ingen_polyphonic); @@ -69,8 +68,6 @@ CreateNode::CreateNode( void CreateNode::pre_process() { - _lock.acquire(); - if (_engine.engine_store()->find_object(_path) != NULL) { _node_already_exists = true; QueuedEvent::pre_process(); @@ -121,7 +118,6 @@ void CreateNode::post_process() { if (!_request) { - _lock.release(); return; } @@ -143,8 +139,6 @@ CreateNode::post_process() _request->respond_ok(); _engine.broadcaster()->send_object(_node, true); // yes, send ports } - - _lock.release(); } } // namespace Server diff --git a/src/server/events/CreateNode.hpp b/src/server/events/CreateNode.hpp index 47f86622..86cabf2a 100644 --- a/src/server/events/CreateNode.hpp +++ b/src/server/events/CreateNode.hpp @@ -20,8 +20,6 @@ #include <string> -#include <glibmm/thread.h> - #include "ingen/Resource.hpp" #include "QueuedEvent.hpp" @@ -65,8 +63,7 @@ private: bool _node_already_exists; bool _polyphonic; - Resource::Properties _properties; - Glib::RWLock::WriterLock _lock; + Resource::Properties _properties; }; } // namespace Server diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index fdf675a6..5c3ecbd2 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -49,7 +49,7 @@ CreatePort::CreatePort( const Raul::URI& type, bool is_output, const Resource::Properties& properties) - : QueuedEvent(engine, request, timestamp, bool(request)) + : QueuedEvent(engine, request, timestamp) , _path(path) , _type(type) , _is_output(is_output) @@ -58,16 +58,7 @@ CreatePort::CreatePort( , _patch_port(NULL) , _driver_port(NULL) , _properties(properties) - , _lock(engine.engine_store()->lock(), Glib::NOT_LOCK) { - /* This is blocking because of the two different sets of Patch ports, the array used in the - * audio thread (inherited from NodeImpl), and the arrays used in the pre processor thread. - * If two add port events arrive in the same cycle and the second pre processes before the - * first executes, bad things happen (ports are lost). - * - * TODO: fix this using RCU? - */ - if (_data_type == PortType::UNKNOWN) _error = UNKNOWN_TYPE; } @@ -75,8 +66,6 @@ CreatePort::CreatePort( void CreatePort::pre_process() { - _lock.acquire(); - if (_error == UNKNOWN_TYPE || _engine.engine_store()->find_object(_path)) { QueuedEvent::pre_process(); return; @@ -156,16 +145,12 @@ CreatePort::execute(ProcessContext& context) if (_driver_port) { _engine.driver()->add_port(_driver_port); } - - if (_request) - _request->unblock(); } void CreatePort::post_process() { if (!_request) { - _lock.release(); return; } @@ -188,8 +173,6 @@ CreatePort::post_process() _request->respond_error(msg); break; } - - _lock.release(); } } // namespace Server diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp index e3c13fa1..56c0f0a0 100644 --- a/src/server/events/CreatePort.hpp +++ b/src/server/events/CreatePort.hpp @@ -18,8 +18,6 @@ #ifndef INGEN_EVENTS_CREATEPORT_HPP #define INGEN_EVENTS_CREATEPORT_HPP -#include <glibmm/thread.h> - #include "raul/Array.hpp" #include "raul/Path.hpp" @@ -75,8 +73,7 @@ private: DriverPort* _driver_port; ///< Driver (eg Jack) port if this is a toplevel port bool _succeeded; - Resource::Properties _properties; - Glib::RWLock::WriterLock _lock; + Resource::Properties _properties; }; } // namespace Server diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 4f13cd97..1e7b35e8 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -40,7 +40,7 @@ Delete::Delete(Engine& engine, SharedPtr<Request> request, FrameTime time, const Raul::URI& uri) - : QueuedEvent(engine, request, time, true) + : QueuedEvent(engine, request, time) , _uri(uri) , _store_iterator(engine.engine_store()->end()) , _garbage(NULL) @@ -166,8 +166,6 @@ Delete::execute(ProcessContext& context) _engine.maid()->push(parent_patch->compiled_patch()); parent_patch->compiled_patch(_compiled_patch); } - - _request->unblock(); } void diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index e7177fab..de078c3f 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -15,10 +15,12 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "raul/log.hpp" +#include <glibmm/thread.h> + #include "raul/Maid.hpp" #include "raul/Path.hpp" -#include "events/Disconnect.hpp" +#include "raul/log.hpp" + #include "AudioBuffer.hpp" #include "ClientBroadcaster.hpp" #include "ConnectionImpl.hpp" @@ -32,6 +34,7 @@ #include "ProcessContext.hpp" #include "Request.hpp" #include "ThreadManager.hpp" +#include "events/Disconnect.hpp" using namespace std; using namespace Raul; @@ -40,12 +43,11 @@ namespace Ingen { namespace Server { namespace Events { -Disconnect::Disconnect( - Engine& engine, - SharedPtr<Request> request, - SampleCount timestamp, - const Raul::Path& src_port_path, - const Raul::Path& dst_port_path) +Disconnect::Disconnect(Engine& engine, + SharedPtr<Request> request, + SampleCount timestamp, + const Raul::Path& src_port_path, + const Raul::Path& dst_port_path) : QueuedEvent(engine, request, timestamp) , _src_port_path(src_port_path) , _dst_port_path(dst_port_path) @@ -113,6 +115,8 @@ Disconnect::Impl::Impl(Engine& e, void Disconnect::pre_process() { + Glib::RWLock::WriterLock lock(_engine.engine_store()->lock()); + if (_src_port_path.parent().parent() != _dst_port_path.parent().parent() && _src_port_path.parent() != _dst_port_path.parent().parent() && _src_port_path.parent().parent() != _dst_port_path.parent()) { diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp index a553fe79..d0124ce1 100644 --- a/src/server/events/Disconnect.hpp +++ b/src/server/events/Disconnect.hpp @@ -46,12 +46,11 @@ namespace Events { class Disconnect : public QueuedEvent { public: - Disconnect( - Engine& engine, - SharedPtr<Request> request, - SampleCount timestamp, - const Raul::Path& src_port_path, - const Raul::Path& dst_port_path); + Disconnect(Engine& engine, + SharedPtr<Request> request, + SampleCount timestamp, + const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); void pre_process(); void execute(ProcessContext& context); diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 23db5167..f355575a 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -16,6 +16,7 @@ */ #include <boost/format.hpp> +#include <glibmm/thread.h> #include "raul/Array.hpp" #include "raul/Maid.hpp" @@ -98,7 +99,11 @@ DisconnectAll::maybe_remove_connection(ConnectionImpl* c) void DisconnectAll::pre_process() { + Glib::RWLock::WriterLock lock(_engine.engine_store()->lock(), Glib::NOT_LOCK); + if (!_deleting) { + lock.acquire(); + _parent = _engine.engine_store()->find_patch(_parent_path); if (_parent == NULL) { @@ -115,7 +120,8 @@ DisconnectAll::pre_process() return; } - if (object->parent_patch() != _parent && object->parent()->parent_patch() != _parent) { + if (object->parent_patch() != _parent + && object->parent()->parent_patch() != _parent) { _error = INVALID_PARENT_PATH; QueuedEvent::pre_process(); return; diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index 2e006b8c..ec2f763e 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -15,15 +15,18 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <glibmm/thread.h> + #include "raul/Path.hpp" -#include "events/Move.hpp" + #include "ClientBroadcaster.hpp" +#include "Driver.hpp" #include "Engine.hpp" -#include "NodeImpl.hpp" #include "EngineStore.hpp" +#include "NodeImpl.hpp" #include "PatchImpl.hpp" #include "Request.hpp" -#include "Driver.hpp" +#include "events/Move.hpp" using namespace std; using namespace Raul; @@ -48,6 +51,8 @@ Move::~Move() void Move::pre_process() { + Glib::RWLock::WriterLock lock(_engine.engine_store()->lock()); + if (!_old_path.parent().is_parent_of(_new_path)) { _error = PARENT_DIFFERS; QueuedEvent::pre_process(); diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp index 1a2d6b17..efa57198 100644 --- a/src/server/events/SetMetadata.cpp +++ b/src/server/events/SetMetadata.cpp @@ -57,7 +57,7 @@ SetMetadata::SetMetadata( const URI& subject, const Properties& properties, const Properties& remove) - : QueuedEvent(engine, request, timestamp, false) + : QueuedEvent(engine, request, timestamp) , _create_event(NULL) , _subject(subject) , _properties(properties) @@ -67,6 +67,7 @@ SetMetadata::SetMetadata( , _compiled_patch(NULL) , _create(create) , _context(context) + , _lock(engine.engine_store()->lock(), Glib::NOT_LOCK) { if (context != Resource::DEFAULT) { Resource::set_context(_properties, context); @@ -102,6 +103,8 @@ SetMetadata::pre_process() const bool is_graph_object = Path::is_path(_subject); + _lock.acquire(); + _object = is_graph_object ? _engine.engine_store()->find_object(Path(_subject.str())) : static_cast<Shared::ResourceImpl*>(_engine.node_factory()->plugin(_subject)); @@ -135,7 +138,6 @@ SetMetadata::pre_process() _create_event = new CreateNode(_engine, sub_request, _time, path, p->second.get_uri(), _properties); } else if (is_port) { - _blocking = bool(_request); _create_event = new CreatePort(_engine, sub_request, _time, path, data_type.uri(), is_output, _properties); } @@ -219,7 +221,6 @@ SetMetadata::pre_process() } else if (key == uris.ingen_polyphony) { if (value.type() == Atom::INT) { op = POLYPHONY; - _blocking = true; _patch->prepare_internal_poly(*_engine.buffer_factory(), value.get_int32()); } else { _error = BAD_VALUE_TYPE; @@ -230,7 +231,6 @@ SetMetadata::pre_process() if (parent) { if (value.type() == Atom::BOOL) { op = POLYPHONIC; - _blocking = true; obj->set_property(key, value.get_bool(), value.context()); NodeImpl* node = dynamic_cast<NodeImpl*>(obj); if (node) @@ -340,9 +340,6 @@ SetMetadata::execute(ProcessContext& context) } QueuedEvent::execute(context); - - if (_blocking) - _request->unblock(); } void @@ -380,6 +377,8 @@ SetMetadata::post_process() % _subject % _error_predicate).str()); break; } + + _lock.release(); } } // namespace Server diff --git a/src/server/events/SetMetadata.hpp b/src/server/events/SetMetadata.hpp index 6e2a93a2..bf359b79 100644 --- a/src/server/events/SetMetadata.hpp +++ b/src/server/events/SetMetadata.hpp @@ -18,6 +18,7 @@ #ifndef INGEN_EVENTS_SETMETADATA_HPP #define INGEN_EVENTS_SETMETADATA_HPP +#include <glibmm/thread.h> #include <vector> @@ -120,6 +121,8 @@ private: ControlBindings::Key _binding; SharedPtr<ControlBindings::Bindings> _old_bindings; + + Glib::RWLock::WriterLock _lock; }; } // namespace Server |