Implement the LV2 urid extension and remove implementation of (experimental) LV2...
authorDavid Robillard <d@drobilla.net>
Mon, 21 Nov 2011 03:22:08 +0000 (03:22 +0000)
committerDavid Robillard <d@drobilla.net>
Mon, 21 Nov 2011 03:22:08 +0000 (03:22 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10723 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/uri_map.h
libs/ardour/lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h [deleted file]
libs/ardour/lv2_plugin_lilv.cc
libs/ardour/uri_map.cc

index f24d03f18c11447ef22f7b0689b1faa60e53f0ff..3fb8560022f71d6479063a9cbcfe69e7ba7012fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2009 Paul Davis
+    Copyright (C) 2009-2011 Paul Davis
     Author: David Robillard
 
     This program is free software; you can redistribute it and/or modify
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
 */
 
 #ifndef __ardour_uri_map_h__
 #define __ardour_uri_map_h__
 
 #include <map>
-#include <string>
 
 #include <boost/utility.hpp>
 
 #include "lv2.h"
 #include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
-#include "lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h"
+#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
 
 namespace ARDOUR {
 
 
-/** Implementation of the LV2 URI Map extension
+/** Implementation of the LV2 uri-map and urid extensions.
  */
 class URIMap : public boost::noncopyable {
 public:
        URIMap();
 
-       LV2_Feature* feature() { return &uri_map_feature; }
+       LV2_Feature* uri_map_feature()    { return &_uri_map_feature; }
+       LV2_Feature* urid_map_feature()   { return &_urid_map_feature; }
+       LV2_Feature* urid_unmap_feature() { return &_urid_unmap_feature; }
 
        uint32_t uri_to_id(const char* map,
                           const char* uri);
 
        const char* id_to_uri(const char* map,
-                             uint32_t id);
+                             uint32_t    id);
 
 private:
        static uint32_t uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data,
                                          const char*               map,
                                          const char*               uri);
 
-       static const char* uri_unmap_id_to_uri(LV2_URI_Map_Callback_Data callback_data,
-                                              const char*               map,
-                                              const uint32_t            id);
+       static LV2_URID urid_map(LV2_URID_Map_Handle handle,
+                                const char*         uri);
+
+       static const char* urid_unmap(LV2_URID_Unmap_Handle handle,
+                                     LV2_URID              urid);
 
        typedef std::map<uint16_t, uint32_t> EventToGlobal;
        typedef std::map<uint32_t, uint16_t> GlobalToEvent;
@@ -62,10 +64,12 @@ private:
        EventToGlobal _event_to_global;
        GlobalToEvent _global_to_event;
 
-       LV2_Feature           uri_map_feature;
-       LV2_URI_Map_Feature   uri_map_feature_data;
-       LV2_Feature           uri_unmap_feature;
-       LV2_URI_Unmap_Feature uri_unmap_feature_data;
+       LV2_Feature           _uri_map_feature;
+       LV2_URI_Map_Feature   _uri_map_feature_data;
+       LV2_Feature           _urid_map_feature;
+       LV2_URID_Map          _urid_map_feature_data;
+       LV2_Feature           _urid_unmap_feature;
+       LV2_URID_Unmap        _urid_unmap_feature_data;
 };
 
 
diff --git a/libs/ardour/lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h b/libs/ardour/lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h
deleted file mode 100644 (file)
index d6cb900..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* lv2_uri_unmap.h - C header file for the LV2 URI Unmap extension.
- *
- * Copyright (C) 2010 David Robillard <http://drobilla.net>
- *
- * This header is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This header is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this header; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA
- */
-
-/** @file
- * C header for the LV2 URI Map extension <http://lv2plug.in/ns/ext/uri-unmap>.
- */
-
-#ifndef LV2_URI_UNMAP_H
-#define LV2_URI_UNMAP_H
-
-#define LV2_URI_UNMAP_URI "http://lv2plug.in/ns/ext/uri-unmap"
-
-#include <stdint.h>
-
-
-/** Opaque pointer to host data. */
-typedef void* LV2_URI_Unmap_Callback_Data;
-
-
-/** The data field of the LV2_Feature for the URI Unmap extension.
- *
- * To support this extension the host must pass an LV2_Feature struct to the
- * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/uri-unmap"
- * and data pointed to an instance of this struct.
- */
-typedef struct {
-
-       /** Opaque pointer to host data.
-        *
-        * The plugin MUST pass this to any call to functions in this struct.
-        * Otherwise, it must not be interpreted in any way.
-        */
-       LV2_URI_Unmap_Callback_Data callback_data;
-
-       /** Get the numeric ID of a URI from the host.
-        *
-        * @param callback_data Must be the callback_data member of this struct.
-        * @param map The 'context' used to map this URI.
-        * @param id The URI ID to unmap.
-        * @return The string form of @a id, or NULL on error.
-        *
-        * The @a id MUST be a value previously returned from
-        * LV2_Uri_Map_Feature.uri_to_id.
-        *
-        * The returned string is owned by the host and MUST NOT be freed by
-        * the plugin or stored for a long period of time (e.g. across run
-        * invocations) without copying.
-        *
-        * This function is referentially transparent - any number of calls with
-        * the same arguments is guaranteed to return the same value over the life
-        * of a plugin instance (though the same ID may return different values
-        * with a different map parameter).
-        *
-        * This function may be called from any non-realtime thread, possibly
-        * concurrently (hosts may simply use a mutex to meet these requirements).
-        */
-       const char* (*id_to_uri)(LV2_URI_Unmap_Callback_Data callback_data,
-                                const char*                 map,
-                                uint32_t                    id);
-
-} LV2_URI_Unmap_Feature;
-
-
-#endif /* LV2_URI_UNMAP_H */
-
index fc8ed9583507cc3ceaa520383054bcb2e21bef45..bee0f3846f47af39d868e6fdbf10bfb7e6863373 100644 (file)
@@ -167,13 +167,15 @@ LV2Plugin::init(void* c_plugin, framecnt_t rate)
        }
 #endif
 
