Skip to content

Commit

Permalink
Fix yabridge_version() in chainloaders
Browse files Browse the repository at this point in the history
The function doesn't (and cannot) have the same name as the function
pointer, so `MAYBE_LOAD_FUNCTION()` does the wrong thing here. May as
well just do it manually.
  • Loading branch information
robbert-vdh committed Dec 10, 2023
1 parent f1a7ad4 commit cb6a1dd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
22 changes: 11 additions & 11 deletions src/chainloader/clap-chainloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,27 @@ bool initialize_library() {
return false;
}

#define MAYBE_LOAD_FUNCTION(name) \
#define LOAD_FUNCTION(name) \
do { \
(name) = \
reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \
} while (false)
#define LOAD_FUNCTION(name) \
do { \
MAYBE_LOAD_FUNCTION(name); \
if (!(name)) { \
log_failing_dlsym(yabridge_clap_plugin_name, #name); \
return false; \
} \
if (!(name)) { \
log_failing_dlsym(yabridge_clap_plugin_name, #name); \
return false; \
} \
} while (false)

LOAD_FUNCTION(yabridge_module_init);
LOAD_FUNCTION(yabridge_module_free);
LOAD_FUNCTION(yabridge_module_get_factory);
MAYBE_LOAD_FUNCTION(remote_yabridge_version);

// This one can be a null pointer if the function does not yet exist in this
// yabridge version
remote_yabridge_version =
reinterpret_cast<decltype(remote_yabridge_version)>(
dlsym(library_handle, "yabridge_version"));

#undef LOAD_FUNCTION
#undef MAYBE_LOAD_FUNCTION

return true;
}
Expand Down
22 changes: 11 additions & 11 deletions src/chainloader/vst2-chainloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ bool initialize_library() {
return false;
}

#define MAYBE_LOAD_FUNCTION(name) \
#define LOAD_FUNCTION(name) \
do { \
(name) = \
reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \
} while (false)
#define LOAD_FUNCTION(name) \
do { \
MAYBE_LOAD_FUNCTION(name); \
if (!(name)) { \
log_failing_dlsym(yabridge_vst2_plugin_name, #name); \
return false; \
} \
if (!(name)) { \
log_failing_dlsym(yabridge_vst2_plugin_name, #name); \
return false; \
} \
} while (false)

LOAD_FUNCTION(yabridge_plugin_init);
MAYBE_LOAD_FUNCTION(remote_yabridge_version);

// This one can be a null pointer if the function does not yet exist in this
// yabridge version
remote_yabridge_version =
reinterpret_cast<decltype(remote_yabridge_version)>(
dlsym(library_handle, "yabridge_version"));

#undef LOAD_FUNCTION
#undef MAYBE_LOAD_FUNCTION

return true;
}
Expand Down
22 changes: 11 additions & 11 deletions src/chainloader/vst3-chainloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,27 @@ bool initialize_library() {
return false;
}

#define MAYBE_LOAD_FUNCTION(name) \
#define LOAD_FUNCTION(name) \
do { \
(name) = \
reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \
} while (false)
#define LOAD_FUNCTION(name) \
do { \
MAYBE_LOAD_FUNCTION(name); \
if (!(name)) { \
log_failing_dlsym(yabridge_vst3_plugin_name, #name); \
return false; \
} \
if (!(name)) { \
log_failing_dlsym(yabridge_vst3_plugin_name, #name); \
return false; \
} \
} while (false)

LOAD_FUNCTION(yabridge_module_init);
LOAD_FUNCTION(yabridge_module_free);
LOAD_FUNCTION(yabridge_module_get_plugin_factory);
MAYBE_LOAD_FUNCTION(remote_yabridge_version);

// This one can be a null pointer if the function does not yet exist in this
// yabridge version
remote_yabridge_version =
reinterpret_cast<decltype(remote_yabridge_version)>(
dlsym(library_handle, "yabridge_version"));

#undef LOAD_FUNCTION
#undef MAYBE_LOAD_FUNCTION

return true;
}
Expand Down

0 comments on commit cb6a1dd

Please sign in to comment.