summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-16 02:49:22 +0000
committerDavid Robillard <d@drobilla.net>2008-11-16 02:49:22 +0000
commit24d998447070dbfef3eaf7762dce7e97c3903801 (patch)
tree0feffd6ca3c4459e0a7ff6fad9cf48b7816f2cd7 /src/engine
parentfb6471ac9d5daefd3655bc19532a6028b5f0ead4 (diff)
downloadingen-24d998447070dbfef3eaf7762dce7e97c3903801.tar.gz
ingen-24d998447070dbfef3eaf7762dce7e97c3903801.tar.bz2
ingen-24d998447070dbfef3eaf7762dce7e97c3903801.zip
TCP notification stream support (not fully implemented yet, but transport stuff is working).
Support multiple event sources in the engine. Clean up HTTP/TCP stuff. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1721 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/ClientBroadcaster.cpp4
-rw-r--r--src/engine/ClientBroadcaster.hpp2
-rw-r--r--src/engine/Engine.cpp21
-rw-r--r--src/engine/Engine.hpp10
-rw-r--r--src/engine/HTTPClientSender.cpp6
-rw-r--r--src/engine/HTTPClientSender.hpp8
-rw-r--r--src/engine/HTTPEngineReceiver.cpp14
-rw-r--r--src/engine/OSCClientSender.cpp8
-rw-r--r--src/engine/OSCClientSender.hpp2
-rw-r--r--src/engine/events/SendPortActivityEvent.cpp2
10 files changed, 38 insertions, 39 deletions
diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp
index f13743f6..19cb0cd4 100644
--- a/src/engine/ClientBroadcaster.cpp
+++ b/src/engine/ClientBroadcaster.cpp
@@ -222,10 +222,10 @@ ClientBroadcaster::send_port_value(const string& port_path, const Raul::Atom& va
void
-ClientBroadcaster::send_port_activity(const string& port_path)
+ClientBroadcaster::send_activity(const string& path)
{
for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->port_activity(port_path);
+ (*i).second->activity(path);
}
diff --git a/src/engine/ClientBroadcaster.hpp b/src/engine/ClientBroadcaster.hpp
index 8f9afca3..2de4b1b9 100644
--- a/src/engine/ClientBroadcaster.hpp
+++ b/src/engine/ClientBroadcaster.hpp
@@ -77,7 +77,7 @@ public:
void send_variable_change(const string& node_path, const string& key, const Raul::Atom& value);
void send_property_change(const string& node_path, const string& key, const Raul::Atom& value);
void send_port_value(const string& port_path, const Raul::Atom& value);
- void send_port_activity(const string& port_path);
+ void send_activity(const string& path);
void send_program_add(const string& node_path, int bank, int program, const string& name);
void send_program_remove(const string& node_path, int bank, int program);
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index d221b4f9..eb9e2aa8 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -165,12 +165,9 @@ Engine::main_iteration()
void
-Engine::set_event_source(SharedPtr<EventSource> source)
+Engine::add_event_source(SharedPtr<EventSource> source)
{
- if (_event_source)
- cerr << "Warning: Dropped event source (engine interface)" << endl;
-
- _event_source = source;
+ _event_sources.insert(source);
}
@@ -192,8 +189,8 @@ Engine::activate(size_t parallelism)
if (!_midi_driver)
_midi_driver = new DummyMidiDriver();
- if (_event_source)
- _event_source->activate();
+ for (EventSources::iterator i = _event_sources.begin(); i != _event_sources.end(); ++i)
+ (*i)->activate();
// Create root patch
@@ -229,8 +226,8 @@ Engine::deactivate()
if (!_activated)
return;
- if (_event_source)
- _event_source->deactivate();
+ for (EventSources::iterator i = _event_sources.begin(); i != _event_sources.end(); ++i)
+ (*i)->deactivate();
/*for (Tree<GraphObject*>::iterator i = _engine_store->objects().begin();
i != _engine_store->objects().end(); ++i)
@@ -257,7 +254,7 @@ Engine::deactivate()
_post_processor->process();
_audio_driver.reset();
- _event_source.reset();
+ _event_sources.clear();
_activated = false;
}
@@ -266,8 +263,8 @@ Engine::deactivate()
void
Engine::process_events(ProcessContext& context)
{
- if (_event_source)
- _event_source->process(*_post_processor, context);
+ for (EventSources::iterator i = _event_sources.begin(); i != _event_sources.end(); ++i)
+ (*i)->process(*_post_processor, context);
}
diff --git a/src/engine/Engine.hpp b/src/engine/Engine.hpp
index 8edf37c3..261f135f 100644
--- a/src/engine/Engine.hpp
+++ b/src/engine/Engine.hpp
@@ -21,6 +21,7 @@
#include "config.h"
#include <cassert>
#include <vector>
+#include <set>
#include <boost/utility.hpp>
#include "raul/SharedPtr.hpp"
#include "module/global.hpp"
@@ -81,7 +82,6 @@ public:
virtual bool activated() { return _activated; }
Raul::Maid* maid() const { return _maid; }
- EventSource* event_source() const { return _event_source.get(); }
AudioDriver* audio_driver() const { return _audio_driver.get(); }
MidiDriver* midi_driver() const { return _midi_driver; }
OSCDriver* osc_driver() const { return _osc_driver; }
@@ -97,10 +97,10 @@ public:
/** Set the driver for the given data type (replacing the old) */
virtual void set_driver(DataType type, SharedPtr<Driver> driver);
-
- virtual void set_event_source(SharedPtr<EventSource> source);
virtual void set_midi_driver(MidiDriver* driver);
+ virtual void add_event_source(SharedPtr<EventSource> source);
+
Ingen::Shared::World* world() { return _world; }
typedef std::vector<ProcessSlave*> ProcessSlaves;
@@ -108,9 +108,11 @@ public:
inline ProcessSlaves& process_slaves() { return _process_slaves; }
private:
+ typedef std::set< SharedPtr<EventSource> > EventSources;
+ EventSources _event_sources;
+
ProcessSlaves _process_slaves;
Ingen::Shared::World* _world;
- SharedPtr<EventSource> _event_source;
SharedPtr<AudioDriver> _audio_driver;
MidiDriver* _midi_driver;
OSCDriver* _osc_driver;
diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp
index ae97e1ca..ec60cb44 100644
--- a/src/engine/HTTPClientSender.cpp
+++ b/src/engine/HTTPClientSender.cpp
@@ -135,9 +135,9 @@ HTTPClientSender::set_voice_value(const std::string& port_path, uint32_t voice,
void
-HTTPClientSender::port_activity(const std::string& port_path)
+HTTPClientSender::activity(const std::string& path)
{
- //lo_send(_address, "/ingen/port_activity", "s", port_path.c_str(), LO_ARGS_END);
+ //lo_send(_address, "/ingen/activity", "s", port_path.c_str(), LO_ARGS_END);
}
@@ -159,9 +159,7 @@ HTTPClientSender::new_plugin(const std::string& uri,
void
HTTPClientSender::new_patch(const std::string& path, uint32_t poly)
{
- cout << "HTTP NEW PATCH" << endl;
send_chunk(string("<").append(path).append("> a ingen:Patch"));
- //send("/ingen/new_patch", "si", path.c_str(), poly, LO_ARGS_END);
}
diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp
index 8e4f3d33..57aaed0e 100644
--- a/src/engine/HTTPClientSender.hpp
+++ b/src/engine/HTTPClientSender.hpp
@@ -41,12 +41,10 @@ namespace Shared { class EngineInterface; }
*/
class HTTPClientSender
: public Shared::ClientInterface
- , public Raul::Thread
, public Shared::HTTPSender
{
public:
- HTTPClientSender(SoupServer* s, SoupMessage* m)
- : Shared::HTTPSender(s, m)
+ HTTPClientSender()
{}
bool enabled() const { return _enabled; }
@@ -58,7 +56,7 @@ public:
void bundle_end() { HTTPSender::bundle_end(); }
void transfer_begin() { HTTPSender::transfer_begin(); }
void transfer_end() { HTTPSender::transfer_end(); }
-
+
std::string uri() const { return "http://example.org/"; }
void subscribe(Shared::EngineInterface* engine) { }
@@ -115,7 +113,7 @@ public:
uint32_t voice,
const Raul::Atom& value);
- virtual void port_activity(const std::string& port_path);
+ virtual void activity(const std::string& path);
virtual void program_add(const std::string& node_path,
uint32_t bank,
diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp
index 9b6b6fb9..82bebc0c 100644
--- a/src/engine/HTTPEngineReceiver.cpp
+++ b/src/engine/HTTPEngineReceiver.cpp
@@ -148,16 +148,20 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
return;
} else if (path.substr(0, 6) == "/patch") {
path = '/' + path.substr(6);
+
} else if (path.substr(0, 7) == "/stream") {
- cout << "REGISTERING CLIENT" << endl;
- // FIXME: memory leak
- ClientInterface* client = new HTTPClientSender(me->_server, msg);
- soup_message_headers_set_encoding(msg->response_headers, SOUP_ENCODING_CHUNKED);
+ HTTPClientSender* client = new HTTPClientSender();
me->register_client(client);
+
+ // Respond with port number of stream for client
+ const int port = client->listen_port();
+ char buf[32];
+ snprintf(buf, 32, "%d", port);
+ soup_message_set_status(msg, SOUP_STATUS_OK);
+ soup_message_set_response(msg, mime_type, SOUP_MEMORY_COPY, buf, strlen(buf));
return;
} else {
- cout << "UNKNOWN PATH: " << path << endl;
soup_message_set_status(msg, SOUP_STATUS_NOT_FOUND);
soup_message_set_response(msg, "text/plain", SOUP_MEMORY_STATIC,
"Unknown path\n\n", 14);
diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp
index d9893241..aa99c1d8 100644
--- a/src/engine/OSCClientSender.cpp
+++ b/src/engine/OSCClientSender.cpp
@@ -278,16 +278,16 @@ OSCClientSender::set_voice_value(const std::string& port_path, uint32_t voice, c
/** \page client_osc_namespace
- * <p> \b /ingen/port_activity - Notification of activity for a port (e.g. MIDI messages)
- * \arg \b path (string) - Path of port </p> \n \n
+ * <p> \b /ingen/activity - Notification of "activity" (e.g. port message blinkenlights)
+ * \arg \b path (string) - Path of object </p> \n \n
*/
void
-OSCClientSender::port_activity(const std::string& port_path)
+OSCClientSender::activity(const std::string& path)
{
if (!_enabled)
return;
- lo_send(_address, "/ingen/port_activity", "s", port_path.c_str(), LO_ARGS_END);
+ lo_send(_address, "/ingen/activity", "s", path.c_str(), LO_ARGS_END);
}
diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp
index 3de967ab..879484c8 100644
--- a/src/engine/OSCClientSender.hpp
+++ b/src/engine/OSCClientSender.hpp
@@ -114,7 +114,7 @@ public:
uint32_t voice,
const Raul::Atom& value);
- virtual void port_activity(const std::string& port_path);
+ virtual void activity(const std::string& path);
virtual void program_add(const std::string& node_path,
uint32_t bank,
diff --git a/src/engine/events/SendPortActivityEvent.cpp b/src/engine/events/SendPortActivityEvent.cpp
index 0ab3abdd..3a408d8d 100644
--- a/src/engine/events/SendPortActivityEvent.cpp
+++ b/src/engine/events/SendPortActivityEvent.cpp
@@ -26,7 +26,7 @@ namespace Ingen {
void
SendPortActivityEvent::post_process()
{
- _engine.broadcaster()->send_port_activity(_port->path());
+ _engine.broadcaster()->send_activity(_port->path());
}