diff options
author | David Robillard <d@drobilla.net> | 2014-01-24 00:57:48 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-01-24 00:57:48 +0000 |
commit | d970641441746aacfc645176b71d7ba71af0463a (patch) | |
tree | 1b4263ce9bc271b8617a500e9272e0dc482c6fcb /src | |
parent | 229be04694a5b99a1e9c384a7c65452ebb30eedd (diff) | |
download | ingen-d970641441746aacfc645176b71d7ba71af0463a.tar.gz ingen-d970641441746aacfc645176b71d7ba71af0463a.tar.bz2 ingen-d970641441746aacfc645176b71d7ba71af0463a.zip |
Update for latest LV2 Atom Object simplifications.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5319 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/AtomReader.cpp | 25 | ||||
-rw-r--r-- | src/AtomWriter.cpp | 91 | ||||
-rw-r--r-- | src/URIs.cpp | 4 | ||||
-rw-r--r-- | src/gui/App.cpp | 2 | ||||
-rw-r--r-- | src/gui/ConnectWindow.cpp | 21 | ||||
-rw-r--r-- | src/gui/ConnectWindow.hpp | 5 | ||||
-rw-r--r-- | src/server/ControlBindings.cpp | 14 | ||||
-rw-r--r-- | src/server/JackDriver.cpp | 16 | ||||
-rw-r--r-- | src/server/events/Delta.cpp | 2 | ||||
-rw-r--r-- | src/server/ingen_lv2.cpp | 2 |
10 files changed, 111 insertions, 71 deletions
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index f7b5a82a..2f3cf695 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -98,7 +98,7 @@ AtomReader::atom_to_path(const LV2_Atom* atom) bool AtomReader::is_message(URIs& uris, const LV2_Atom* msg) { - if (msg->type != uris.atom_Blank && msg->type != uris.atom_Resource) { + if (msg->type != uris.atom_Object) { return false; } @@ -115,7 +115,7 @@ AtomReader::is_message(URIs& uris, const LV2_Atom* msg) bool AtomReader::write(const LV2_Atom* msg) { - if (msg->type != _uris.atom_Blank && msg->type != _uris.atom_Resource) { + if (msg->type != _uris.atom_Object) { _log.warn(fmt("Unknown message type <%1%>\n") % _map.unmap_uri(msg->type)); return false; @@ -123,12 +123,24 @@ AtomReader::write(const LV2_Atom* msg) const LV2_Atom_Object* obj = (const LV2_Atom_Object*)msg; const LV2_Atom* subject = NULL; - - lv2_atom_object_get(obj, (LV2_URID)_uris.patch_subject, &subject, NULL); - const char* subject_uri = atom_to_uri(subject); + const LV2_Atom* number = NULL; + + lv2_atom_object_get(obj, + (LV2_URID)_uris.patch_subject, &subject, + (LV2_URID)_uris.patch_sequenceNumber, &number, + NULL); + + const char* subject_uri = atom_to_uri(subject); + const int32_t seq_id = ((number && number->type == _uris.atom_Int) + ? ((const LV2_Atom_Int*)number)->body + : 0); + if (seq_id) { + _iface.set_response_id(seq_id); + } else { + _iface.set_response_id(-1); + } if (obj->body.otype == _uris.patch_Get) { - _iface.set_response_id(obj->body.id); _iface.get(Raul::URI(subject_uri)); } else if (obj->body.otype == _uris.patch_Delete) { const LV2_Atom_Object* body = NULL; @@ -194,7 +206,6 @@ AtomReader::write(const LV2_Atom* msg) } else { Ingen::Resource::Properties props; get_props(body, props); - _iface.set_response_id(obj->body.id); _iface.put(Raul::URI(subject_uri), props); } } else if (obj->body.otype == _uris.patch_Set) { diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index 8b2d90c5..99cd1492 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -98,7 +98,7 @@ void AtomWriter::forge_properties(const Resource::Properties& properties) { for (auto p : properties) { - lv2_atom_forge_property_head(&_forge, _map.map_uri(p.first.c_str()), 0); + lv2_atom_forge_key(&_forge, _map.map_uri(p.first.c_str())); if (p.second.type() == _forge.URI) { forge_uri(Raul::URI(p.second.ptr<char>())); } else { @@ -112,27 +112,39 @@ void AtomWriter::forge_arc(const Raul::Path& tail, const Raul::Path& head) { LV2_Atom_Forge_Frame arc; - lv2_atom_forge_blank(&_forge, &arc, 0, _uris.ingen_Arc); - lv2_atom_forge_property_head(&_forge, _uris.ingen_tail, 0); + lv2_atom_forge_object(&_forge, &arc, 0, _uris.ingen_Arc); + lv2_atom_forge_key(&_forge, _uris.ingen_tail); forge_uri(Node::path_to_uri(tail)); - lv2_atom_forge_property_head(&_forge, _uris.ingen_head, 0); + lv2_atom_forge_key(&_forge, _uris.ingen_head); forge_uri(Node::path_to_uri(head)); lv2_atom_forge_pop(&_forge, &arc); } void +AtomWriter::forge_request(LV2_Atom_Forge_Frame* frame, LV2_URID type) +{ + lv2_atom_forge_object(&_forge, frame, 0, type); + + const int32_t id = next_id(); + if (id != 0) { + lv2_atom_forge_key(&_forge, _uris.patch_sequenceNumber); + lv2_atom_forge_int(&_forge, id); + } +} + +void AtomWriter::put(const Raul::URI& uri, const Resource::Properties& properties, Resource::Graph ctx) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Put); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + forge_request(&msg, _uris.patch_Put); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(uri); - lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); + lv2_atom_forge_key(&_forge, _uris.patch_body); LV2_Atom_Forge_Frame body; - lv2_atom_forge_blank(&_forge, &body, 0, 0); + lv2_atom_forge_object(&_forge, &body, 0, 0); forge_properties(properties); lv2_atom_forge_pop(&_forge, &body); @@ -146,19 +158,19 @@ AtomWriter::delta(const Raul::URI& uri, const Resource::Properties& add) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Patch); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + forge_request(&msg, _uris.patch_Patch); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(uri); - lv2_atom_forge_property_head(&_forge, _uris.patch_remove, 0); + lv2_atom_forge_key(&_forge, _uris.patch_remove); LV2_Atom_Forge_Frame remove_obj; - lv2_atom_forge_blank(&_forge, &remove_obj, 0, 0); + lv2_atom_forge_object(&_forge, &remove_obj, 0, 0); forge_properties(remove); lv2_atom_forge_pop(&_forge, &remove_obj); - lv2_atom_forge_property_head(&_forge, _uris.patch_add, 0); + lv2_atom_forge_key(&_forge, _uris.patch_add); LV2_Atom_Forge_Frame add_obj; - lv2_atom_forge_blank(&_forge, &add_obj, 0, 0); + lv2_atom_forge_object(&_forge, &add_obj, 0, 0); forge_properties(add); lv2_atom_forge_pop(&_forge, &add_obj); @@ -171,10 +183,10 @@ AtomWriter::move(const Raul::Path& old_path, const Raul::Path& new_path) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Move); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + forge_request(&msg, _uris.patch_Move); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(Node::path_to_uri(old_path)); - lv2_atom_forge_property_head(&_forge, _uris.patch_destination, 0); + lv2_atom_forge_key(&_forge, _uris.patch_destination); forge_uri(Node::path_to_uri(new_path)); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); @@ -184,8 +196,8 @@ void AtomWriter::del(const Raul::URI& uri) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Delete); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + forge_request(&msg, _uris.patch_Delete); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(uri); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); @@ -196,10 +208,10 @@ AtomWriter::connect(const Raul::Path& tail, const Raul::Path& head) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Put); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + forge_request(&msg, _uris.patch_Put); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(Node::path_to_uri(Raul::Path::lca(tail, head))); - lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); + lv2_atom_forge_key(&_forge, _uris.patch_body); forge_arc(tail, head); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); @@ -210,8 +222,8 @@ AtomWriter::disconnect(const Raul::Path& tail, const Raul::Path& head) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Delete); - lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); + forge_request(&msg, _uris.patch_Delete); + lv2_atom_forge_key(&_forge, _uris.patch_body); forge_arc(tail, head); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); @@ -222,15 +234,15 @@ AtomWriter::disconnect_all(const Raul::Path& graph, const Raul::Path& path) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Delete); + forge_request(&msg, _uris.patch_Delete); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(Node::path_to_uri(graph)); - lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); + lv2_atom_forge_key(&_forge, _uris.patch_body); LV2_Atom_Forge_Frame arc; - lv2_atom_forge_blank(&_forge, &arc, 0, _uris.ingen_Arc); - lv2_atom_forge_property_head(&_forge, _uris.ingen_incidentTo, 0); + lv2_atom_forge_object(&_forge, &arc, 0, _uris.ingen_Arc); + lv2_atom_forge_key(&_forge, _uris.ingen_incidentTo); forge_uri(Node::path_to_uri(path)); lv2_atom_forge_pop(&_forge, &arc); @@ -244,12 +256,12 @@ AtomWriter::set_property(const Raul::URI& subject, const Atom& value) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Set); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + forge_request(&msg, _uris.patch_Set); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(subject); - lv2_atom_forge_property_head(&_forge, _uris.patch_property, 0); + lv2_atom_forge_key(&_forge, _uris.patch_property); lv2_atom_forge_urid(&_forge, _map.map_uri(predicate.c_str())); - lv2_atom_forge_property_head(&_forge, _uris.patch_value, 0); + lv2_atom_forge_key(&_forge, _uris.patch_value); lv2_atom_forge_atom(&_forge, value.size(), value.type()); lv2_atom_forge_write(&_forge, value.get_body(), value.size()); @@ -260,14 +272,15 @@ AtomWriter::set_property(const Raul::URI& subject, void AtomWriter::set_response_id(int32_t id) { + _id = id; } void AtomWriter::get(const Raul::URI& uri) { LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Get); - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + forge_request(&msg, _uris.patch_Get); + lv2_atom_forge_key(&_forge, _uris.patch_subject); forge_uri(uri); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); @@ -281,14 +294,14 @@ AtomWriter::response(int32_t id, Status status, const std::string& subject) } LV2_Atom_Forge_Frame msg; - lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Response); - lv2_atom_forge_property_head(&_forge, _uris.patch_request, 0); + forge_request(&msg, _uris.patch_Response); + lv2_atom_forge_key(&_forge, _uris.patch_request); lv2_atom_forge_int(&_forge, id); if (!subject.empty() && Raul::URI::is_valid(subject)) { - lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + lv2_atom_forge_key(&_forge, _uris.patch_subject); lv2_atom_forge_uri(&_forge, subject.c_str(), subject.length()); } - lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); + lv2_atom_forge_key(&_forge, _uris.patch_body); lv2_atom_forge_int(&_forge, static_cast<int>(status)); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); diff --git a/src/URIs.cpp b/src/URIs.cpp index b810259b..b6bf7ad8 100644 --- a/src/URIs.cpp +++ b/src/URIs.cpp @@ -44,12 +44,11 @@ URIs::Quark::Quark(Forge& forge, URIMap* map, const char* c_str) URIs::URIs(Forge& f, URIMap* map) : forge(f) , atom_AtomPort (forge, map, LV2_ATOM__AtomPort) - , atom_Blank (forge, map, LV2_ATOM__Blank) , atom_Bool (forge, map, LV2_ATOM__Bool) , atom_Chunk (forge, map, LV2_ATOM__Chunk) , atom_Float (forge, map, LV2_ATOM__Float) , atom_Int (forge, map, LV2_ATOM__Int) - , atom_Resource (forge, map, LV2_ATOM__Resource) + , atom_Object (forge, map, LV2_ATOM__Object) , atom_Sequence (forge, map, LV2_ATOM__Sequence) , atom_Sound (forge, map, LV2_ATOM__Sound) , atom_String (forge, map, LV2_ATOM__String) @@ -133,6 +132,7 @@ URIs::URIs(Forge& f, URIMap* map) , patch_property (forge, map, LV2_PATCH__property) , patch_remove (forge, map, LV2_PATCH__remove) , patch_request (forge, map, LV2_PATCH__request) + , patch_sequenceNumber (forge, map, LV2_PATCH__sequenceNumber) , patch_subject (forge, map, LV2_PATCH__subject) , patch_value (forge, map, LV2_PATCH__value) , patch_wildcard (forge, map, LV2_PATCH__wildcard) diff --git a/src/gui/App.cpp b/src/gui/App.cpp index 1b71cf06..719fe694 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -335,7 +335,7 @@ bool App::quit(Gtk::Window* dialog_parent) { bool quit = true; - if (_world->engine()) { + if (_world->engine() && _connect_window->attached()) { Gtk::MessageDialog d( "The engine is running in this process. Quitting will terminate Ingen." "\n\n" "Are you sure you want to quit?", diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index ca4836b7..6c1b5827 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -15,8 +15,10 @@ */ #include <stdlib.h> -#include <string> + +#include <limits> #include <sstream> +#include <string> #include <gtkmm/stock.h> @@ -86,6 +88,20 @@ ConnectWindow::start(App& app, Ingen::World* world) } void +ConnectWindow::ingen_response(int32_t id, + Status status, + const std::string& subject) +{ + if (id == _ping_id) { + if (status != Status::SUCCESS) { + _app->world()->log().error("Failed to get root patch\n"); + } else { + _attached = true; + } + } +} + +void ConnectWindow::set_connected_to(SPtr<Ingen::Interface> engine) { _app->world()->set_interface(engine); @@ -388,7 +404,7 @@ ConnectWindow::gtk_callback() _app->client()->signal_response().connect( sigc::mem_fun(this, &ConnectWindow::ingen_response)); - _ping_id = g_random_int(); + _ping_id = g_random_int_range(1, std::numeric_limits<int32_t>::max()); _app->interface()->set_response_id(_ping_id); _app->interface()->get(Raul::URI("ingen:/engine")); @@ -436,6 +452,7 @@ ConnectWindow::gtk_callback() _progress_label->set_text("Connected to engine"); _connect_stage = 0; // set ourselves up for next time (if there is one) _finished_connecting = true; + _app->interface()->set_response_id(-1); return false; // deregister this callback } diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp index 2efa394f..5e375342 100644 --- a/src/gui/ConnectWindow.hpp +++ b/src/gui/ConnectWindow.hpp @@ -51,9 +51,6 @@ public: void set_connected_to(SPtr<Ingen::Interface> engine); void start(App& app, Ingen::World* world); - void ingen_response(int32_t id, Status status, const std::string& subject) { - _attached = true; - } bool attached() const { return _finished_connecting; } bool quit_flag() const { return _quit_flag; } @@ -61,6 +58,8 @@ public: private: enum class Mode { CONNECT_REMOTE, LAUNCH_REMOTE, INTERNAL }; + void ingen_response(int32_t id, Status status, const std::string& subject); + void server_toggled(); void launch_toggled(); void internal_toggled(); diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index fce5ba28..3c6d26df 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -68,7 +68,7 @@ ControlBindings::binding_key(const Atom& binding) const const Ingen::URIs& uris = _engine.world()->uris(); Key key; LV2_Atom* num = NULL; - if (binding.type() == uris.atom_Blank) { + if (binding.type() == uris.atom_Object) { const LV2_Atom_Object_Body* obj = (const LV2_Atom_Object_Body*) binding.get_body(); if (obj->otype == uris.midi_Bender) { @@ -283,19 +283,19 @@ forge_binding(const URIs& uris, LV2_Atom_Forge_Frame frame; switch (binding_type) { case ControlBindings::Type::MIDI_CC: - lv2_atom_forge_blank(forge, &frame, 0, uris.midi_Controller); - lv2_atom_forge_property_head(forge, uris.midi_controllerNumber, 0); + lv2_atom_forge_object(forge, &frame, 0, uris.midi_Controller); + lv2_atom_forge_key(forge, uris.midi_controllerNumber); lv2_atom_forge_int(forge, value); break; case ControlBindings::Type::MIDI_BENDER: - lv2_atom_forge_blank(forge, &frame, 0, uris.midi_Bender); + lv2_atom_forge_object(forge, &frame, 0, uris.midi_Bender); break; case ControlBindings::Type::MIDI_CHANNEL_PRESSURE: - lv2_atom_forge_blank(forge, &frame, 0, uris.midi_ChannelPressure); + lv2_atom_forge_object(forge, &frame, 0, uris.midi_ChannelPressure); break; case ControlBindings::Type::MIDI_NOTE: - lv2_atom_forge_blank(forge, &frame, 0, uris.midi_NoteOn); - lv2_atom_forge_property_head(forge, uris.midi_noteNumber, 0); + lv2_atom_forge_object(forge, &frame, 0, uris.midi_NoteOn); + lv2_atom_forge_key(forge, uris.midi_noteNumber); lv2_atom_forge_int(forge, value); break; case ControlBindings::Type::MIDI_RPN: // TODO diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 32dd625f..8157bdbf 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -367,22 +367,22 @@ JackDriver::append_time_events(ProcessContext& context, uint8_t pos_buf[256]; LV2_Atom_Forge_Frame frame; lv2_atom_forge_set_buffer(&_forge, pos_buf, sizeof(pos_buf)); - lv2_atom_forge_blank(&_forge, &frame, 1, uris.time_Position); - lv2_atom_forge_property_head(&_forge, uris.time_frame, 0); + lv2_atom_forge_object(&_forge, &frame, 0, uris.time_Position); + lv2_atom_forge_key(&_forge, uris.time_frame); lv2_atom_forge_long(&_forge, pos->frame); - lv2_atom_forge_property_head(&_forge, uris.time_speed, 0); + lv2_atom_forge_key(&_forge, uris.time_speed); lv2_atom_forge_float(&_forge, rolling ? 1.0 : 0.0); if (pos->valid & JackPositionBBT) { - lv2_atom_forge_property_head(&_forge, uris.time_barBeat, 0); + lv2_atom_forge_key(&_forge, uris.time_barBeat); lv2_atom_forge_float( &_forge, pos->beat - 1 + (pos->tick / pos->ticks_per_beat)); - lv2_atom_forge_property_head(&_forge, uris.time_bar, 0); + lv2_atom_forge_key(&_forge, uris.time_bar); lv2_atom_forge_long(&_forge, pos->bar - 1); - lv2_atom_forge_property_head(&_forge, uris.time_beatUnit, 0); + lv2_atom_forge_key(&_forge, uris.time_beatUnit); lv2_atom_forge_int(&_forge, pos->beat_type); - lv2_atom_forge_property_head(&_forge, uris.time_beatsPerBar, 0); + lv2_atom_forge_key(&_forge, uris.time_beatsPerBar); lv2_atom_forge_float(&_forge, pos->beats_per_bar); - lv2_atom_forge_property_head(&_forge, uris.time_beatsPerMinute, 0); + lv2_atom_forge_key(&_forge, uris.time_beatsPerMinute); lv2_atom_forge_float(&_forge, pos->beats_per_minute); } diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 91db7b21..072d0ba3 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -189,7 +189,7 @@ Delta::pre_process() if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) { if (value == uris.patch_wildcard) { _engine.control_bindings()->learn(port); - } else if (value.type() == uris.atom_Blank) { + } else if (value.type() == uris.atom_Object) { op = SpecialType::CONTROL_BINDING; } else { _status = Status::BAD_VALUE_TYPE; diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 8bcef2da..9d64c07b 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -260,7 +260,7 @@ public: const URIs& uris = _engine.world()->uris(); LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_ports[0]->buffer(); LV2_ATOM_SEQUENCE_FOREACH(seq, ev) { - if (ev->body.type == uris.atom_Blank && + if (ev->body.type == uris.atom_Object && ((LV2_Atom_Object*)&ev)->body.otype == uris.time_Position) { buffer.append_event(ev->time.frames, ev->body.size, |