summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/Driver.hpp12
-rw-r--r--src/libs/engine/JackAudioDriver.cpp18
-rw-r--r--src/libs/engine/JackAudioDriver.hpp4
-rw-r--r--src/libs/engine/JackMidiDriver.cpp24
-rw-r--r--src/libs/engine/JackMidiDriver.hpp5
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.cpp23
-rw-r--r--src/libs/engine/events/RenameEvent.cpp47
7 files changed, 93 insertions, 40 deletions
diff --git a/src/libs/engine/Driver.hpp b/src/libs/engine/Driver.hpp
index 012b4ab0..13a5a432 100644
--- a/src/libs/engine/Driver.hpp
+++ b/src/libs/engine/Driver.hpp
@@ -22,6 +22,7 @@
#include <boost/utility.hpp>
#include <raul/Path.hpp>
#include "DataType.hpp"
+#include "DuplexPort.hpp"
namespace Ingen {
@@ -43,13 +44,14 @@ public:
/** Set the name of the system port */
virtual void set_name(const std::string& name) = 0;
- bool is_input() { return _is_input; }
+ bool is_input() const { return _patch_port->is_input(); }
+ DuplexPort* patch_port() const { return _patch_port; }
protected:
/** is_input from the perspective outside of ingen */
- DriverPort(bool is_input) : _is_input(is_input) {}
+ DriverPort(DuplexPort* port) : _patch_port(port) {}
- bool _is_input;
+ DuplexPort* _patch_port;
};
@@ -74,13 +76,15 @@ public:
virtual void deactivate() = 0;
virtual bool is_activated() const = 0;
-
+
/** Create a port ready to be inserted with add_input (non realtime).
*
* May return NULL if the Driver can not drive the port for some reason.
*/
virtual DriverPort* create_port(DuplexPort* patch_port) = 0;
+ virtual DriverPort* driver_port(const Raul::Path& path) = 0;
+
virtual void add_port(DriverPort* port) = 0;
virtual DriverPort* remove_port(const Raul::Path& path) = 0;
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
index c8a26510..0d4eb878 100644
--- a/src/libs/engine/JackAudioDriver.cpp
+++ b/src/libs/engine/JackAudioDriver.cpp
@@ -48,12 +48,11 @@ namespace Ingen {
//// JackAudioPort ////
JackAudioPort::JackAudioPort(JackAudioDriver* driver, DuplexPort* patch_port)
-: DriverPort(patch_port->is_input()),
+: DriverPort(patch_port),
Raul::ListNode<JackAudioPort*>(this),
_driver(driver),
_jack_port(NULL),
- _jack_buffer(NULL),
- _patch_port(patch_port)
+ _jack_buffer(NULL)
{
assert(patch_port->poly() == 1);
@@ -253,6 +252,19 @@ JackAudioDriver::create_port(DuplexPort* patch_port)
}
+DriverPort*
+JackAudioDriver::driver_port(const Path& path)
+{
+ assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
+
+ for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return (*i);
+
+ return NULL;
+}
+
+
/**** Jack Callbacks ****/
diff --git a/src/libs/engine/JackAudioDriver.hpp b/src/libs/engine/JackAudioDriver.hpp
index f2678800..07877e6f 100644
--- a/src/libs/engine/JackAudioDriver.hpp
+++ b/src/libs/engine/JackAudioDriver.hpp
@@ -52,13 +52,11 @@ public:
void prepare_buffer(jack_nframes_t nframes);
jack_port_t* jack_port() const { return _jack_port; }
- DuplexPort* patch_port() const { return _patch_port; }
private:
JackAudioDriver* _driver;
jack_port_t* _jack_port;
jack_sample_t* _jack_buffer; ///< Cached for output ports
- DuplexPort* _patch_port;
};
@@ -91,6 +89,8 @@ public:
void add_port(DriverPort* port);
DriverPort* remove_port(const Raul::Path& path);
+ DriverPort* driver_port(const Raul::Path& path);
+
Patch* root_patch() { return _root_patch; }
void set_root_patch(Patch* patch) { _root_patch = patch; }
diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp
index 730f5d80..b07a4e37 100644
--- a/src/libs/engine/JackMidiDriver.cpp
+++ b/src/libs/engine/JackMidiDriver.cpp
@@ -39,11 +39,10 @@ namespace Ingen {
//// JackMidiPort ////
JackMidiPort::JackMidiPort(JackMidiDriver* driver, DuplexPort* patch_port)
-: DriverPort(patch_port->is_input()),
+: DriverPort(patch_port),
Raul::ListNode<JackMidiPort*>(this),
_driver(driver),
- _jack_port(NULL),
- _patch_port(patch_port)
+ _jack_port(NULL)
{
assert(patch_port->poly() == 1);
@@ -240,6 +239,25 @@ JackMidiDriver::remove_port(const Path& path)
return NULL;
}
+
+DriverPort*
+JackMidiDriver::driver_port(const Path& path)
+{
+ assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
+
+ // FIXME: duplex?
+
+ for (Raul::List<JackMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return (*i);
+
+ for (Raul::List<JackMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return (*i);
+
+ return NULL;
+}
+
} // namespace Ingen
diff --git a/src/libs/engine/JackMidiDriver.hpp b/src/libs/engine/JackMidiDriver.hpp
index ce83266f..5d7ae493 100644
--- a/src/libs/engine/JackMidiDriver.hpp
+++ b/src/libs/engine/JackMidiDriver.hpp
@@ -46,13 +46,10 @@ public:
void post_process(ProcessContext& context);
void set_name(const std::string& name) { jack_port_set_name(_jack_port, name.c_str()); };
-
- DuplexPort* patch_port() const { return _patch_port; }
private:
JackMidiDriver* _driver;
jack_port_t* _jack_port;
- DuplexPort* _patch_port;
};
@@ -85,6 +82,8 @@ public:
void add_port(DriverPort* port);
DriverPort* remove_port(const Raul::Path& path);
+
+ DriverPort* driver_port(const Raul::Path& path);
jack_client_t* jack_client() { return _client; }
diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp
index b1f76dd6..26f31549 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.cpp
+++ b/src/libs/engine/events/DisconnectNodeEvent.cpp
@@ -15,26 +15,23 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "DisconnectNodeEvent.hpp"
-#include <iostream>
-#include <raul/List.hpp>
#include <raul/Array.hpp>
+#include <raul/List.hpp>
#include <raul/Maid.hpp>
-#include "Responder.hpp"
-#include "Engine.hpp"
-#include "Node.hpp"
+#include <raul/Path.hpp>
+#include "ClientBroadcaster.hpp"
#include "Connection.hpp"
+#include "DisconnectNodeEvent.hpp"
#include "DisconnectionEvent.hpp"
-#include "Port.hpp"
+#include "Engine.hpp"
#include "InputPort.hpp"
+#include "Node.hpp"
+#include "ObjectStore.hpp"
#include "OutputPort.hpp"
#include "Patch.hpp"
-#include "ClientBroadcaster.hpp"
+#include "Port.hpp"
+#include "Responder.hpp"
#include "util.hpp"
-#include "ObjectStore.hpp"
-#include <raul/Path.hpp>
-
-using std::cerr; using std::endl;
namespace Ingen {
@@ -75,8 +72,6 @@ DisconnectNodeEvent::pre_process()
{
typedef Raul::List<Connection*>::const_iterator ConnectionListIterator;
- // cerr << "Preparing disconnection event...\n";
-
if (_lookup) {
_patch = _engine.object_store()->find_patch(_node_path.parent());
diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp
index 1ec3b0d1..9e5ef543 100644
--- a/src/libs/engine/events/RenameEvent.cpp
+++ b/src/libs/engine/events/RenameEvent.cpp
@@ -15,15 +15,17 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <raul/Path.hpp>
+#include "ClientBroadcaster.hpp"
+#include "Engine.hpp"
+#include "Node.hpp"
+#include "ObjectStore.hpp"
+#include "Patch.hpp"
#include "RenameEvent.hpp"
#include "Responder.hpp"
-#include "Patch.hpp"
-#include "Node.hpp"
#include "Tree.hpp"
-#include "Engine.hpp"
-#include "ClientBroadcaster.hpp"
-#include <raul/Path.hpp>
-#include "ObjectStore.hpp"
+#include "AudioDriver.hpp"
+#include "MidiDriver.hpp"
using namespace std;
@@ -34,7 +36,7 @@ RenameEvent::RenameEvent(Engine& engine, SharedPtr<Responder> responder, SampleC
: QueuedEvent(engine, responder, timestamp),
_old_path(path),
_name(name),
- _new_path(_old_path.parent().base() + name),
+ _new_path("/"),
_parent_patch(NULL),
_store_iterator(engine.object_store()->objects().end()),
_error(NO_ERROR)
@@ -55,19 +57,27 @@ RenameEvent::~RenameEvent()
void
RenameEvent::pre_process()
{
- if (_name.find("/") != string::npos) {
+ if ((!Raul::Path::is_valid_name(_name)) || _name.find("/") != string::npos) {
_error = INVALID_NAME;
QueuedEvent::pre_process();
return;
}
+ _new_path = _old_path.parent().base() + _name;
+
_store_iterator = _engine.object_store()->find(_old_path);
if (_store_iterator == _engine.object_store()->objects().end()) {
_error = OBJECT_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
-
+
+ if (_engine.object_store()->find_object(_new_path)) {
+ _error = OBJECT_EXISTS;
+ QueuedEvent::pre_process();
+ return;
+ }
+
Table<Path,GraphObject*> removed = _engine.object_store()->remove(_store_iterator);
assert(removed.size() > 0);
@@ -81,7 +91,6 @@ RenameEvent::pre_process()
else
child_new_path = _new_path.base() + child_old_path.substr(_old_path.length()+1);
- cerr << "Renamed " << child_old_path << " -> " << child_new_path << endl;
i->second->set_path(child_new_path);
i->first = child_new_path;
}
@@ -95,8 +104,24 @@ RenameEvent::pre_process()
void
RenameEvent::execute(ProcessContext& context)
{
- //cout << "Executing rename event...";
QueuedEvent::execute(context);
+
+ Port* port = dynamic_cast<Port*>(_store_iterator->second);
+ if (port && port->parent()->parent() == NULL) {
+ DriverPort* driver_port = NULL;
+
+ if (port->type() == DataType::FLOAT)
+ driver_port = _engine.audio_driver()->driver_port(_new_path);
+ else if (port->type() == DataType::MIDI)
+ driver_port = _engine.midi_driver()->driver_port(_new_path);
+
+ if (driver_port) {
+ cerr << "DRIVER PORT :)!" << endl;
+ driver_port->set_name(_new_path);
+ } else {
+ cerr << "NO DRIVER PORT :(" << endl;
+ }
+ }
}