summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-21 03:27:16 +0000
committerDavid Robillard <d@drobilla.net>2006-06-21 03:27:16 +0000
commita603f4a917bd5a7d806ff8394e2bfbe0f64acc64 (patch)
treecb2fe94e1bb08c8d603918bf94d8ee362e98d4eb /src/libs/engine/events
parent032d526710d174b30e0c9f33ff9f7e60e99fb172 (diff)
downloadingen-a603f4a917bd5a7d806ff8394e2bfbe0f64acc64.tar.gz
ingen-a603f4a917bd5a7d806ff8394e2bfbe0f64acc64.tar.bz2
ingen-a603f4a917bd5a7d806ff8394e2bfbe0f64acc64.zip
Got the audio flowing
git-svn-id: http://svn.drobilla.net/lad/grauph@70 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events')
-rw-r--r--src/libs/engine/events/AddPortEvent.cpp41
-rw-r--r--src/libs/engine/events/AddPortEvent.h16
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp8
3 files changed, 37 insertions, 28 deletions
diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp
index 0318c5c0..43cc797a 100644
--- a/src/libs/engine/events/AddPortEvent.cpp
+++ b/src/libs/engine/events/AddPortEvent.cpp
@@ -29,7 +29,10 @@
#include "util/Path.h"
#include "Port.h"
#include "AudioDriver.h"
+#include "MidiDriver.h"
#include "List.h"
+#include "Driver.h"
+#include "DuplexPort.h"
namespace Om {
@@ -41,7 +44,8 @@ AddPortEvent::AddPortEvent(CountedPtr<Responder> responder, const string& path,
_is_output(is_output),
_data_type(DataType::UNKNOWN),
_patch(NULL),
- _port(NULL),
+ _patch_port(NULL),
+ _driver_port(NULL),
_succeeded(true)
{
string type_str;
@@ -52,11 +56,6 @@ AddPortEvent::AddPortEvent(CountedPtr<Responder> responder, const string& path,
}
-AddPortEvent::~AddPortEvent()
-{
-}
-
-
void
AddPortEvent::pre_process()
{
@@ -65,6 +64,8 @@ AddPortEvent::pre_process()
return;
}
+ // FIXME: this is just a mess :/
+
_patch = om->object_store()->find_patch(_path.parent());
if (_patch != NULL) {
@@ -74,15 +75,24 @@ AddPortEvent::pre_process()
if (_type == "AUDIO" || _type == "MIDI")
buffer_size = om->audio_driver()->buffer_size();
- _port = _patch->create_port(_path.name(), _data_type, buffer_size, _is_output);
- if (_port) {
+ _patch_port = _patch->create_port(_path.name(), _data_type, buffer_size, _is_output);
+ if (_patch_port) {
if (_is_output)
- _patch->add_output(new ListNode<Port*>(_port));
+ _patch->add_output(new ListNode<Port*>(_patch_port));
else
- _patch->add_input(new ListNode<Port*>(_port));
+ _patch->add_input(new ListNode<Port*>(_patch_port));
_ports_array = new Array<Port*>(_patch->num_ports() + 1, _patch->external_ports());
- _ports_array->at(_patch->num_ports()) = _port;
- om->object_store()->add(_port);
+ _ports_array->at(_patch->num_ports()) = _patch_port;
+ om->object_store()->add(_patch_port);
+
+ if (!_patch->parent()) {
+ if (_type == "AUDIO")
+ _driver_port = om->audio_driver()->create_port(
+ dynamic_cast<DuplexPort<sample>*>(_patch_port));
+ else if (_type == "MIDI")
+ _driver_port = om->midi_driver()->create_port(
+ dynamic_cast<DuplexPort<MidiMessage>*>(_patch_port));
+ }
}
}
QueuedEvent::pre_process();
@@ -94,11 +104,14 @@ AddPortEvent::execute(samplecount offset)
{
QueuedEvent::execute(offset);
- if (_port) {
+ if (_patch_port) {
om->maid()->push(_patch->external_ports());
//_patch->add_port(_port);
_patch->external_ports(_ports_array);
}
+
+ if (_driver_port)
+ _driver_port->add_to_driver();
}
@@ -110,7 +123,7 @@ AddPortEvent::post_process()
m_responder->respond_error(msg);
} else {
m_responder->respond_ok();
- om->client_broadcaster()->send_port(_port);
+ om->client_broadcaster()->send_port(_patch_port);
}
}
diff --git a/src/libs/engine/events/AddPortEvent.h b/src/libs/engine/events/AddPortEvent.h
index 6ebe262c..b0913719 100644
--- a/src/libs/engine/events/AddPortEvent.h
+++ b/src/libs/engine/events/AddPortEvent.h
@@ -31,6 +31,7 @@ namespace Om {
class Patch;
class Port;
class Plugin;
+class DriverPort;
/** An event to add a Port to a Patch.
@@ -41,7 +42,6 @@ class AddPortEvent : public QueuedEvent
{
public:
AddPortEvent(CountedPtr<Responder> responder, const string& path, const string& type, bool is_output);
- ~AddPortEvent();
void pre_process();
void execute(samplecount offset);
@@ -53,18 +53,10 @@ private:
bool _is_output;
DataType _data_type;
Patch* _patch;
- Port* _port;
- Array<Port*>* _ports_array; // New (external) ports array for Patch
+ Port* _patch_port;
+ Array<Port*>* _ports_array; ///< New (external) ports array for Patch
+ DriverPort* _driver_port; ///< Driver (eg Jack) port if this is a toplevel port
bool _succeeded;
- /*
- string m_patch_name;
- Path m_path;
- Plugin* m_plugin;
- bool m_poly;
- Patch* m_patch;
- Node* m_node;
- Array<Node*>* m_process_order; // Patch's new process order
- bool m_node_already_exists;*/
};
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp
index 1d5b3ba1..74fa4e97 100644
--- a/src/libs/engine/events/ConnectionEvent.cpp
+++ b/src/libs/engine/events/ConnectionEvent.cpp
@@ -212,8 +212,12 @@ TypedConnectionEvent<T>::pre_process()
m_port_listnode = new ListNode<TypedConnection<T>*>(m_connection);
m_patch_listnode = new ListNode<Connection*>(m_connection);
- dst_node->providers()->push_back(new ListNode<Node*>(src_node));
- src_node->dependants()->push_back(new ListNode<Node*>(dst_node));
+ // Need to be careful about patch port connections here and adding a node's
+ // parent as a dependant/provider...
+ if (src_node->parent() == dst_node->parent()) {
+ dst_node->providers()->push_back(new ListNode<Node*>(src_node));
+ src_node->dependants()->push_back(new ListNode<Node*>(dst_node));
+ }
if (m_patch->process())
m_process_order = m_patch->build_process_order();