Implement unused Lv2UridCache
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <lilv/lilv.h>
|
||||
|
||||
#include "Lv2Basics.h"
|
||||
#include "Lv2UridCache.h"
|
||||
#include "Lv2UridMap.h"
|
||||
#include "Plugin.h"
|
||||
|
||||
@@ -123,7 +124,7 @@ public:
|
||||
};
|
||||
|
||||
UridMap& uridMap() { return m_uridMap; }
|
||||
//! Return all
|
||||
const Lv2UridCache& uridCache() const { return m_uridCache; }
|
||||
const std::set<const char*, CmpStr>& supportedFeatureURIs() const
|
||||
{
|
||||
return m_supportedFeatureURIs;
|
||||
@@ -140,6 +141,9 @@ private:
|
||||
// feature data that are common for all Lv2Proc
|
||||
UridMap m_uridMap;
|
||||
|
||||
// URID cache for fast URID access
|
||||
Lv2UridCache m_uridCache;
|
||||
|
||||
// functions
|
||||
bool isSubclassOf(const LilvPluginClass *clvss, const char *uriStr);
|
||||
};
|
||||
|
||||
52
include/Lv2UridCache.h
Normal file
52
include/Lv2UridCache.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Lv2UridCache.h - Lv2UridCache definition
|
||||
*
|
||||
* Copyright (c) 2020-2020 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV2URIDCACHE_H
|
||||
#define LV2URIDCACHE_H
|
||||
|
||||
#include "lmmsconfig.h"
|
||||
|
||||
#ifdef LMMS_HAVE_LV2
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
//! Cached URIDs for fast access (for use in real-time code)
|
||||
class Lv2UridCache
|
||||
{
|
||||
public:
|
||||
enum class Id //!< ID for m_uridCache array
|
||||
{
|
||||
midi_MidiEvent, //!< just an example, unused yet
|
||||
size
|
||||
};
|
||||
//! Return URID for a cache ID
|
||||
uint32_t operator[](Id id) const;
|
||||
|
||||
Lv2UridCache(class UridMap& mapper);
|
||||
private:
|
||||
uint32_t m_cache[static_cast<int>(Id::size)];
|
||||
};
|
||||
|
||||
#endif // LMMS_HAVE_LV2
|
||||
#endif // LV2URIDCACHE_H
|
||||
@@ -98,6 +98,7 @@ set(LMMS_SRCS
|
||||
core/lv2/Lv2Proc.cpp
|
||||
core/lv2/Lv2Manager.cpp
|
||||
core/lv2/Lv2SubPluginFeatures.cpp
|
||||
core/lv2/Lv2UridCache.cpp
|
||||
core/lv2/Lv2UridMap.cpp
|
||||
|
||||
core/midi/MidiAlsaRaw.cpp
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
|
||||
|
||||
|
||||
Lv2Manager::Lv2Manager()
|
||||
Lv2Manager::Lv2Manager() :
|
||||
m_uridCache(m_uridMap)
|
||||
{
|
||||
const char* dbgStr = getenv("LMMS_LV2_DEBUG");
|
||||
m_debug = (dbgStr && *dbgStr);
|
||||
|
||||
57
src/core/lv2/Lv2UridCache.cpp
Normal file
57
src/core/lv2/Lv2UridCache.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Lv2UridCache.cpp - Lv2UridCache implementation
|
||||
*
|
||||
* Copyright (c) 2020-2020 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Lv2UridCache.h"
|
||||
|
||||
#ifdef LMMS_HAVE_LV2
|
||||
|
||||
#include <lv2/lv2plug.in/ns/ext/midi/midi.h>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "Lv2UridMap.h"
|
||||
|
||||
uint32_t Lv2UridCache::operator[](Lv2UridCache::Id id) const
|
||||
{
|
||||
Q_ASSERT(id != Id::size);
|
||||
return m_cache[static_cast<std::size_t>(id)];
|
||||
}
|
||||
|
||||
Lv2UridCache::Lv2UridCache(UridMap &mapper)
|
||||
{
|
||||
const uint32_t noIdYet = 0;
|
||||
std::fill_n(m_cache, static_cast<std::size_t>(Id::size), noIdYet);
|
||||
|
||||
auto init = [this, &mapper](Id id, const char* uridStr)
|
||||
{
|
||||
m_cache[static_cast<std::size_t>(id)] = mapper.map(uridStr);
|
||||
};
|
||||
|
||||
init(Id::midi_MidiEvent, LV2_MIDI__MidiEvent);
|
||||
|
||||
for(uint32_t urid : m_cache) { Q_ASSERT(urid != noIdYet); }
|
||||
}
|
||||
|
||||
#endif // LMMS_HAVE_LV2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user