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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
use lv2_raw::*;
type LV2_Handle = LV2Handle;
type LV2_Descriptor = LV2Descriptor;
#[inline(always)]
pub unsafe fn lilv_instance_get_uri(
instance: *const crate::LilvInstance,
) -> *const std::os::raw::c_char {
instance
.as_ref()
.iter()
.flat_map(|i| i.lv2_descriptor.as_ref())
.map(|d| d.uri)
.next()
.unwrap_or(std::ptr::null())
}
#[inline(always)]
pub unsafe fn lilv_instance_connect_port(
instance: *mut crate::LilvInstance,
port_index: u32,
data_location: *mut ::std::os::raw::c_void,
) {
if let Some(instance) = instance.as_mut() {
if let Some(descriptor) = instance.lv2_descriptor.as_ref() {
(descriptor.connect_port)(instance.lv2_handle, port_index, data_location);
}
}
}
pub unsafe fn lilv_instance_activate(instance: *const crate::LilvInstance) {
if let Some(instance) = instance.as_ref() {
if let Some(descriptor) = instance.lv2_descriptor.as_ref() {
if let Some(activate_fn) = descriptor.activate {
(activate_fn)(instance.lv2_handle);
}
}
}
}
#[inline(always)]
pub unsafe fn lilv_instance_run(instance: *const crate::LilvInstance, sample_count: u32) {
if let Some(instance) = instance.as_ref() {
if let Some(descriptor) = instance.lv2_descriptor.as_ref() {
(descriptor.run)(instance.lv2_handle, sample_count);
}
}
}
#[inline(always)]
pub unsafe fn lilv_instance_deactivate(instance: *mut crate::LilvInstance) {
if let Some(instance) = instance.as_ref() {
if let Some(descriptor) = instance.lv2_descriptor.as_ref() {
if let Some(deactivate_fn) = descriptor.deactivate {
(deactivate_fn)(instance.lv2_handle);
}
}
}
}
#[inline(always)]
pub unsafe fn lilv_instance_get_extension_data(
instance: *mut crate::LilvInstance,
uri: *const u8,
) -> *const ::std::os::raw::c_void {
if let Some(instance) = instance.as_ref() {
if let Some(descriptor) = instance.lv2_descriptor.as_ref() {
return (descriptor.extension_data)(uri);
}
};
std::ptr::null()
}
#[inline(always)]
pub unsafe fn lilv_instance_get_descriptor(
instance: *const crate::LilvInstance,
) -> *const LV2_Descriptor {
instance
.as_ref()
.map(|i| i.lv2_descriptor)
.unwrap_or(::std::ptr::null())
}
#[inline(always)]
pub unsafe fn lilv_instance_get_handle(instance: *const crate::LilvInstance) -> LV2_Handle {
instance
.as_ref()
.map(|i| i.lv2_handle)
.unwrap_or(::std::ptr::null_mut())
}