Allow a LV2 plugin to mark the session dirty
authorRobin Gareus <robin@gareus.org>
Thu, 13 Oct 2016 14:04:28 +0000 (16:04 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 13 Oct 2016 14:04:28 +0000 (16:04 +0200)
If some plugin-internal state changes (GUI <> Plugin e.g. load a sample)
no ports change and the host does not know that the plugin state has
changed. The session may be closed without save.

This is a prototype using an ardour.org URI, pending upstream lv2plug.in

libs/ardour/ardour/uri_map.h
libs/ardour/lv2_plugin.cc
libs/ardour/uri_map.cc

index 460aa99773e02aa04c14e02d0b237a26f57d95f1..9b831bea6acdbaea9d636658c9691c1224eed224 100644 (file)
@@ -92,6 +92,7 @@ public:
                uint32_t auto_end;
                uint32_t auto_parameter;
                uint32_t auto_value;
+               uint32_t state_Dirty;
 #endif
        };
 
index 2d19ea94581e18f6c1743a90cdb96203557700ac..717e933ebfdc0e3c6fa14f33ea1f6f70faae42ee 100644 (file)
@@ -2692,6 +2692,18 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                }
                                        }
                                }
+
+                               // Intercept state dirty message
+                               if (_has_state_interface /* && (flags & PORT_DIRTYMSG)*/) {
+                                       LV2_Atom* atom = (LV2_Atom*)(data - sizeof(LV2_Atom));
+                                       if (atom->type == _uri_map.urids.atom_Blank ||
+                                           atom->type == _uri_map.urids.atom_Object) {
+                                               LV2_Atom_Object* obj = (LV2_Atom_Object*)atom;
+                                               if (obj->body.otype == _uri_map.urids.state_Dirty) {
+                                                       _session.set_dirty ();
+                                               }
+                                       }
+                               }
 #endif
 
                                // Intercept patch change messages to emit PropertyChanged signal
index 4bdb405a0ee84a2a9131096388070e51a3f49633..c8af4095066c9334455f63404bea33adc4fb3d37 100644 (file)
@@ -70,6 +70,7 @@ URIMap::URIDs::init(URIMap& uri_map)
        auto_end           = uri_map.uri_to_id(LV2_AUTOMATE_URI__end);
        auto_parameter     = uri_map.uri_to_id(LV2_AUTOMATE_URI__parameter);
        auto_value         = uri_map.uri_to_id(LV2_AUTOMATE_URI__value);
+       state_Dirty        = uri_map.uri_to_id("http://ardour.org/lv2/state#Dirty"); // XXX http://lv2plug.in/ns/ext/state/#dirty
 #endif
 }