Audacity 3.2.0
Classes | Public Member Functions | Public Attributes | List of all members
LV2InstanceFeaturesList Struct Referencefinal

#include <LV2InstanceFeaturesList.h>

Inheritance diagram for LV2InstanceFeaturesList:
[legend]
Collaboration diagram for LV2InstanceFeaturesList:
[legend]

Classes

struct  ValidatePlugin
 Perform extra initialization-time checks. More...
 

Public Member Functions

 LV2InstanceFeaturesList (const LV2FeaturesList &baseFeatures)
 
const LV2FeaturesListBase () const
 
bool InitializeOptions ()
 
const LV2_Options_Option * NominalBlockLengthOption () const
 
size_t AddOption (LV2_URID, uint32_t size, LV2_URID, const void *value)
 
bool ValidateOptions (const LilvNode *subject)
 
bool CheckOptions (const LilvNode *subject, bool required)
 
- Public Member Functions inherited from ExtendedLV2FeaturesList
 ExtendedLV2FeaturesList (WithBase_t, const LV2FeaturesListBase &baseFeatures)
 
virtual ~ExtendedLV2FeaturesList ()
 
FeaturePointers GetFeaturePointers () const override
 
void AddFeature (const char *uri, const void *data)
 
- Public Member Functions inherited from LV2FeaturesListBase
 LV2FeaturesListBase (const LilvPlugin &plug)
 
virtual ~LV2FeaturesListBase ()
 
 LV2FeaturesListBase (const LV2FeaturesListBase &)=delete
 
LV2FeaturesListBaseoperator= (const LV2FeaturesListBase &)=delete
 
virtual FeaturePointers GetFeaturePointers () const =0
 
bool ValidateFeatures (const LilvNode *subject)
 
bool CheckFeatures (const LilvNode *subject, bool required)
 

Public Attributes

std::vector< LV2_Options_Option > mOptions
 
size_t mBlockSizeOption {}
 
size_t mBlockSize { LV2Preferences::DEFAULT_BLOCKSIZE }
 
int mSeqSize { DEFAULT_SEQSIZE }
 
bool mSupportsNominalBlockLength { false }
 
size_t mMinBlockSize { 1 }
 
size_t mMaxBlockSize { mBlockSize }
 
float mSampleRate { 44100.0f }
 
const bool mOk
 
- Public Attributes inherited from ExtendedLV2FeaturesList
const LV2FeaturesListBasemBaseFeatures
 
- Public Attributes inherited from LV2FeaturesListBase
const LilvPlugin & mPlug
 
bool mNoResize { false }
 

Additional Inherited Members

- Public Types inherited from LV2FeaturesListBase
using FeaturePointers = std::vector< const LV2_Feature * >
 Get vector of pointers to features, whose .data() can be passed to lv2. More...
 
- Protected Attributes inherited from ExtendedLV2FeaturesList
std::vector< LV2_Feature > mFeatures
 

Detailed Description

Definition at line 25 of file LV2InstanceFeaturesList.h.

Constructor & Destructor Documentation

◆ LV2InstanceFeaturesList()

LV2InstanceFeaturesList::LV2InstanceFeaturesList ( const LV2FeaturesList baseFeatures)
explicit

Definition at line 17 of file LV2InstanceFeaturesList.cpp.

