summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/DirectDriver.hpp78
-rw-r--r--src/server/Engine.cpp25
-rw-r--r--src/server/Engine.hpp1
-rw-r--r--src/server/events/CreatePort.cpp112
-rw-r--r--src/server/wscript13
5 files changed, 175 insertions, 54 deletions
diff --git a/src/server/DirectDriver.hpp b/src/server/DirectDriver.hpp
new file mode 100644
index 00000000..b6d66df6
--- /dev/null
+++ b/src/server/DirectDriver.hpp
@@ -0,0 +1,78 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2012 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or 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 Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_ENGINE_DIRECT_DRIVER_HPP
+#define INGEN_ENGINE_DIRECT_DRIVER_HPP
+
+#include "Driver.hpp"
+
+namespace Ingen {
+namespace Server {
+
+/** Driver for running Ingen directly as a library.
+ * \ingroup engine
+ */
+class DirectDriver : public Driver {
+public:
+ DirectDriver(double sample_rate, SampleCount block_length)
+ : _sample_rate(sample_rate)
+ , _block_length(block_length)
+ {}
+
+ virtual ~DirectDriver() {}
+
+ virtual void activate() {}
+
+ virtual void deactivate() {}
+
+ virtual EnginePort* create_port(DuplexPort* patch_port) {
+ return NULL;
+ }
+
+ virtual EnginePort* engine_port(ProcessContext& context,
+ const Raul::Path& path) {
+ return NULL;
+ }
+
+ virtual void add_port(ProcessContext& context, EnginePort* port) {}
+
+ virtual Raul::Deletable* remove_port(ProcessContext& context,
+ const Raul::Path& path,
+ EnginePort** port = NULL) {
+ return NULL;
+ }
+
+ virtual SampleCount block_length() const { return _block_length; }
+
+ virtual SampleCount sample_rate() const { return _sample_rate; }
+
+ virtual SampleCount frame_time() const {
+ return 0;
+ }
+
+ virtual bool is_realtime() const {
+ return false;
+ }
+
+private:
+ SampleCount _sample_rate;
+ SampleCount _block_length;
+};
+
+} // namespace Server
+} // namespace Ingen
+
+#endif // INGEN_ENGINE_DIRECT_DRIVER_HPP
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 69ad435b..9359bacf 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -14,7 +14,6 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cassert>
#include <sys/mman.h>
#include <unistd.h>
@@ -31,6 +30,7 @@
#include "Broadcaster.hpp"
#include "BufferFactory.hpp"
+#include "DirectDriver.hpp"
#include "ControlBindings.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
@@ -142,14 +142,24 @@ execute_and_delete_event(ProcessContext& context, Event* ev)
delete ev;
}
+void
+Engine::init(double sample_rate, uint32_t block_length)
+{
+ set_driver(SharedPtr<Driver>(new DirectDriver(sample_rate, block_length)));
+}
+
bool
Engine::activate()
{
- assert(_driver);
+ if (!_driver) {
+ return false;
+ }
+
ThreadManager::single_threaded = true;
_buffer_factory->set_block_length(_driver->block_length());
+ _pre_processor->start();
_message_context.Thread::start();
const Ingen::Shared::URIs& uris = world()->uris();
@@ -226,8 +236,15 @@ Engine::activate()
void
Engine::deactivate()
{
- _driver->deactivate();
- _root_patch->deactivate();
+ _pre_processor->stop();
+
+ if (_driver) {
+ _driver->deactivate();
+ }
+
+ if (_root_patch) {
+ _root_patch->deactivate();
+ }
ThreadManager::single_threaded = true;
}
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index 8fcb5ce6..edbe33ae 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -65,6 +65,7 @@ public:
virtual ~Engine();
// EngineBase methods
+ virtual void init(double sample_rate, uint32_t block_length);
virtual bool activate();
virtual void deactivate();
virtual unsigned run(uint32_t sample_count);
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index d8c183cd..a783512f 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -90,73 +90,85 @@ CreatePort::CreatePort(Engine& engine,
void
CreatePort::pre_process()
{
- if (_status == UNKNOWN_TYPE || _engine.engine_store()->find_object(_path)) {
+ if (_status) {
Event::pre_process();
return;
}
- _patch = _engine.engine_store()->find_patch(_path.parent());
+ if (_engine.engine_store()->find_object(_path)) {
+ _status = EXISTS;
+ Event::pre_process();
+ return;
+ }
+
+ if (!(_patch = _engine.engine_store()->find_patch(_path.parent()))) {
+ _status = PARENT_NOT_FOUND;
+ Event::pre_process();
+ return;
+ }
const Ingen::Shared::URIs& uris = _engine.world()->uris();
- if (_patch != NULL) {
- assert(_patch->path() == _path.parent());
-
- size_t buffer_size = _engine.buffer_factory()->default_buffer_size(_buffer_type);
-
- const uint32_t old_num_ports = (_patch->external_ports())
- ? _patch->external_ports()->size()
- : 0;
-
- Resource::Properties::const_iterator index_i = _properties.find(uris.lv2_index);
- if (index_i == _properties.end()) {
- index_i = _properties.insert(
- std::make_pair(uris.lv2_index,
- _engine.world()->forge().make(int32_t(old_num_ports))));
- } else if (index_i->second.type() != uris.forge.Int
- || index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) {
- Event::pre_process();
- _status = BAD_INDEX;
- return;
- }
+ assert(_patch->path() == _path.parent());
- Resource::Properties::const_iterator poly_i = _properties.find(uris.ingen_polyphonic);
- bool polyphonic = (poly_i != _properties.end() &&
- poly_i->second.type() == uris.forge.Bool &&
- poly_i->second.get_bool());
+ size_t buffer_size = _engine.buffer_factory()->default_buffer_size(_buffer_type);
- _patch_port = _patch->create_port(*_engine.buffer_factory(), _path.symbol(),
- _port_type, _buffer_type, buffer_size,
- _is_output, polyphonic);
+ const uint32_t old_num_ports = (_patch->external_ports())
+ ? _patch->external_ports()->size()
+ : 0;
- _patch_port->properties().insert(_properties.begin(), _properties.end());
+ Resource::Properties::const_iterator index_i = _properties.find(uris.lv2_index);
+ if (index_i == _properties.end()) {
+ index_i = _properties.insert(
+ std::make_pair(uris.lv2_index,
+ _engine.world()->forge().make(int32_t(old_num_ports))));
+ } else if (index_i->second.type() != uris.forge.Int
+ || index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) {
+ _status = BAD_INDEX;
+ Event::pre_process();
+ return;
+ }
- assert(index_i->second == _engine.world()->forge().make((int)_patch_port->index()));
+ Resource::Properties::const_iterator poly_i = _properties.find(uris.ingen_polyphonic);
+ bool polyphonic = (poly_i != _properties.end() &&
+ poly_i->second.type() == uris.forge.Bool &&
+ poly_i->second.get_bool());
- if (_patch_port) {
- if (_is_output)
- _patch->add_output(new Raul::List<PortImpl*>::Node(_patch_port));
- else
- _patch->add_input(new Raul::List<PortImpl*>::Node(_patch_port));
+ if (!(_patch_port = _patch->create_port(
+ *_engine.buffer_factory(), _path.symbol(),
+ _port_type, _buffer_type, buffer_size, _is_output, polyphonic))) {
+ _status = CREATION_FAILED;
+ Event::pre_process();
+ return;
+ }
- if (_patch->external_ports())
- _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, *_patch->external_ports(), NULL);
- else
- _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, NULL);
+ _patch_port->properties().insert(_properties.begin(), _properties.end());
- _ports_array->at(old_num_ports) = _patch_port;
- _engine.engine_store()->add(_patch_port);
+ assert(index_i->second == _engine.world()->forge().make((int)_patch_port->index()));
- if (!_patch->parent()) {
- _engine_port = _engine.driver()->create_port(
- dynamic_cast<DuplexPort*>(_patch_port));
- }
+ if (_patch_port) {
+ if (_is_output)
+ _patch->add_output(new Raul::List<PortImpl*>::Node(_patch_port));
+ else
+ _patch->add_input(new Raul::List<PortImpl*>::Node(_patch_port));
+
+ if (_patch->external_ports())
+ _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, *_patch->external_ports(), NULL);
+ else
+ _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, NULL);
+
+ _ports_array->at(old_num_ports) = _patch_port;
+ _engine.engine_store()->add(_patch_port);
+
+ if (!_patch->parent()) {
+ _engine_port = _engine.driver()->create_port(
+ dynamic_cast<DuplexPort*>(_patch_port));
+ }
- assert(_ports_array->size() == _patch->num_ports_non_rt());
+ assert(_ports_array->size() == _patch->num_ports_non_rt());
- } else {
- _status = CREATION_FAILED;
- }
+ } else {
+ _status = CREATION_FAILED;
}
_update = _patch_port->properties();
diff --git a/src/server/wscript b/src/server/wscript
index 4cb61be5..8f505983 100644
--- a/src/server/wscript
+++ b/src/server/wscript
@@ -60,6 +60,19 @@ def build(bld):
core_libs = 'GLIBMM GTHREAD LV2 LILV RAUL SORD'
autowaf.use_lib(bld, obj, core_libs)
+ if bld.env['BUILD_TESTS']:
+ obj = bld(features = 'cxx cxxshlib',
+ source = core_source,
+ export_includes = ['../..'],
+ includes = ['.', '../..'],
+ name = 'libingen_server_profiled',
+ target = 'ingen_server_profiled',
+ install_path = '${LIBDIR}',
+ use = 'libingen_shared_profiled',
+ lib = bld.env['INGEN_TEST_LIBS'],
+ cxxflags = bld.env['INGEN_TEST_CXXFLAGS'])
+ autowaf.use_lib(bld, obj, core_libs)
+
if bld.is_defined('HAVE_JACK'):
obj = bld(features = 'cxx cxxshlib',
source = 'JackDriver.cpp ingen_jack.cpp',