-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlv2_ext.cpp
More file actions
95 lines (81 loc) · 2.77 KB
/
lv2_ext.cpp
File metadata and controls
95 lines (81 loc) · 2.77 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
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
//
// Created by djshaji on 5/3/24.
//
#include "lv2_ext.h"
int lv2_urid_map (URID * handle, const char * string) {
IN
auto f = std::find(handle->urids.begin(), handle->urids.end(),std::string (string)) ;
if (f == handle->urids.end ()) {
handle->urids.push_back(std::string(string));
OUT
return handle->urids.size();
} else {
OUT
return std::distance(handle->urids.begin(), f) + 1 ;
}
}
void lv2_urid_unmap (URID * handle, int at) {
handle -> urids.erase(std::next(handle -> urids.begin(), at));
}
//int logger_printf (LV2_Log_Handle handle, LV2_URID type, const char* fmt, va_list ap) {
// return LOGD(fmt, ap);
//}
LV2_State_Status
store_callback(LV2_State_Handle handle,
std::basic_string<char> key,
const void* value,
size_t size,
uint32_t type,
uint32_t flags)
{
if ((flags & LV2_STATE_IS_POD)) {
// We only care about POD since we're keeping state in memory only.
// Disk or network use would also require LV2_STATE_IS_PORTABLE.
std::map<std::string, std::string> state_map ;
state_map [key] = std::string ((char *) value);
return LV2_STATE_SUCCESS;;
} else {
return LV2_STATE_ERR_BAD_FLAGS; // Non-POD events are unsupported
}
}
const void* retrieve_callback (LV2_State_Handle handle,
uint32_t key,
size_t* size,
uint32_t* type,
uint32_t* flags) {
return nullptr;
}
int logger_vprintf(LV2_Log_Handle handle,
LV2_URID type,
const char* fmt,
va_list ap) {
LOGD(fmt, ap);
return 0 ;
}
int logger_printf(LV2_Log_Handle handle, LV2_URID type, const char *fmt, ...) {
return 0;
}
LV2_URID ampMap_map (LV2_URID_Map_Handle handle, const char* uri) {
IN
std::vector <std::string> * v = static_cast<std::vector<std::string> *>(handle);
auto i = std::find(v->begin(), v->end(),std::string (uri)) ;
if (i == v->end ()) {
v->push_back(std::string (uri));
LOGD ("[map] %s -> %d", uri, v->size() + 1);
OUT
return v->size() + 1;
} else {
OUT
LOGD ("[map] %s -> %d", uri, std::distance(v->begin(), i) + 2 );
return std::distance(v->begin(), i) + 2 ;
}
}
LV2_URID_Map * ampMap_new () {
IN
LV2_URID_Map * ampMap = (LV2_URID_Map *) malloc (sizeof (LV2_URID_Map)) ;
// ampMap->handle = new std::vector <std::string> ();
// ampMap->handle = symap_new();
ampMap->map = reinterpret_cast<LV2_URID (*)(LV2_URID_Map_Handle, const char *)>(symap_map);
return ampMap;
OUT
}