summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/Engine.cpp4
-rw-r--r--src/engine/JackDriver.cpp71
-rw-r--r--src/engine/JackDriver.hpp13
-rw-r--r--src/engine/ingen_lv2.cpp11
4 files changed, 83 insertions, 16 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index 74c9b12b..8e0d7e0e 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -110,8 +110,8 @@ Engine::main()
{
Raul::Thread::get().set_context(THREAD_POST_PROCESS);
- // Loop until quit flag is set (by OSCReceiver)
- while ( ! _quit_flag) {
+ // Loop until quit flag is set
+ while (!_quit_flag) {
nanosleep(&main_rate, NULL);
main_iteration();
}
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 638217fc..d83c319f 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -15,10 +15,17 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "ingen-config.h"
+
#include <cstdlib>
#include <string>
#include <jack/midiport.h>
+#ifdef INGEN_JACK_SESSION
+#include <jack/session.h>
+#include <boost/format.hpp>
+#include "serialisation/Serialiser.hpp"
+#endif
#include "raul/log.hpp"
#include "raul/List.hpp"
@@ -38,7 +45,6 @@
#include "ProcessSlave.hpp"
#include "QueuedEvent.hpp"
#include "ThreadManager.hpp"
-#include "ingen-config.h"
#include "module/World.hpp"
#include "shared/LV2Features.hpp"
#include "shared/LV2URIMap.hpp"
@@ -224,20 +230,30 @@ JackDriver::attach(const std::string& server_name,
{
assert(!_client);
if (!jack_client) {
- // Try supplied server name
- if (!server_name.empty()) {
+ #ifdef INGEN_JACK_SESSION
+ const std::string uuid = _engine.world()->jack_uuid();
+ if (!uuid.empty()) {
_client = jack_client_open(client_name.c_str(),
- JackServerName, NULL, server_name.c_str());
- if (_client)
- LOG(info) << "Connected to JACK server `" << server_name << "'" << endl;
+ JackSessionID, NULL,
+ uuid.c_str());
+ LOG(info) << "Connected to JACK server as client `"
+ << client_name.c_str() << "' UUID `" << uuid << "'" << endl;
}
+ #endif
+ // Try supplied server name
+ if (!_client && !server_name.empty()) {
+ if ((_client = jack_client_open(client_name.c_str(),
+ JackServerName, NULL,
+ server_name.c_str()))) {
+ LOG(info) << "Connected to JACK server `" << server_name << "'" << endl;
+ }
+ }
+
// Either server name not specified, or supplied server name does not exist
// Connect to default server
if (!_client) {
- _client = jack_client_open(client_name.c_str(), JackNullOption, NULL);
-
- if (_client)
+ if ((_client = jack_client_open(client_name.c_str(), JackNullOption, NULL)))
LOG(info) << "Connected to default JACK server" << endl;
}
@@ -260,6 +276,9 @@ JackDriver::attach(const std::string& server_name,
jack_set_thread_init_callback(_client, thread_init_cb, this);
jack_set_sample_rate_callback(_client, sample_rate_cb, this);
jack_set_buffer_size_callback(_client, block_length_cb, this);
+#ifdef INGEN_JACK_SESSION
+ jack_set_session_callback(_client, session_cb, this);
+#endif
for (Raul::List<JackPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
(*i)->create();
@@ -524,4 +543,38 @@ JackDriver::_block_length_cb(jack_nframes_t nframes)
}
+#ifdef INGEN_JACK_SESSION
+void
+JackDriver::_session_cb(jack_session_event_t* event)
+{
+ LOG(info) << "Jack session save to " << event->session_dir << endl;
+
+ const string cmd = (boost::format("ingen -eg -n %1% -u %2% -l ${SESSION_DIR}")
+ % jack_get_client_name(_client)
+ % event->client_uuid).str();
+
+ SharedPtr<Serialisation::Serialiser> serialiser = _engine.world()->serialiser();
+ if (serialiser) {
+ SharedPtr<Patch> root(_engine.driver()->root_patch(), NullDeleter<Patch>);
+ serialiser->write_bundle(root, string("file://") + event->session_dir);
+ }
+
+ event->command_line = strdup(cmd.c_str());
+ jack_session_reply(_client, event);
+
+ switch (event->type) {
+ case JackSessionSave:
+ break;
+ case JackSessionSaveAndQuit:
+ LOG(warn) << "Jack session quit" << endl;
+ _engine.quit();
+ break;
+ case JackSessionSaveTemplate:
+ break;
+ }
+
+ jack_session_event_free(event);
+}
+#endif
+
} // namespace Ingen
diff --git a/src/engine/JackDriver.hpp b/src/engine/JackDriver.hpp
index 1d47a8fc..b10efad1 100644
--- a/src/engine/JackDriver.hpp
+++ b/src/engine/JackDriver.hpp
@@ -18,10 +18,15 @@
#ifndef INGEN_ENGINE_JACKAUDIODRIVER_HPP
#define INGEN_ENGINE_JACKAUDIODRIVER_HPP
+#include "ingen-config.h"
+
#include <string>
#include <jack/jack.h>
#include <jack/transport.h>
+#ifdef INGEN_JACK_SESSION
+#include <jack/session.h>
+#endif
#include "raul/AtomicInt.hpp"
#include "raul/List.hpp"
@@ -143,6 +148,11 @@ private:
inline static int sample_rate_cb(jack_nframes_t nframes, void* const jack_driver) {
return ((JackDriver*)jack_driver)->_sample_rate_cb(nframes);
}
+#ifdef INGEN_JACK_SESSION
+ inline static void session_cb(jack_session_event_t* event, void* jack_driver) {
+ ((JackDriver*)jack_driver)->_session_cb(event);
+ }
+#endif
// Non static callbacks (methods)
void _thread_init_cb();
@@ -150,6 +160,9 @@ private:
int _process_cb(jack_nframes_t nframes);
int _block_length_cb(jack_nframes_t nframes);
int _sample_rate_cb(jack_nframes_t nframes);
+#ifdef INGEN_JACK_SESSION
+ void _session_cb(jack_session_event_t* event);
+#endif
Engine& _engine;
Raul::Thread* _jack_thread;
diff --git a/src/engine/ingen_lv2.cpp b/src/engine/ingen_lv2.cpp
index 3b62eca9..8b9fd90d 100644
--- a/src/engine/ingen_lv2.cpp
+++ b/src/engine/ingen_lv2.cpp
@@ -293,9 +293,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
interface->process(*engine->post_processor(), context, false);
engine->post_processor()->process();
- plugin->world->parser()->parse_document(plugin->world,
- plugin->world->engine().get(),
- patch->filename);
+ plugin->world->parser()->parse_file(plugin->world,
+ plugin->world->engine().get(),
+ patch->filename);
while (!interface->empty()) {
interface->process(*engine->post_processor(), context, false);
@@ -402,8 +402,9 @@ Lib::Lib()
Shared::bundle_file_path("manifest.ttl"))));
for (Records::iterator i = records.begin(); i != records.end(); ++i) {
- patches.push_back(SharedPtr<const LV2Patch>(
- new LV2Patch(i->uri.str(), i->filename)));
+ patches.push_back(
+ SharedPtr<const LV2Patch>(new LV2Patch(i->patch_uri.str(),
+ i->file_uri)));
}
ingen_world_free(world);