summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Buffer.hpp4
-rw-r--r--src/server/BufferFactory.hpp2
-rw-r--r--src/server/CompiledPatch.hpp7
-rw-r--r--src/server/ConnectionImpl.hpp8
-rw-r--r--src/server/Driver.hpp5
-rw-r--r--src/server/Engine.cpp6
-rw-r--r--src/server/EventBuffer.hpp2
-rw-r--r--src/server/InputPort.cpp4
-rw-r--r--src/server/NodeImpl.hpp12
-rw-r--r--src/server/ObjectBuffer.hpp2
-rw-r--r--src/server/ObjectSender.cpp2
-rw-r--r--src/server/PatchImpl.hpp8
-rw-r--r--src/server/PortImpl.cpp3
-rw-r--r--src/server/PortImpl.hpp6
-rw-r--r--src/server/PortType.hpp96
-rw-r--r--src/server/events/CreatePort.cpp35
-rw-r--r--src/server/events/CreatePort.hpp9
-rw-r--r--src/server/events/SetMetadata.cpp12
-rw-r--r--src/server/mix.hpp4
19 files changed, 181 insertions, 46 deletions
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 45afa6aa..0b3c9348 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -24,13 +24,13 @@
#include <boost/intrusive_ptr.hpp>
#include <boost/utility.hpp>
-#include "ingen/PortType.hpp"
#include "raul/AtomicInt.hpp"
#include "raul/Deletable.hpp"
#include "raul/SharedPtr.hpp"
-#include "types.hpp"
#include "BufferFactory.hpp"
+#include "PortType.hpp"
+#include "types.hpp"
namespace Ingen {
namespace Server {
diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp
index 58dc55af..5690113c 100644
--- a/src/server/BufferFactory.hpp
+++ b/src/server/BufferFactory.hpp
@@ -20,10 +20,10 @@
#include <map>
#include <boost/intrusive_ptr.hpp>
-#include "ingen/PortType.hpp"
#include "glibmm/thread.h"
#include "raul/RingBuffer.hpp"
#include "raul/AtomicPtr.hpp"
+#include "PortType.hpp"
#include "types.hpp"
namespace Ingen {
diff --git a/src/server/CompiledPatch.hpp b/src/server/CompiledPatch.hpp
index 65ee9fad..519b5a2a 100644
--- a/src/server/CompiledPatch.hpp
+++ b/src/server/CompiledPatch.hpp
@@ -19,14 +19,17 @@
#define INGEN_ENGINE_COMPILEDPATCH_HPP
#include <vector>
-#include "raul/List.hpp"
-#include "raul/Deletable.hpp"
+
#include <boost/utility.hpp>
+#include "raul/Deletable.hpp"
+#include "raul/List.hpp"
+
namespace Ingen {
namespace Server {
class ConnectionImpl;
+class NodeImpl;
/** All information required about a node to execute it in an audio thread.
*/
diff --git a/src/server/ConnectionImpl.hpp b/src/server/ConnectionImpl.hpp
index 9dd71233..33ec0608 100644
--- a/src/server/ConnectionImpl.hpp
+++ b/src/server/ConnectionImpl.hpp
@@ -19,13 +19,15 @@
#define INGEN_ENGINE_CONNECTIONIMPL_HPP
#include <cstdlib>
+
#include <boost/intrusive_ptr.hpp>
#include <boost/utility.hpp>
-#include "raul/log.hpp"
-#include "raul/Deletable.hpp"
-#include "ingen/PortType.hpp"
+
#include "ingen/Connection.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
+#include "raul/Deletable.hpp"
+#include "raul/log.hpp"
+
#include "PortImpl.hpp"
using namespace std;
diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp
index f9416e3e..0178b4f0 100644
--- a/src/server/Driver.hpp
+++ b/src/server/Driver.hpp
@@ -21,7 +21,6 @@
#include <string>
#include <boost/utility.hpp>
#include "raul/Deletable.hpp"
-#include "ingen/PortType.hpp"
#include "ingen/EventType.hpp"
#include "DuplexPort.hpp"
@@ -96,10 +95,6 @@ public:
virtual Raul::Deletable* remove_port(const Raul::Path& path,
DriverPort** port=NULL) = 0;
- /** Return true iff this driver supports the given type of I/O */
- virtual bool supports(PortType port_type,
- EventType event_type) = 0;
-
virtual void set_root_patch(PatchImpl* patch) = 0;
virtual PatchImpl* root_patch() = 0;
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 301d90e1..5d27ae2e 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -177,6 +177,7 @@ Engine::activate()
// Add control input
Resource::Properties in_properties(control_properties);
in_properties.insert(make_pair(uris.rdf_type, uris.lv2_InputPort));
+ in_properties.insert(make_pair(uris.rdf_type, uris.ev_EventPort));
in_properties.insert(make_pair(uris.lv2_index, 0));
in_properties.insert(make_pair(uris.ingenui_canvas_x,
Resource::Property(32.0f, Resource::EXTERNAL)));
@@ -185,11 +186,12 @@ Engine::activate()
execute_and_delete_event(context, new Events::CreatePort(
*this, SharedPtr<Request>(), 0,
- "/control_in", uris.ev_EventPort, false, in_properties));
+ "/control_in", false, in_properties));
// Add control out
Resource::Properties out_properties(control_properties);
out_properties.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort));
+ out_properties.insert(make_pair(uris.rdf_type, uris.ev_EventPort));
out_properties.insert(make_pair(uris.lv2_index, 1));
out_properties.insert(make_pair(uris.ingenui_canvas_x,
Resource::Property(128.0f, Resource::EXTERNAL)));
@@ -198,7 +200,7 @@ Engine::activate()
execute_and_delete_event(context, new Events::CreatePort(
*this, SharedPtr<Request>(), 0,
- "/control_out", uris.ev_EventPort, true, out_properties));
+ "/control_out", true, out_properties));
}
_driver->activate();
diff --git a/src/server/EventBuffer.hpp b/src/server/EventBuffer.hpp
index de67ae0c..668a0c6b 100644
--- a/src/server/EventBuffer.hpp
+++ b/src/server/EventBuffer.hpp
@@ -21,7 +21,7 @@
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/event/event.h"
#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h"
-#include "ingen/PortType.hpp"
+
#include "Buffer.hpp"
namespace Ingen {
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 4a1c9d25..2abd17eb 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -72,8 +72,8 @@ InputPort::apply_poly(Maid& maid, uint32_t poly)
return true;
}
-/** Set \a buffers appropriately if this port has \a num_connections connections.
- * \return true iff buffers are locally owned by the port
+/** Set @a buffers to the buffers to be used for this port.
+ * @return true iff buffers are locally owned by the port
*/
bool
InputPort::get_buffers(BufferFactory& bufs,
diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp
index 0009316e..3fc4a5d6 100644
--- a/src/server/NodeImpl.hpp
+++ b/src/server/NodeImpl.hpp
@@ -19,12 +19,16 @@
#define INGEN_ENGINE_NODEIMPL_HPP
#include <string>
+
#include <boost/intrusive_ptr.hpp>
+
+#include "ingen/Node.hpp"
#include "raul/Array.hpp"
#include "raul/AtomicInt.hpp"
#include "raul/Semaphore.hpp"
-#include "ingen/Node.hpp"
+
#include "GraphObjectImpl.hpp"
+#include "PortType.hpp"
#include "types.hpp"
namespace Raul { template <typename T> class List; class Maid; }
@@ -183,8 +187,10 @@ public:
virtual void plugin(PluginImpl* pi) { _plugin = pi; }
- virtual void set_buffer_size(Context& context, BufferFactory& bufs,
- PortType type, size_t size);
+ virtual void set_buffer_size(Context& context,
+ BufferFactory& bufs,
+ PortType type,
+ size_t size);
/** The Patch this Node belongs to. */
inline PatchImpl* parent_patch() const { return (PatchImpl*)_parent; }
diff --git a/src/server/ObjectBuffer.hpp b/src/server/ObjectBuffer.hpp
index 11481ad1..93dc746b 100644
--- a/src/server/ObjectBuffer.hpp
+++ b/src/server/ObjectBuffer.hpp
@@ -19,7 +19,7 @@
#define INGEN_ENGINE_OBJECTBUFFER_HPP
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
-#include "ingen/PortType.hpp"
+
#include "Buffer.hpp"
namespace Ingen {
diff --git a/src/server/ObjectSender.cpp b/src/server/ObjectSender.cpp
index a166a885..16255135 100644
--- a/src/server/ObjectSender.cpp
+++ b/src/server/ObjectSender.cpp
@@ -24,7 +24,7 @@
#include "PortImpl.hpp"
#include "ConnectionImpl.hpp"
#include "NodeFactory.hpp"
-#include "ingen/PortType.hpp"
+#include "PortType.hpp"
#include "AudioBuffer.hpp"
using namespace std;
diff --git a/src/server/PatchImpl.hpp b/src/server/PatchImpl.hpp
index 20ff59a6..5795a066 100644
--- a/src/server/PatchImpl.hpp
+++ b/src/server/PatchImpl.hpp
@@ -20,12 +20,14 @@
#include <cstdlib>
#include <string>
-#include "raul/List.hpp"
-#include "ingen/PortType.hpp"
+
#include "ingen/Patch.hpp"
+#include "raul/List.hpp"
+
+#include "CompiledPatch.hpp"
#include "NodeImpl.hpp"
#include "PluginImpl.hpp"
-#include "CompiledPatch.hpp"
+#include "PortType.hpp"
namespace Ingen {
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 73953b5c..ce75321d 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -22,8 +22,6 @@
#include "shared/LV2URIMap.hpp"
-#include "ingen/PortType.hpp"
-
#include "AudioBuffer.hpp"
#include "BufferFactory.hpp"
#include "Engine.hpp"
@@ -33,6 +31,7 @@
#include "Notification.hpp"
#include "ObjectBuffer.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "ThreadManager.hpp"
using namespace std;
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index caf291f0..7baaf089 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -26,11 +26,11 @@
#include "raul/Atom.hpp"
#include "ingen/Port.hpp"
-#include "ingen/PortType.hpp"
#include "Buffer.hpp"
#include "Context.hpp"
#include "GraphObjectImpl.hpp"
+#include "PortType.hpp"
#include "types.hpp"
namespace Raul { class Maid; }
@@ -123,8 +123,12 @@ public:
uint32_t index() const { return _index; }
+ typedef std::set<PortType> PortTypes;
+
const PortTypes& types() const { return _types; }
+ inline bool is_a(PortType type) const { return _types.find(type) != _types.end(); }
+
PortType buffer_type() const;
bool supports(const Raul::URI& value_type) const;
diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp
new file mode 100644
index 00000000..1fc9f995
--- /dev/null
+++ b/src/server/PortType.hpp
@@ -0,0 +1,96 @@
+/* This file is part of Ingen.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef INGEN_INTERFACE_PORTTYPE_HPP
+#define INGEN_INTERFACE_PORTTYPE_HPP
+
+#include "raul/URI.hpp"
+
+namespace Ingen {
+
+/** The type of a port.
+ *
+ * This type refers to the type of the port itself (not necessarily the type
+ * of its contents). Ports with different types can contain the same type of
+ * data, but may e.g. have different access semantics.
+ */
+class PortType {
+public:
+ enum Symbol {
+ UNKNOWN = 0,
+ AUDIO = 1,
+ CONTROL = 2,
+ EVENTS = 3,
+ VALUE = 4,
+ MESSAGE = 5,
+ };
+
+ PortType(const Raul::URI& uri)
+ : _symbol(UNKNOWN)
+ {
+ if (uri == type_uri(AUDIO)) {
+ _symbol = AUDIO;
+ } else if (uri == type_uri(CONTROL)) {
+ _symbol = CONTROL;
+ } else if (uri == type_uri(EVENTS)) {
+ _symbol = EVENTS;
+ } else if (uri == type_uri(VALUE)) {
+ _symbol = VALUE;
+ } else if (uri == type_uri(MESSAGE)) {
+ _symbol = MESSAGE;
+ }
+ }
+
+ PortType(Symbol symbol)
+ : _symbol(symbol)
+ {}
+
+ inline const Raul::URI& uri() const { return type_uri(_symbol); }
+ inline Symbol symbol() const { return _symbol; }
+
+ inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); }
+ inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); }
+ inline bool operator==(const PortType& type) const { return (_symbol == type._symbol); }
+ inline bool operator!=(const PortType& type) const { return (_symbol != type._symbol); }
+ inline bool operator<(const PortType& type) const { return (_symbol < type._symbol); }
+
+ inline bool is_audio() { return _symbol == AUDIO; }
+ inline bool is_control() { return _symbol == CONTROL; }
+ inline bool is_events() { return _symbol == EVENTS; }
+ inline bool is_value() { return _symbol == VALUE; }
+ inline bool is_message() { return _symbol == MESSAGE; }
+
+private:
+ static inline const Raul::URI& type_uri(unsigned symbol_num) {
+ assert(symbol_num <= MESSAGE);
+ static const Raul::URI uris[] = {
+ "http://drobilla.net/ns/ingen#nil",
+ "http://lv2plug.in/ns/lv2core#AudioPort",
+ "http://lv2plug.in/ns/lv2core#ControlPort",
+ "http://lv2plug.in/ns/ext/event#EventPort",
+ "http://lv2plug.in/ns/ext/atom#ValuePort",
+ "http://lv2plug.in/ns/ext/atom#MessagePort"
+ };
+ return uris[symbol_num];
+ }
+
+ Symbol _symbol;
+};
+
+} // namespace Ingen
+
+#endif // INGEN_INTERFACE_PORTTYPE_HPP
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 5c3ecbd2..c6d7c296 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -46,21 +46,46 @@ CreatePort::CreatePort(
SharedPtr<Request> request,
SampleCount timestamp,
const Raul::Path& path,
- const Raul::URI& type,
bool is_output,
const Resource::Properties& properties)
: QueuedEvent(engine, request, timestamp)
, _path(path)
- , _type(type)
- , _is_output(is_output)
- , _data_type(type)
+ , _data_type(PortType::UNKNOWN)
, _patch(NULL)
, _patch_port(NULL)
+ , _ports_array(NULL)
, _driver_port(NULL)
, _properties(properties)
+ , _is_output(is_output)
{
- if (_data_type == PortType::UNKNOWN)
+ const Ingen::Shared::LV2URIMap& uris = *_engine.world()->uris().get();
+
+ typedef Resource::Properties::const_iterator Iterator;
+ typedef std::pair<Iterator, Iterator> Range;
+ const Range types = properties.equal_range(uris.rdf_type);
+ for (Iterator i = types.first; i != types.second; ++i) {
+ const Raul::Atom& type = i->second;
+ if (type.type() != Atom::URI) {
+ warn << "Non-URI port type " << type << endl;
+ continue;
+ }
+
+ if (type == uris.lv2_AudioPort) {
+ _data_type = PortType::AUDIO;
+ } else if (type == uris.lv2_ControlPort) {
+ _data_type = PortType::CONTROL;
+ } else if (type == uris.ev_EventPort) {
+ _data_type = PortType::EVENTS;
+ } else if (type == uris.atom_ValuePort) {
+ _data_type = PortType::VALUE;
+ } else if (type == uris.atom_MessagePort) {
+ _data_type = PortType::MESSAGE;
+ }
+ }
+
+ if (_data_type == PortType::UNKNOWN) {
_error = UNKNOWN_TYPE;
+ }
}
void
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 56c0f0a0..4b1b03fa 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -21,9 +21,9 @@
#include "raul/Array.hpp"
#include "raul/Path.hpp"
-#include "ingen/PortType.hpp"
#include "ingen/Resource.hpp"
+#include "PortType.hpp"
#include "QueuedEvent.hpp"
namespace Ingen {
@@ -47,7 +47,6 @@ public:
SharedPtr<Request> request,
SampleCount timestamp,
const Raul::Path& path,
- const Raul::URI& type,
bool is_output,
const Resource::Properties& properties);
@@ -65,15 +64,13 @@ private:
Raul::Path _path;
Raul::URI _type;
- bool _is_output;
PortType _data_type;
PatchImpl* _patch;
PortImpl* _patch_port;
Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports array for Patch
DriverPort* _driver_port; ///< Driver (eg Jack) port if this is a toplevel port
- bool _succeeded;
-
- Resource::Properties _properties;
+ Resource::Properties _properties;
+ bool _is_output;
};
} // namespace Server
diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp
index bef968fc..4e40baeb 100644
--- a/src/server/events/SetMetadata.cpp
+++ b/src/server/events/SetMetadata.cpp
@@ -16,11 +16,12 @@
*/
#include <string>
+
#include <boost/format.hpp>
+
#include "raul/log.hpp"
#include "raul/Maid.hpp"
-#include "ingen/PortType.hpp"
-#include "shared/LV2URIMap.hpp"
+
#include "ClientBroadcaster.hpp"
#include "ControlBindings.hpp"
#include "CreateNode.hpp"
@@ -33,9 +34,11 @@
#include "PatchImpl.hpp"
#include "PluginImpl.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "Request.hpp"
#include "SetMetadata.hpp"
#include "SetPortValue.hpp"
+#include "shared/LV2URIMap.hpp"
#define LOG(s) s << "[SetMetadata] "
@@ -120,8 +123,7 @@ SetMetadata::pre_process()
if (is_graph_object && !_object) {
Path path(_subject.str());
bool is_patch = false, is_node = false, is_port = false, is_output = false;
- PortType data_type(PortType::UNKNOWN);
- Shared::ResourceImpl::type(uris, _properties, is_patch, is_node, is_port, is_output, data_type);
+ Shared::ResourceImpl::type(uris, _properties, is_patch, is_node, is_port, is_output);
// Create a separate request without a source so EventSource isn't unblocked twice
SharedPtr<Request> sub_request(new Request(NULL, _request->client(), _request->id()));
@@ -139,7 +141,7 @@ SetMetadata::pre_process()
path, p->second.get_uri(), _properties);
} else if (is_port) {
_create_event = new CreatePort(_engine, sub_request, _time,
- path, data_type.uri(), is_output, _properties);
+ path, is_output, _properties);
}
if (_create_event) {
_create_event->pre_process();
diff --git a/src/server/mix.hpp b/src/server/mix.hpp
index 79b02477..c90c0e17 100644
--- a/src/server/mix.hpp
+++ b/src/server/mix.hpp
@@ -19,10 +19,12 @@
#define INGEN_ENGINE_MIX_HPP
#include <boost/intrusive_ptr.hpp>
+
#include "raul/log.hpp"
-#include "ingen/PortType.hpp"
+
#include "Buffer.hpp"
#include "Context.hpp"
+#include "PortType.hpp"
using namespace Raul;