-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdescriptor.cpp
More file actions
58 lines (49 loc) · 1.06 KB
/
descriptor.cpp
File metadata and controls
58 lines (49 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "descriptor.h"
#include <vector>
namespace {
std::vector<descriptor> *descriptors;
}
/*
* descriptor
*/
descriptor::descriptor(const LADSPA_Descriptor &d, std::string &&label,
std::string &&name)
: d_{d}, label_{std::move(label)}, name_{std::move(name)}
{
d_.Label = label_.c_str();
d_.Name = name_.c_str();
}
descriptor::descriptor(descriptor &&o)
: d_{o.d_}, label_{std::move(o.label_)}, name_{std::move(o.name_)}
{
d_.Label = label_.c_str();
d_.Name = name_.c_str();
}
const LADSPA_Descriptor *
descriptor::get()
{
return &d_;
}
/*
* register_plugin
*/
void
register_plugin(descriptor &&d)
{
/* this is slightly ugly but necessary as the initialisation order of
* global objects is undefined between translation units */
static std::vector<descriptor> desc;
desc.emplace_back(std::move(d));
descriptors = &desc;
}
/*
* ladspa_descriptor
*/
__attribute__((externally_visible))
const LADSPA_Descriptor *
ladspa_descriptor(unsigned long i)
{
if (descriptors && i >= size(*descriptors))
return nullptr;
return (*descriptors)[i].get();
}