summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp12
-rw-r--r--src/libs/engine/Engine.cpp10
-rw-r--r--src/libs/engine/Engine.h9
-rw-r--r--src/libs/engine/EventSource.h7
-rw-r--r--src/libs/engine/JackAudioDriver.cpp50
-rw-r--r--src/libs/engine/JackAudioDriver.h2
-rw-r--r--src/libs/engine/Makefile.am8
-rw-r--r--src/libs/engine/OSCClientSender.cpp (renamed from src/libs/engine/OSCClient.cpp)51
-rw-r--r--src/libs/engine/OSCClientSender.h (renamed from src/libs/engine/OSCClient.h)16
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp (renamed from src/libs/engine/OSCReceiver.cpp)100
-rw-r--r--src/libs/engine/OSCEngineReceiver.h (renamed from src/libs/engine/OSCReceiver.h)26
-rw-r--r--src/libs/engine/QueuedEventSource.cpp36
-rw-r--r--src/libs/engine/QueuedEventSource.h9
13 files changed, 157 insertions, 179 deletions
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index 1fa64d9a..355d4232 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -30,7 +30,7 @@
#include "ObjectSender.h"
#include "interface/ClientKey.h"
#include "interface/ClientInterface.h"
-#include "OSCClient.h"
+#include "OSCClientSender.h"
using std::cout; using std::cerr; using std::endl;
using Ingen::Shared::ClientInterface;
@@ -137,6 +137,10 @@ ClientBroadcaster::send_plugins_to(ClientInterface* client, const list<Plugin*>&
const Plugin* plugin;
+ // FIXME FIXME FIXME
+ OSCClientSender* osc_client = dynamic_cast<OSCClientSender*>(client);
+ assert(osc_client);
+
lo_timetag tt;
lo_timetag_now(&tt);
lo_bundle b = lo_bundle_new(tt);
@@ -157,16 +161,14 @@ ClientBroadcaster::send_plugins_to(ClientInterface* client, const list<Plugin*>&
lo_bundle_add_message(b, "/om/plugin", m);
msgs.push_back(m);
if (lo_bundle_length(b) > 1024) {
- // FIXME FIXME FIXME dirty, dirty cast
- lo_send_bundle(((OSCClient*)client)->address(), b);
+ lo_send_bundle(osc_client->address(), b);
lo_bundle_free(b);
b = lo_bundle_new(tt);
}
}
if (lo_bundle_length(b) > 0) {
- // FIXME FIXME FIXME dirty, dirty cast
- lo_send_bundle(((OSCClient*)client)->address(), b);
+ lo_send_bundle(osc_client->address(), b);
lo_bundle_free(b);
} else {
lo_bundle_free(b);
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
index a98f4fbf..ebe8e4f7 100644
--- a/src/libs/engine/Engine.cpp
+++ b/src/libs/engine/Engine.cpp
@@ -24,7 +24,6 @@
#include "util/Queue.h"
#include "JackAudioDriver.h"
#include "NodeFactory.h"
-#include "OSCReceiver.h"
#include "ClientBroadcaster.h"
#include "Patch.h"
#include "ObjectStore.h"
@@ -49,9 +48,9 @@ using std::cout; using std::cerr; using std::endl;
namespace Ingen {
-Engine::Engine(const char* listen_port, AudioDriver* audio_driver)
-: m_audio_driver( (audio_driver) ? audio_driver : new JackAudioDriver(*this) ),
- m_osc_receiver(new OSCReceiver(*this, pre_processor_queue_size, listen_port)),
+Engine::Engine(AudioDriver* audio_driver)
+: m_event_source(NULL),
+ m_audio_driver( (audio_driver) ? audio_driver : new JackAudioDriver(*this) ),
#ifdef HAVE_JACK_MIDI
m_midi_driver(new JackMidiDriver(((JackAudioDriver*)m_audio_driver)->jack_client())),
#elif HAVE_ALSA_MIDI
@@ -72,7 +71,6 @@ Engine::Engine(const char* listen_port, AudioDriver* audio_driver)
m_quit_flag(false),
m_activated(false)
{
- m_osc_receiver->activate();
}
@@ -88,7 +86,6 @@ Engine::~Engine()
delete m_object_store;
delete m_client_broadcaster;
- delete m_osc_receiver;
delete m_node_factory;
delete m_midi_driver;
delete m_audio_driver;
@@ -183,7 +180,6 @@ Engine::deactivate()
if (m_midi_driver != NULL)
m_midi_driver->deactivate();
- m_osc_receiver->deactivate();
m_audio_driver->deactivate();
// Finalize any lingering events (unlikely)
diff --git a/src/libs/engine/Engine.h b/src/libs/engine/Engine.h
index fbad649f..35192bb5 100644
--- a/src/libs/engine/Engine.h
+++ b/src/libs/engine/Engine.h
@@ -27,7 +27,6 @@ namespace Ingen {
class AudioDriver;
class MidiDriver;
class NodeFactory;
-class OSCReceiver;
class ClientBroadcaster;
class Patch;
class ObjectStore;
@@ -51,7 +50,7 @@ template <typename T> class Driver;
class Engine
{
public:
- Engine(const char* listen_port, AudioDriver* audio_driver = 0);
+ Engine(AudioDriver* audio_driver = 0);
~Engine();
int main();
@@ -63,8 +62,10 @@ public:
void activate();
void deactivate();
+ void set_event_source(EventSource* es) { m_event_source = es; }
+
+ EventSource* event_source() const { return m_event_source; }
AudioDriver* audio_driver() const { return m_audio_driver; }
- OSCReceiver* osc_receiver() const { return m_osc_receiver; }
MidiDriver* midi_driver() const { return m_midi_driver; }
Maid* maid() const { return m_maid; }
PostProcessor* post_processor() const { return m_post_processor; }
@@ -81,8 +82,8 @@ private:
Engine(const Engine&);
Engine& operator=(const Engine&);
+ EventSource* m_event_source;
AudioDriver* m_audio_driver;
- OSCReceiver* m_osc_receiver;
MidiDriver* m_midi_driver;
Maid* m_maid;
PostProcessor* m_post_processor;
diff --git a/src/libs/engine/EventSource.h b/src/libs/engine/EventSource.h
index 212249c6..d251cac5 100644
--- a/src/libs/engine/EventSource.h
+++ b/src/libs/engine/EventSource.h
@@ -17,10 +17,13 @@
#ifndef EVENTSOURCE_H
#define EVENTSOURCE_H
+#include "types.h"
+
namespace Ingen {
class Event;
class QueuedEvent;
+class PostProcessor;
/** Source for events to run in the audio thread.
@@ -41,9 +44,7 @@ public:
virtual ~EventSource() {}
- virtual Event* pop_earliest_queued_before(const SampleCount time) = 0;
-
- virtual Event* pop_earliest_stamped_before(const SampleCount time) = 0;
+ virtual void process(PostProcessor& dest, SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end) = 0;
protected:
EventSource() {}
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
index 2c0d4a70..66a16d51 100644
--- a/src/libs/engine/JackAudioDriver.cpp
+++ b/src/libs/engine/JackAudioDriver.cpp
@@ -24,7 +24,6 @@
#include "Event.h"
#include "QueuedEvent.h"
#include "EventSource.h"
-#include "OSCReceiver.h"
#include "PostProcessor.h"
#include "util/Queue.h"
#include "Node.h"
@@ -33,6 +32,7 @@
#include "MidiDriver.h"
#include "List.h"
#include "DuplexPort.h"
+#include "EventSource.h"
#ifdef HAVE_LASH
#include "LashDriver.h"
#endif
@@ -181,8 +181,6 @@ void
JackAudioDriver::deactivate()
{
if (_is_activated) {
- _engine.osc_receiver()->deactivate();
-
jack_deactivate(_client);
_is_activated = false;
@@ -242,48 +240,6 @@ JackAudioDriver::create_port(DuplexPort<Sample>* patch_port)
}
-/** Process all the pending events for this cycle.
- *
- * Called from the realtime thread once every process cycle.
- */
-void
-JackAudioDriver::process_events(SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end)
-{
- Event* ev = NULL;
-
- /* Limit the maximum number of queued events to process per cycle. This
- * makes the process callback (more) realtime-safe by preventing being
- * choked by events coming in faster than they can be processed.
- * FIXME: run the math on this and figure out a good value */
- const unsigned int MAX_QUEUED_EVENTS = _buffer_size / 100;
-
- unsigned int num_events_processed = 0;
-
- // Process the "slow" events first, because it's possible some of the
- // RT events depend on them
-
- /* FIXME: Merge these next two loops into one */
-
- // FIXME
- while ((ev = _engine.osc_receiver()->pop_earliest_queued_before(cycle_end))) {
- ev->execute(nframes, cycle_start, cycle_end);
- _engine.post_processor()->push(ev);
- if (++num_events_processed > MAX_QUEUED_EVENTS)
- break;
- }
-
- while ((ev = _engine.osc_receiver()->pop_earliest_stamped_before(cycle_end))) {
- ev->execute(nframes, cycle_start, cycle_end);
- _engine.post_processor()->push(ev);
- ++num_events_processed;
- }
-
- if (num_events_processed > 0)
- _engine.post_processor()->whip();
-}
-
-
-
/**** Jack Callbacks ****/
@@ -313,7 +269,9 @@ JackAudioDriver::_process_cb(jack_nframes_t nframes)
_transport_state = jack_transport_query(_client, &_position);
- process_events(nframes, start_of_last_cycle, start_of_current_cycle);
+ if (_engine.event_source())
+ _engine.event_source()->process(*_engine.post_processor(), nframes, start_of_last_cycle, start_of_current_cycle);
+
_engine.midi_driver()->prepare_block(start_of_last_cycle, start_of_current_cycle);
// Set buffers of patch ports to Jack port buffers (zero-copy processing)
diff --git a/src/libs/engine/JackAudioDriver.h b/src/libs/engine/JackAudioDriver.h
index aa0cebbc..072434b9 100644
--- a/src/libs/engine/JackAudioDriver.h
+++ b/src/libs/engine/JackAudioDriver.h
@@ -84,8 +84,6 @@ public:
void enable();
void disable();
- void process_events(SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end);
-
DriverPort* create_port(DuplexPort<Sample>* patch_port);
Patch* root_patch() { return _root_patch; }
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am
index bc2560eb..1f3b4d45 100644
--- a/src/libs/engine/Makefile.am
+++ b/src/libs/engine/Makefile.am
@@ -23,8 +23,8 @@ libingen_la_SOURCES = \
Engine.cpp \
JackAudioDriver.h \
JackAudioDriver.cpp \
- OSCReceiver.h \
- OSCReceiver.cpp \
+ OSCEngineReceiver.h \
+ OSCEngineReceiver.cpp \
Responder.h \
OSCResponder.h \
OSCResponder.cpp \
@@ -33,8 +33,8 @@ libingen_la_SOURCES = \
ClientBroadcaster.cpp \
ObjectSender.h \
ObjectSender.cpp \
- OSCClient.h \
- OSCClient.cpp \
+ OSCClientSender.h \
+ OSCClientSender.cpp \
Buffer.h \
Buffer.cpp \
Port.h \
diff --git a/src/libs/engine/OSCClient.cpp b/src/libs/engine/OSCClientSender.cpp
index acc56cdf..d6f56e74 100644
--- a/src/libs/engine/OSCClient.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -14,7 +14,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "OSCClient.h"
+#include "OSCClientSender.h"
#include <cassert>
#include <iostream>
#include <unistd.h>
@@ -92,7 +92,7 @@ namespace Ingen {
* user command, ie "unexpected" errors.</p> \n \n
*/
void
-OSCClient::error(const string& msg)
+OSCClientSender::error(const string& msg)
{
lo_send(_address, "/om/error", "s", msg.c_str());
}
@@ -113,7 +113,7 @@ OSCClient::error(const string& msg)
* of how many plugins (/om/plugin messages) to expect.</p> \n \n
*/
void
-OSCClient::num_plugins(uint32_t num)
+OSCClientSender::num_plugins(uint32_t num)
{
lo_message m = lo_message_new();
lo_message_add_int32(m, num);
@@ -132,7 +132,7 @@ OSCClient::num_plugins(uint32_t num)
*/
/*
void
-OSCClient::plugins()
+OSCClientSender::plugins()
{
Engine::instance().node_factory()->lock_plugin_list();
@@ -189,7 +189,7 @@ OSCClient::plugins()
* this one (/om/new_node), followed by a series of /om/new_port commands,
* followed by /om/new_node_end. </p> \n \n
*/
-void OSCClient::new_node(const string& plugin_type,
+void OSCClientSender::new_node(const string& plugin_type,
const string& plugin_uri,
const string& node_path,
bool is_polyphonic,
@@ -301,7 +301,7 @@ void OSCClient::new_node(const string& plugin_type,
* as metadata.</p> \n \n
*/
void
-OSCClient::new_port(const string& path,
+OSCClientSender::new_port(const string& path,
const string& data_type,
bool is_output)
{
@@ -321,7 +321,7 @@ OSCClient::new_port(const string& path,
* \arg \b path (string) - Path of object (which no longer exists) </p> \n \n
*/
void
-OSCClient::object_destroyed(const string& path)
+OSCClientSender::object_destroyed(const string& path)
{
assert(path != "/");
@@ -334,7 +334,7 @@ OSCClient::object_destroyed(const string& path)
* \arg \b path (string) - Path of patch (which is now empty)</p> \n \n
*/
void
-OSCClient::patch_cleared(const string& patch_path)
+OSCClientSender::patch_cleared(const string& patch_path)
{
lo_send(_address, "/om/patch_cleared", "s", patch_path.c_str());
}
@@ -345,7 +345,7 @@ OSCClient::patch_cleared(const string& patch_path)
* \arg \b path (string) - Path of enabled patch</p> \n \n
*/
void
-OSCClient::patch_enabled(const string& patch_path)
+OSCClientSender::patch_enabled(const string& patch_path)
{
lo_send(_address, "/om/patch_enabled", "s", patch_path.c_str());
}
@@ -356,7 +356,7 @@ OSCClient::patch_enabled(const string& patch_path)
* \arg \b path (string) - Path of disabled patch</p> \n \n
*/
void
-OSCClient::patch_disabled(const string& patch_path)
+OSCClientSender::patch_disabled(const string& patch_path)
{
lo_send(_address, "/om/patch_disabled", "s", patch_path.c_str());
}
@@ -368,7 +368,7 @@ OSCClient::patch_disabled(const string& patch_path)
* \arg \b dst-path (string) - Path of the destination port</p> \n \n
*/
void
-OSCClient::connection(const string& src_port_path, const string& dst_port_path)
+OSCClientSender::connection(const string& src_port_path, const string& dst_port_path)
{
lo_send(_address, "/om/new_connection", "ss", src_port_path.c_str(), dst_port_path.c_str());
}
@@ -380,7 +380,7 @@ OSCClient::connection(const string& src_port_path, const string& dst_port_path)
* \arg \b dst-path (string) - Path of the destination port</p> \n \n
*/
void
-OSCClient::disconnection(const string& src_port_path, const string& dst_port_path)
+OSCClientSender::disconnection(const string& src_port_path, const string& dst_port_path)
{
lo_send(_address, "/om/disconnection", "ss", src_port_path.c_str(), dst_port_path.c_str());
}
@@ -393,7 +393,7 @@ OSCClient::disconnection(const string& src_port_path, const string& dst_port_pat
* \arg \b value (string)</p> \n \n
*/
void
-OSCClient::metadata_update(const string& path, const string& key, const string& value)
+OSCClientSender::metadata_update(const string& path, const string& key, const string& value)
{
lo_send(_address, "/om/metadata/update", "sss", path.c_str(), key.c_str(), value.c_str());
}
@@ -408,7 +408,7 @@ OSCClient::metadata_update(const string& path, const string& key, const string&
* changing because of connections to other ports!</p> \n \n
*/
void
-OSCClient::control_change(const string& port_path, float value)
+OSCClientSender::control_change(const string& port_path, float value)
{
lo_send(_address, "/om/control_change", "sf", port_path.c_str(), value);
}
@@ -421,7 +421,7 @@ OSCClient::control_change(const string& port_path, float value)
* \arg \b name (string) - Descriptive human-readable name of plugin (ie "ADSR Envelope")
*/
void
-OSCClient::new_plugin(const string& type, const string& uri, const string& name)
+OSCClientSender::new_plugin(const string& type, const string& uri, const string& name)
{
lo_message m = lo_message_new();
lo_message_add_string(m, type.c_str());
@@ -437,7 +437,7 @@ OSCClient::new_plugin(const string& type, const string& uri, const string& name)
* \arg \b poly (int) - Polyphony of new patch (\em not a boolean like new_node) </p> \n \n
*/
void
-OSCClient::new_patch(const string& path, uint32_t poly)
+OSCClientSender::new_patch(const string& path, uint32_t poly)
{
lo_send(_address, "/om/new_patch", "si", path.c_str(), poly);
@@ -460,29 +460,16 @@ OSCClient::new_patch(const string& path, uint32_t poly)
* \arg \b new-path (string) - New path of object </p> \n \n
*/
void
-OSCClient::object_renamed(const string& old_path, const string& new_path)
+OSCClientSender::object_renamed(const string& old_path, const string& new_path)
{
lo_send(_address, "/om/object_renamed", "ss", old_path.c_str(), new_path.c_str());
}
-/** Sends all GraphObjects known to the engine.
- */
-/*
-void
-OSCClient::all_objects()
-{
- for (Tree<GraphObject*>::iterator i = Engine::instance().object_store()->objects().begin();
- i != Engine::instance().object_store()->objects().end(); ++i)
- if ((*i)->as_node() != NULL && (*i)->parent() == NULL)
- (*i)->as_node()->send_creation_messages(this);
-}
-*/
-
/** Sends information about a program associated with a DSSI plugin node.
*/
void
-OSCClient::program_add(const string& node_path, uint32_t bank, uint32_t program, const string& name)
+OSCClientSender::program_add(const string& node_path, uint32_t bank, uint32_t program, const string& name)
{
lo_send(_address, "/om/program_add", "siis",
node_path.c_str(), bank, program, name.c_str());
@@ -490,7 +477,7 @@ OSCClient::program_add(const string& node_path, uint32_t bank, uint32_t program,
void
-OSCClient::program_remove(const string& node_path, uint32_t bank, uint32_t program)
+OSCClientSender::program_remove(const string& node_path, uint32_t bank, uint32_t program)
{
lo_send(_address, "/om/program_remove", "sii",
node_path.c_str(), bank, program);
diff --git a/src/libs/engine/OSCClient.h b/src/libs/engine/OSCClientSender.h
index 423bb32f..1826a36d 100644
--- a/src/libs/engine/OSCClient.h
+++ b/src/libs/engine/OSCClientSender.h
@@ -14,8 +14,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef OSCCLIENT_H
-#define OSCCLIENT_H
+#ifndef OSCCLIENTSENDER_H
+#define OSCCLIENTSENDER_H
#include <string>
#include <iostream>
@@ -35,15 +35,15 @@ namespace Ingen {
*
* \ingroup engine
*/
-class OSCClient : public Shared::ClientInterface
+class OSCClientSender : public Shared::ClientInterface
{
public:
- OSCClient(const string& url)
+ OSCClientSender(const string& url)
: _url(url),
_address(lo_address_new_from_url(url.c_str()))
{}
- virtual ~OSCClient()
+ virtual ~OSCClientSender()
{ lo_address_free(_address); }
const string& url() const { return _url; }
@@ -117,8 +117,8 @@ public:
private:
// Prevent copies (undefined)
- OSCClient(const OSCClient&);
- OSCClient& operator=(const OSCClient&);
+ OSCClientSender(const OSCClientSender&);
+ OSCClientSender& operator=(const OSCClientSender&);
string _url;
lo_address _address;
@@ -127,5 +127,5 @@ private:
} // namespace Ingen
-#endif // OSCCLIENT_H
+#endif // OSCCLIENTSENDER_H
diff --git a/src/libs/engine/OSCReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 5c08c17a..4b1ae496 100644
--- a/src/libs/engine/OSCReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -14,7 +14,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "OSCReceiver.h"
+#include "OSCEngineReceiver.h"
#include <iostream>
#include <cstdlib>
#include <string>
@@ -25,7 +25,7 @@
#include "QueuedEventSource.h"
#include "interface/ClientKey.h"
#include "interface/ClientInterface.h"
-#include "OSCClient.h"
+#include "OSCClientSender.h"
#include "OSCResponder.h"
#include "ClientBroadcaster.h"
@@ -47,7 +47,7 @@ using Shared::ClientKey;
*/
-OSCReceiver::OSCReceiver(Engine& engine, size_t queue_size, const char* const port)
+OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, const char* const port)
: QueuedEngineInterface(engine, queue_size, queue_size), // FIXME
_port(port),
_server(NULL),
@@ -122,7 +122,7 @@ OSCReceiver::OSCReceiver(Engine& engine, size_t queue_size, const char* const po
}
-OSCReceiver::~OSCReceiver()
+OSCEngineReceiver::~OSCEngineReceiver()
{
deactivate();
@@ -134,18 +134,18 @@ OSCReceiver::~OSCReceiver()
void
-OSCReceiver::activate()
+OSCEngineReceiver::activate()
{
- set_name("OSCReceiver");
+ set_name("OSCEngineReceiver");
QueuedEventSource::activate();
set_scheduling(SCHED_FIFO, 10);
}
void
-OSCReceiver::deactivate()
+OSCEngineReceiver::deactivate()
{
- cout << "[OSCReceiver] Stopped OSC listening thread" << endl;
+ cout << "[OSCEngineReceiver] Stopped OSC listening thread" << endl;
QueuedEventSource::deactivate();
}
@@ -154,7 +154,7 @@ OSCReceiver::deactivate()
* to wait on OSC messages and prepare them right away in the same thread.
*/
void
-OSCReceiver::_run()
+OSCEngineReceiver::_run()
{
/* get a timestamp here and stamp all the events with the same time so
* they all get executed in the same cycle */
@@ -194,9 +194,9 @@ OSCReceiver::_run()
* working around the fact that liblo addresses really suck. Oh well.
*/
int
-OSCReceiver::set_response_address_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
+OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
{
- OSCReceiver* const me = reinterpret_cast<OSCReceiver*>(user_data);
+ OSCEngineReceiver* const me = reinterpret_cast<OSCEngineReceiver*>(user_data);
//cerr << "SET RESPONSE\n";
@@ -249,7 +249,7 @@ OSCReceiver::set_response_address_cb(const char* path, const char* types, lo_arg
void
-OSCReceiver::error_cb(int num, const char* msg, const char* path)
+OSCEngineReceiver::error_cb(int num, const char* msg, const char* path)
{
cerr << "liblo server error " << num << " in path \"" << "\" - " << msg << endl;
}
@@ -260,7 +260,7 @@ OSCReceiver::error_cb(int num, const char* msg, const char* path)
* \arg \b response-id (integer) </p> \n \n
*/
int
-OSCReceiver::m_ping_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_ping_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
_responder->respond_ok();
return 0;
@@ -277,7 +277,7 @@ OSCReceiver::m_ping_cb(const char* path, const char* types, lo_arg** argv, int a
* finished processing.</p> \n \n
*/
int
-OSCReceiver::m_ping_slow_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_ping_slow_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
ping();
return 0;
@@ -293,7 +293,7 @@ OSCReceiver::m_ping_slow_cb(const char* path, const char* types, lo_arg** argv,
* 10 messages would never get executed. </p> \n \n
*/
int
-OSCReceiver::m_quit_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_quit_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
quit();
@@ -308,12 +308,12 @@ OSCReceiver::m_quit_cb(const char* path, const char* types, lo_arg** argv, int a
* want to register a different specific address, use the URL version.
*/
int
-OSCReceiver::m_register_client_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_register_client_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
lo_address addr = lo_message_get_source(msg);
char* const url = lo_address_get_url(addr);
- CountedPtr<ClientInterface> client(new OSCClient((const char*)url));
+ CountedPtr<ClientInterface> client(new OSCClientSender((const char*)url));
register_client(ClientKey(ClientKey::OSC_URL, (const char*)url), client);
free(url);
@@ -326,7 +326,7 @@ OSCReceiver::m_register_client_cb(const char* path, const char* types, lo_arg**
* \arg \b response-id (integer) </p> \n \n
*/
int
-OSCReceiver::m_unregister_client_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_unregister_client_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
lo_address addr = lo_message_get_source(msg);
@@ -343,7 +343,7 @@ OSCReceiver::m_unregister_client_cb(const char* path, const char* types, lo_arg*
* \arg \b response-id (integer) </p> \n \n
*/
int
-OSCReceiver::m_load_plugins_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_load_plugins_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
load_plugins();
return 0;
@@ -358,7 +358,7 @@ OSCReceiver::m_load_plugins_cb(const char* path, const char* types, lo_arg** arg
* anything at all - <em>including respond to your messages!</em> \n \n
*/
int
-OSCReceiver::m_engine_activate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_engine_activate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
QueuedEngineInterface::activate();
return 0;
@@ -370,7 +370,7 @@ OSCReceiver::m_engine_activate_cb(const char* path, const char* types, lo_arg**
* \arg \b response-id (integer) </p> \n \n
*/
int
-OSCReceiver::m_engine_deactivate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_engine_deactivate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
QueuedEngineInterface::deactivate();
return 0;
@@ -384,7 +384,7 @@ OSCReceiver::m_engine_deactivate_cb(const char* path, const char* types, lo_arg*
* \arg \b poly (integer) - Patch's (internal) polyphony </p> \n \n
*/
int
-OSCReceiver::m_create_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_create_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* patch_path = &argv[1]->s;
const int poly = argv[2]->i;
@@ -401,7 +401,7 @@ OSCReceiver::m_create_patch_cb(const char* path, const char* types, lo_arg** arg
* \arg \b name - New name for object </p> \n \n
*/
int
-OSCReceiver::m_rename_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_rename_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* object_path = &argv[1]->s;
const char* name = &argv[2]->s;
@@ -417,7 +417,7 @@ OSCReceiver::m_rename_cb(const char* path, const char* types, lo_arg** argv, int
* \arg \b patch-path - Patch's path
*/
int
-OSCReceiver::m_enable_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_enable_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* patch_path = &argv[1]->s;
@@ -432,7 +432,7 @@ OSCReceiver::m_enable_patch_cb(const char* path, const char* types, lo_arg** arg
* \arg \b patch-path - Patch's path
*/
int
-OSCReceiver::m_disable_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_disable_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* patch_path = &argv[1]->s;
@@ -447,7 +447,7 @@ OSCReceiver::m_disable_patch_cb(const char* path, const char* types, lo_arg** ar
* \arg \b patch-path - Patch's path
*/
int
-OSCReceiver::m_clear_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_clear_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* patch_path = &argv[1]->s;
@@ -464,7 +464,7 @@ OSCReceiver::m_clear_patch_cb(const char* path, const char* types, lo_arg** argv
* \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1) </p> \n \n
*/
int
-OSCReceiver::m_create_port_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_create_port_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* port_path = &argv[1]->s;
const char* data_type = &argv[2]->s;
@@ -483,7 +483,7 @@ OSCReceiver::m_create_port_cb(const char* path, const char* types, lo_arg** argv
* \arg \b poly (integer-boolean) - Whether node is polyphonic (0 = false, 1 = true) </p> \n \n
*/
int
-OSCReceiver::m_create_node_by_uri_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_create_node_by_uri_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* node_path = &argv[1]->s;
const char* type = &argv[2]->s;
@@ -511,7 +511,7 @@ OSCReceiver::m_create_node_by_uri_cb(const char* path, const char* types, lo_arg
* </p> \n \n
*/
int
-OSCReceiver::m_create_node_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_create_node_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* node_path = &argv[1]->s;
const char* type = &argv[2]->s;
@@ -530,7 +530,7 @@ OSCReceiver::m_create_node_cb(const char* path, const char* types, lo_arg** argv
* \arg \b node-path (string) - Full path of the object </p> \n \n
*/
int
-OSCReceiver::m_destroy_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_destroy_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* node_path = &argv[1]->s;
@@ -546,7 +546,7 @@ OSCReceiver::m_destroy_cb(const char* path, const char* types, lo_arg** argv, in
* \arg \b dst-port-path (string) - Full path of destination port </p> \n \n
*/
int
-OSCReceiver::m_connect_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_connect_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* src_port_path = &argv[1]->s;
const char* dst_port_path = &argv[2]->s;
@@ -563,7 +563,7 @@ OSCReceiver::m_connect_cb(const char* path, const char* types, lo_arg** argv, in
* \arg \b dst-port-path (string) - Full path of destination port </p> \n \n
*/
int
-OSCReceiver::m_disconnect_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_disconnect_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* src_port_path = &argv[1]->s;
const char* dst_port_path = &argv[2]->s;
@@ -579,7 +579,7 @@ OSCReceiver::m_disconnect_cb(const char* path, const char* types, lo_arg** argv,
* \arg \b node-path (string) - Full path of node. </p> \n \n
*/
int
-OSCReceiver::m_disconnect_all_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_disconnect_all_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* node_path = &argv[1]->s;
@@ -595,7 +595,7 @@ OSCReceiver::m_disconnect_all_cb(const char* path, const char* types, lo_arg** a
* \arg \b value (float) - Value to set port to
*/
int
-OSCReceiver::m_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* port_path = &argv[1]->s;
const float value = argv[2]->f;
@@ -613,7 +613,7 @@ OSCReceiver::m_set_port_value_cb(const char* path, const char* types, lo_arg** a
* \arg \b value (float) - Value to set port to
*/
int
-OSCReceiver::m_set_port_value_voice_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_set_port_value_voice_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* port_path = &argv[1]->s;
const int voice = argv[2]->i;
@@ -635,7 +635,7 @@ OSCReceiver::m_set_port_value_voice_cb(const char* path, const char* types, lo_a
* slow event and arrive out of order). </p> \n \n
*/
int
-OSCReceiver::m_set_port_value_slow_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_set_port_value_slow_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* port_path = &argv[1]->s;
const float value = argv[2]->f;
@@ -653,7 +653,7 @@ OSCReceiver::m_set_port_value_slow_cb(const char* path, const char* types, lo_ar
* \arg \b velocity (int) - MIDI style velocity (0-127)</p> \n \n
*/
int
-OSCReceiver::m_note_on_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_note_on_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
/*
@@ -674,7 +674,7 @@ OSCReceiver::m_note_on_cb(const char* path, const char* types, lo_arg** argv, in
* \arg \b note-num (int) - MIDI style note number (0-127)</p> \n \n
*/
int
-OSCReceiver::m_note_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_note_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
/*
@@ -693,7 +693,7 @@ OSCReceiver::m_note_off_cb(const char* path, const char* types, lo_arg** argv, i
* \arg \b patch-path (string) - Patch of patch to send event to </p> \n \n
*/
int
-OSCReceiver::m_all_notes_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_all_notes_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
/*
@@ -716,7 +716,7 @@ OSCReceiver::m_all_notes_off_cb(const char* path, const char* types, lo_arg** ar
* method will go away completely. </p> \n \n
*/
int
-OSCReceiver::m_midi_learn_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_midi_learn_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* patch_path = &argv[1]->s;
@@ -732,7 +732,7 @@ OSCReceiver::m_midi_learn_cb(const char* path, const char* types, lo_arg** argv,
* \arg \b response-id (integer)
*/
int
-OSCReceiver::m_lash_restore_done_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_lash_restore_done_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
lash_restore_done();
return 0;
@@ -748,7 +748,7 @@ OSCReceiver::m_lash_restore_done_cb(const char* path, const char* types, lo_arg*
* \arg \b value (string) - Value of new piece of metadata
*/
int
-OSCReceiver::m_metadata_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_metadata_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* node_path = &argv[1]->s;
const char* key = &argv[2]->s;
@@ -769,7 +769,7 @@ OSCReceiver::m_metadata_set_cb(const char* path, const char* types, lo_arg** arg
* \li Reply will be sent to client registered with the source address of this message.</p> \n \n
*/
int
-OSCReceiver::m_metadata_get_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_metadata_get_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
/*
const char* node_path = &argv[1]->s;
@@ -794,7 +794,7 @@ OSCReceiver::m_metadata_get_cb(const char* path, const char* types, lo_arg** arg
* \li Reply will be sent to client registered with the source address of this message.</p> \n \n
*/
int
-OSCReceiver::m_request_plugins_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_request_plugins_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
request_plugins();
return 0;
@@ -808,7 +808,7 @@ OSCReceiver::m_request_plugins_cb(const char* path, const char* types, lo_arg**
* \li Reply will be sent to client registered with the source address of this message.</p> \n \n
*/
int
-OSCReceiver::m_request_all_objects_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_request_all_objects_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
request_all_objects();
return 0;
@@ -823,7 +823,7 @@ OSCReceiver::m_request_all_objects_cb(const char* path, const char* types, lo_ar
* \li Reply will be sent to client registered with the source address of this message.</p> \n \n
*/
int
-OSCReceiver::m_request_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_request_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* port_path = &argv[1]->s;
@@ -834,7 +834,7 @@ OSCReceiver::m_request_port_value_cb(const char* path, const char* types, lo_arg
#ifdef HAVE_DSSI
int
-OSCReceiver::m_dssi_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::m_dssi_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
#if 0
string node_path(path);
@@ -862,7 +862,7 @@ OSCReceiver::m_dssi_cb(const char* path, const char* types, lo_arg** argv, int a
if (ev != NULL)
push(ev);
else
- cerr << "[OSCReceiver] Unknown DSSI command received: " << path << endl;
+ cerr << "[OSCEngineReceiver] Unknown DSSI command received: " << path << endl;
#endif
return 0;
}
@@ -874,7 +874,7 @@ OSCReceiver::m_dssi_cb(const char* path, const char* types, lo_arg** argv, int a
// Display incoming OSC messages (for debugging purposes)
int
-OSCReceiver::generic_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
+OSCEngineReceiver::generic_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
{
printf("[OSCMsg] %s\n", path);
@@ -890,7 +890,7 @@ OSCReceiver::generic_cb(const char* path, const char* types, lo_arg** argv, int
int
-OSCReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
+OSCEngineReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
{
const lo_address addr = lo_message_get_source(msg);
char* const url = lo_address_get_url(addr);
diff --git a/src/libs/engine/OSCReceiver.h b/src/libs/engine/OSCEngineReceiver.h
index 671944fd..cc2d7350 100644
--- a/src/libs/engine/OSCReceiver.h
+++ b/src/libs/engine/OSCEngineReceiver.h
@@ -14,8 +14,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef OSCRECEIVER_H
-#define OSCRECEIVER_H
+#ifndef OSCENGINERECEIVER_H
+#define OSCENGINERECEIVER_H
#include "config.h"
#include <string>
@@ -39,8 +39,8 @@ class Patch;
* lot of ugly boiler plate go away */
#define LO_HANDLER(name) \
int m_##name##_cb (LO_HANDLER_ARGS);\
-inline static int name##_cb(LO_HANDLER_ARGS, void* osc_receiver)\
-{ return ((OSCReceiver*)osc_receiver)->m_##name##_cb(path, types, argv, argc, msg); }
+inline static int name##_cb(LO_HANDLER_ARGS, void* myself)\
+{ return ((OSCEngineReceiver*)myself)->m_##name##_cb(path, types, argv, argc, msg); }
/* FIXME: Make this receive and preprocess in the same thread? */
@@ -56,26 +56,26 @@ inline static int name##_cb(LO_HANDLER_ARGS, void* osc_receiver)\
*
* \ingroup engine
*/
-class OSCReceiver : public QueuedEngineInterface
+class OSCEngineReceiver : public QueuedEngineInterface
{
public:
- OSCReceiver(Engine& engine, size_t queue_size, const char* const port);
- ~OSCReceiver();
+ OSCEngineReceiver(Engine& engine, size_t queue_size, const char* const port);
+ ~OSCEngineReceiver();
void activate();
void deactivate();
private:
// Prevent copies (undefined)
- OSCReceiver(const OSCReceiver&);
- OSCReceiver& operator=(const OSCReceiver&);
+ OSCEngineReceiver(const OSCEngineReceiver&);
+ OSCEngineReceiver& operator=(const OSCEngineReceiver&);
virtual void _run();
static void error_cb(int num, const char* msg, const char* path);
- static int set_response_address_cb(LO_HANDLER_ARGS, void* osc_receiver);
- static int generic_cb(LO_HANDLER_ARGS, void* osc_receiver);
- static int unknown_cb(LO_HANDLER_ARGS, void* osc_receiver);
+ static int set_response_address_cb(LO_HANDLER_ARGS, void* myself);
+ static int generic_cb(LO_HANDLER_ARGS, void* myself);
+ static int unknown_cb(LO_HANDLER_ARGS, void* myself);
LO_HANDLER(quit);
LO_HANDLER(ping);
@@ -126,4 +126,4 @@ private:
} // namespace Ingen
-#endif // OSCRECEIVER_H
+#endif // OSCENGINERECEIVER_H
diff --git a/src/libs/engine/QueuedEventSource.cpp b/src/libs/engine/QueuedEventSource.cpp
index 0ef11ac1..915b7811 100644
--- a/src/libs/engine/QueuedEventSource.cpp
+++ b/src/libs/engine/QueuedEventSource.cpp
@@ -16,6 +16,7 @@
#include "QueuedEventSource.h"
#include "QueuedEvent.h"
+#include "PostProcessor.h"
#include <sys/mman.h>
#include <iostream>
using std::cout; using std::cerr; using std::endl;
@@ -64,12 +65,43 @@ QueuedEventSource::push_queued(QueuedEvent* const ev)
}
+/** Process all events for a cycle.
+ *
+ * Executed events will be pushed to @a dest.
+ */
void
-QueuedEventSource::push_stamped(Event* const ev)
+QueuedEventSource::process(PostProcessor& dest, SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end)
{
- _stamped_queue.push(ev);
+ Event* ev = NULL;
+
+ /* Limit the maximum number of queued events to process per cycle. This
+ * makes the process callback (more) realtime-safe by preventing being
+ * choked by events coming in faster than they can be processed.
+ * FIXME: test this and figure out a good value */
+ const unsigned int MAX_QUEUED_EVENTS = nframes / 100;
+
+ unsigned int num_events_processed = 0;
+
+ /* FIXME: Merge these next two loops into one */
+
+ while ((ev = pop_earliest_queued_before(cycle_end))) {
+ ev->execute(nframes, cycle_start, cycle_end);
+ dest.push(ev);
+ if (++num_events_processed > MAX_QUEUED_EVENTS)
+ break;
+ }
+
+ while ((ev = pop_earliest_stamped_before(cycle_end))) {
+ ev->execute(nframes, cycle_start, cycle_end);
+ dest.push(ev);
+ ++num_events_processed;
+ }
+
+ if (num_events_processed > 0)
+ dest.whip();
}
+
/** Pops the prepared event at the front of the prepare queue, if it exists.
*
* This method will only pop events that have been prepared, and are
diff --git a/src/libs/engine/QueuedEventSource.h b/src/libs/engine/QueuedEventSource.h
index abdea293..f6be92d7 100644
--- a/src/libs/engine/QueuedEventSource.h
+++ b/src/libs/engine/QueuedEventSource.h
@@ -29,6 +29,7 @@
namespace Ingen {
class QueuedEvent;
+class PostProcessor;
/** Queue of events that need processing before reaching the audio thread.
@@ -50,14 +51,16 @@ public:
void activate() { Slave::start(); }
void deactivate() { Slave::stop(); }
- Event* pop_earliest_queued_before(const SampleCount time);
- inline Event* pop_earliest_stamped_before(const SampleCount time);
+ void process(PostProcessor& dest, SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end);
void unblock();
protected:
void push_queued(QueuedEvent* const ev);
- void push_stamped(Event* const ev);
+ inline void push_stamped(Event* const ev) { _stamped_queue.push(ev); }
+
+ Event* pop_earliest_queued_before(const SampleCount time);
+ inline Event* pop_earliest_stamped_before(const SampleCount time);
bool unprepared_events() { return (_prepared_back != _back); }