|
59 | 59 |
|
60 | 60 | #include "pdlua_gfx.h" |
61 | 61 |
|
62 | | -typedef void (*t_signal_setmultiout)(t_signal **, int); |
63 | | -static t_signal_setmultiout g_signal_setmultiout; |
| 62 | +// function pointer type for signal_setmultiout (added with Pd 0.54) |
| 63 | +typedef void (*t_signal_setmultiout_fn)(t_signal **, int); |
| 64 | +static t_signal_setmultiout_fn g_signal_setmultiout; |
| 65 | + |
| 66 | +// function pointer type for glist_getrtext/glist_findrtext (changes with Pd 0.56) |
| 67 | +typedef t_rtext *(*t_glist_rtext_fn)(t_glist *, t_text *); |
| 68 | +static t_glist_rtext_fn g_glist_getrtext; |
64 | 69 |
|
65 | 70 | // This used to be in s_stuff.h, but not anymore since 0.55.1test1. |
66 | 71 | int sys_trytoopenone(const char *dir, const char *name, const char* ext, |
@@ -1315,7 +1320,7 @@ static int pdlua_set_arguments(lua_State *L) |
1315 | 1320 | if (redraw) { |
1316 | 1321 | // update the text in the object box; this makes sure that |
1317 | 1322 | // the arguments in the display are what we just set |
1318 | | - t_rtext *y = glist_findrtext(o->canvas, x); |
| 1323 | + t_rtext *y = g_glist_getrtext(o->canvas, x); |
1319 | 1324 | rtext_retext(y); |
1320 | 1325 | // redraw the object and its iolets (including incident |
1321 | 1326 | // cord lines), in case the object box size has changed |
@@ -3042,23 +3047,38 @@ void pdlua_setup(void) |
3042 | 3047 | #endif |
3043 | 3048 | post(luaversionStr); |
3044 | 3049 |
|
3045 | | -// multichannel handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136 |
| 3050 | +// compatibility handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136 |
3046 | 3051 | #ifdef _WIN32 |
3047 | 3052 | // get a handle to the module containing the Pd API functions. |
3048 | 3053 | // NB: GetModuleHandle("pd.dll") does not cover all cases. |
3049 | 3054 | HMODULE module; |
3050 | 3055 | if (GetModuleHandleEx( |
3051 | 3056 | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, |
3052 | 3057 | (LPCSTR)&pd_typedmess, &module)) { |
3053 | | - g_signal_setmultiout = (t_signal_setmultiout)(void *)GetProcAddress( |
| 3058 | + g_signal_setmultiout = (t_signal_setmultiout_fn)(void *)GetProcAddress( |
3054 | 3059 | module, "signal_setmultiout"); |
| 3060 | + g_glist_getrtext = (t_glist_rtext_fn)(void *)GetProcAddress(module, "glist_getrtext"); |
| 3061 | + if (!g_glist_getrtext) |
| 3062 | + g_glist_getrtext = (t_glist_rtext_fn)(void *)GetProcAddress(module, "glist_findrtext"); |
3055 | 3063 | } |
3056 | 3064 | #else |
3057 | 3065 | // search recursively, starting from the main program |
3058 | | - g_signal_setmultiout = (t_signal_setmultiout)dlsym( |
| 3066 | + g_signal_setmultiout = (t_signal_setmultiout_fn)dlsym( |
3059 | 3067 | dlopen(NULL, RTLD_NOW), "signal_setmultiout"); |
| 3068 | + g_glist_getrtext = (t_glist_rtext_fn)dlsym( |
| 3069 | + dlopen(NULL, RTLD_NOW), "glist_getrtext"); |
| 3070 | + if (!g_glist_getrtext) |
| 3071 | + g_glist_getrtext = (t_glist_rtext_fn)dlsym( |
| 3072 | + dlopen(NULL, RTLD_NOW), "glist_findrtext"); |
3060 | 3073 | #endif |
3061 | 3074 |
|
| 3075 | + // check if g_glist_getrtext was loaded successfully |
| 3076 | + if (!g_glist_getrtext) { |
| 3077 | + pd_error(NULL, "pdlua: failed to load pd's glist_getrtext/glist_findrtext functions"); |
| 3078 | + pd_error(NULL, "pdlua: loader will not be registered!"); |
| 3079 | + return; |
| 3080 | + } |
| 3081 | + |
3062 | 3082 | pdlua_proxyinlet_setup(); |
3063 | 3083 | PDLUA_DEBUG("pdlua pdlua_proxyinlet_setup done", 0); |
3064 | 3084 | pdlua_proxyreceive_setup(); |
|
0 commit comments