-
-
Notifications
You must be signed in to change notification settings - Fork 36
Dynamically load JACK. #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/client/callbacks.rs
Outdated
j::jack_set_buffer_size_callback(client, Some(buffer_size::<N, P>), data_ptr); | ||
j::jack_set_sample_rate_callback(client, Some(sample_rate::<N, P>), data_ptr); | ||
j::jack_set_client_registration_callback( | ||
(LIB.jack_set_thread_init_callback)(client, Some(thread_init_callback::<N, P>), data_ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this. The dlib documentation says you need to use the ffi_dispatch!
macro for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't really need it. I could update all the callers to enable static and dynamic dispatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full disclosure: I couldn't get the macro to work.
Other thing the dlib
library seemed not to work well is specifying both statics and functions in the same external_library!
definition. Even the README's example does not compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not being able to link directly defeats the purpose of using dlopen instead of using libloading directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed ffi_dispatch!
. The issues I ran into were lack of support for trailing commas and no support for functions that don't have any arguments. The latter cases were handled manually, luckily there were only a couple of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for taking care of that. I suggest reporting those issues upstream.
Two big issues with this branch currently:
|
Updated to:
|
jack-sys/src/lib.rs
Outdated
pub const JACK_LIB: &'static str = "libjack.dll"; | ||
|
||
#[cfg(not(windows))] | ||
pub const JACK_LIB: &'static str = "libjack.so.0\0"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On macOS, it is libjack.0.dylib
: https://github.com/jackaudio/jack2/blob/852ba2b8ebc944865e75d8eb5d4550d408772f3b/common/JackWeakAPI.c#L50
This is working on Fedora 35 now. Using
Without
|
I made a PR to fix the platform-specific library names: #164. It is working on Linux. I will test it on macOS and Windows. |
* jack-sys: fix platform-specific dynamic library names * jack-sys: do not use pkg-config with dlopen feature If there happens to be a pkgconfig file but no libjack, downstream applications may fail to link.
I tested #164 on macOS (x86-64) and Windows (x86-64 in QEMU-KVM). macOS is definitely working with and without the So I think this is ready to merge! |
Yaaaay! I'll make a PR to document the new behavior. |
I got cross compiling to x86_64-pc-windows-gnu, x86_64-apple-darwin, and aarch64-apple-darwin from x86-64 Linux working! For macOS I had to use osxcross following this guide. So now it's possible to build cross platform JACK applications from Linux without even needing to build or link C! 🚀 |
Resolves #159