-       _features    = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * 6);
+       _features    = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * 8);
        _features[0] = &_instance_access_feature;
        _features[1] = &_data_access_feature;
        _features[2] = &_path_support_feature;
        _features[3] = &_new_file_support_feature;
-       _features[4] = _uri_map.feature();
-       _features[5] = NULL;
+       _features[4] = _uri_map.uri_map_feature();
+       _features[5] = _uri_map.urid_map_feature();
+       _features[6] = _uri_map.urid_unmap_feature();
+       _features[7] = NULL;
 
        LV2_Files_Path_Support* path_support = (LV2_Files_Path_Support*)malloc(
                sizeof(LV2_Files_Path_Support));
index a702ee3862d8b685694a1755edb157e791cdb1a0..6a1d0a58d165b2c3c9c4d68a495f6f1f1dda7344 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2008-2010 Paul Davis
+    Copyright (C) 2008-2011 Paul Davis
     Author: David Robillard
 
     This program is free software; you can redistribute it and/or modify
@@ -15,7 +15,6 @@
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
 */
 
 #include <cassert>
@@ -37,15 +36,20 @@ namespace ARDOUR {
 
 URIMap::URIMap()
 {
-       uri_map_feature_data.uri_to_id     = &URIMap::uri_map_uri_to_id;
-       uri_map_feature_data.callback_data = this;
-       uri_map_feature.URI                = LV2_URI_MAP_URI;
-       uri_map_feature.data               = &uri_map_feature_data;
-
-       uri_unmap_feature_data.id_to_uri     = &URIMap::uri_unmap_id_to_uri;
-       uri_unmap_feature_data.callback_data = this;
-       uri_unmap_feature.URI                = LV2_URI_UNMAP_URI;
-       uri_unmap_feature.data               = &uri_unmap_feature_data;
+       _uri_map_feature_data.uri_to_id     = &URIMap::uri_map_uri_to_id;
+       _uri_map_feature_data.callback_data = this;
+       _uri_map_feature.URI                = LV2_URI_MAP_URI;
+       _uri_map_feature.data               = &_uri_map_feature_data;
+
+       _urid_map_feature_data.map    = &URIMap::urid_map;
+       _urid_map_feature_data.handle = this;
+       _urid_map_feature.URI         = LV2_URID_MAP_URI;
+       _urid_map_feature.data        = &_urid_map_feature_data;
+
+       _urid_unmap_feature_data.unmap  = &URIMap::urid_unmap;
+       _urid_unmap_feature_data.handle = this;
+       _urid_unmap_feature.URI         = LV2_URID_UNMAP_URI;
+       _urid_unmap_feature.data        = &_urid_unmap_feature_data;
 }
 
 
@@ -98,19 +102,26 @@ URIMap::uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data,
                           const char*               map,
                           const char*               uri)
 {
-       URIMap* me = (URIMap*)callback_data;
+       URIMap* const me = (URIMap*)callback_data;
        return me->uri_to_id(map, uri);
+}
 
+
+LV2_URID
+URIMap::urid_map(LV2_URID_Map_Handle handle,
+                 const char*         uri)
+{
+       URIMap* const me = (URIMap*)handle;
+       return me->uri_to_id(NULL, uri);
 }
 
 
 const char*
-URIMap::uri_unmap_id_to_uri(LV2_URI_Map_Callback_Data callback_data,
-                            const char*               map,
-                            uint32_t                  id)
+URIMap::urid_unmap(LV2_URID_Unmap_Handle handle,
+                   LV2_URID              urid)
 {
-       URIMap* me = (URIMap*)callback_data;
-       return me->id_to_uri(map, id);
+       URIMap* const me = (URIMap*)handle;
+       return me->id_to_uri(NULL, urid);
 }