19 : ExtendedLV2FeaturesList{ WithBase, baseFeatures }
21{
22 AddFeature(LV2_OPTIONS__options, mOptions.data());
23}
constexpr WithBase_t WithBase
Extends one (immutable) feature list (whose lifetime contains this one's)
void AddFeature(const char *uri, const void *data)
std::vector< LV2_Options_Option > mOptions

References ExtendedLV2FeaturesList::AddFeature(), and mOptions.

Here is the call graph for this function:

Member Function Documentation

◆ AddOption()

size_t LV2InstanceFeaturesList::AddOption ( LV2_URID  key,
uint32_t  size,
LV2_URID  type,
const void *  value 
)

Definition at line 68 of file LV2InstanceFeaturesList.cpp.

70{
71 int ndx = mOptions.size();
72 if (key != 0)
73 mOptions.emplace_back(LV2_Options_Option{
74 LV2_OPTIONS_INSTANCE, 0, key, size, type, value });
75 else
76 mOptions.emplace_back(LV2_Options_Option{});
77 return ndx;
78}
static const AudacityProject::AttachedObjects::RegisteredFactory key

References key, mOptions, and size.

Referenced by InitializeOptions().

Here is the caller graph for this function:

◆ Base()

const LV2FeaturesList & LV2InstanceFeaturesList::Base ( ) const
inline

Definition at line 35 of file LV2InstanceFeaturesList.h.

35 {
36 return static_cast<const LV2FeaturesList&>(mBaseFeatures);
37 }
const LV2FeaturesListBase & mBaseFeatures

References ExtendedLV2FeaturesList::mBaseFeatures.

Referenced by LV2Instance::LV2Instance(), and LV2WrapperFeaturesList::LV2WrapperFeaturesList().

Here is the caller graph for this function:

◆ CheckOptions()

bool LV2InstanceFeaturesList::CheckOptions ( const LilvNode *  subject,
bool  required 
)
Parameters
subjectURI of a plugin
requiredwhether to check required or optional options of subject
Returns
true only if !required or else all required options are supported

Definition at line 94 of file LV2InstanceFeaturesList.cpp.

96{
97 using namespace LV2Symbols;
98 bool supported = true;
99 const auto predicate =
100 required ? node_RequiredOption : node_SupportedOption;
101 if (LilvNodesPtr nodes{
102 lilv_world_find_nodes(gWorld, subject, predicate, nullptr) }
103 ){
104 LILV_FOREACH(nodes, i, nodes.get()) {
105 const auto node = lilv_nodes_get(nodes.get(), i);
106 const auto uri = lilv_node_as_string(node);
107 // The signature of our constructor justifies this static_cast
108 const auto urid = static_cast<const LV2FeaturesList&>(mBaseFeatures)
109 .URID_Map(uri);
110 if (urid == urid_NominalBlockLength)
112 // else if (urid == urid_SampleRate)
113 // mSupportsSampleRate = true; // supports changing sample rate
114 else if (required) {
115 const auto end = mOptions.end();
116 supported = (end != std::find_if(mOptions.begin(), end,
117 [&](const auto &option){ return option.key == urid; }));
118 if (!supported) {
119 wxLogError(wxT("%s requires unsupported option %s"),
120 lilv_node_as_string(lilv_plugin_get_uri(&mPlug)), uri);
121 break;
122 }
123 }
124 }
125 }
126 return supported;
127}
wxT("CloseDown"))
Lilv_ptr< LilvNodes, lilv_nodes_free > LilvNodesPtr
const LilvPlugin & mPlug
LilvWorld * gWorld
Definition: LV2Symbols.cpp:31
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), LV2Symbols::gWorld, ExtendedLV2FeaturesList::mBaseFeatures, mOptions, LV2FeaturesListBase::mPlug, mSupportsNominalBlockLength, and wxT().

Referenced by ValidateOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeOptions()

bool LV2InstanceFeaturesList::InitializeOptions ( )
Returns
success

Definition at line 25 of file LV2InstanceFeaturesList.cpp.

26{
27 using namespace LV2Symbols;
28
29 // Construct the null-terminated array describing options, and validate it
30 AddOption(urid_SequenceSize, sizeof(mSeqSize), urid_Int, &mSeqSize);
31 AddOption(urid_MinBlockLength,
32 sizeof(mMinBlockSize), urid_Int, &mMinBlockSize);
33 AddOption(urid_MaxBlockLength,
34 sizeof(mMaxBlockSize), urid_Int, &mMaxBlockSize);
35 // Two options are reset later
36 mBlockSizeOption = AddOption(urid_NominalBlockLength,
37 sizeof(mBlockSize), urid_Int, &mBlockSize);
38 AddOption(urid_SampleRate,
39 sizeof(mSampleRate), urid_Float, &mSampleRate);
40 AddOption(0, 0, 0, nullptr);
41 if (!ValidateOptions(lilv_plugin_get_uri(&mPlug)))
42 return false;
43
44 // Adjust the values in the block size features according to the plugin
45 if (LilvNodePtr minLength{ lilv_world_get(gWorld,
46 lilv_plugin_get_uri(&mPlug), node_MinBlockLength, nullptr) }
47 ; lilv_node_is_int(minLength.get())
48 ){
49 if (auto value = lilv_node_as_int(minLength.get())
50 ; value >= 0
51 )
52 mMinBlockSize = std::max<size_t>(mMinBlockSize, value);
53 }
54 if (LilvNodePtr maxLength{ lilv_world_get(gWorld,
55 lilv_plugin_get_uri(&mPlug), node_MaxBlockLength, nullptr) }
56 ; lilv_node_is_int(maxLength.get())
57 ){
58 if (auto value = lilv_node_as_int(maxLength.get())
59 ; value >= 1
60 )
61 mMaxBlockSize = std::min<size_t>(mMaxBlockSize, value);
62 }
64
65 return true;
66}
Lilv_ptr< LilvNode, lilv_node_free > LilvNodePtr
Definition: LV2Utils.h:33
bool ValidateOptions(const LilvNode *subject)
size_t AddOption(LV2_URID, uint32_t size, LV2_URID, const void *value)

References AddOption(), LV2Symbols::gWorld, mBlockSize, mBlockSizeOption, mMaxBlockSize, mMinBlockSize, LV2FeaturesListBase::mPlug, mSampleRate, mSeqSize, and ValidateOptions().

Here is the call graph for this function:

◆ NominalBlockLengthOption()

const LV2_Options_Option * LV2InstanceFeaturesList::NominalBlockLengthOption ( ) const
Returns
may be null

Definition at line 81 of file LV2InstanceFeaturesList.cpp.

82{
85 else
86 return nullptr;
87}

References mBlockSizeOption, mOptions, and mSupportsNominalBlockLength.

Referenced by LV2Wrapper::SendBlockSize().

Here is the caller graph for this function:

◆ ValidateOptions()

bool LV2InstanceFeaturesList::ValidateOptions ( const LilvNode *  subject)
Parameters
subjectURI of a plugin
Returns
whether all required options of subject are supported

Definition at line 89 of file LV2InstanceFeaturesList.cpp.

90{
91 return CheckOptions(subject, true) && CheckOptions(subject, false);
92}
bool CheckOptions(const LilvNode *subject, bool required)

References CheckOptions().

Referenced by InitializeOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mBlockSize

size_t LV2InstanceFeaturesList::mBlockSize { LV2Preferences::DEFAULT_BLOCKSIZE }

◆ mBlockSizeOption

size_t LV2InstanceFeaturesList::mBlockSizeOption {}

Definition at line 61 of file LV2InstanceFeaturesList.h.

Referenced by InitializeOptions(), and NominalBlockLengthOption().

◆ mMaxBlockSize

size_t LV2InstanceFeaturesList::mMaxBlockSize { mBlockSize }

Definition at line 69 of file LV2InstanceFeaturesList.h.

Referenced by InitializeOptions().

◆ mMinBlockSize

size_t LV2InstanceFeaturesList::mMinBlockSize { 1 }

Definition at line 68 of file LV2InstanceFeaturesList.h.

Referenced by InitializeOptions(), and LV2Instance::SetBlockSize().

◆ mOk

const bool LV2InstanceFeaturesList::mOk

Definition at line 72 of file LV2InstanceFeaturesList.h.

◆ mOptions

std::vector<LV2_Options_Option> LV2InstanceFeaturesList::mOptions

◆ mSampleRate

float LV2InstanceFeaturesList::mSampleRate { 44100.0f }

◆ mSeqSize

int LV2InstanceFeaturesList::mSeqSize { DEFAULT_SEQSIZE }

Definition at line 64 of file LV2InstanceFeaturesList.h.

Referenced by InitializeOptions().

◆ mSupportsNominalBlockLength

bool LV2InstanceFeaturesList::mSupportsNominalBlockLength { false }

Definition at line 66 of file LV2InstanceFeaturesList.h.

Referenced by CheckOptions(), and NominalBlockLengthOption().


The documentation for this struct was generated from the following files: