Comments (7)
Thanks for filing the issue. I observed this on my system using libjack2.
I'm not sure what happens for libjack.
The crate's documentation says it should be called only once, but this was just copied from the JACK API Docs: http://jackaudio.org/files/docs/html/group__ClientCallbacks.html#gad5a6904292f5c9790223c18aeab202bf
I'm not sure what the proper behavior is, but the issue should be reported to the JACK developers.
from rust-jack.
Oh, wait, I think I got it.
One headliner feature of jack2, which I also use, is that it supports multiple audio processing threads. What I did not realize is that for process isolation reasons, it may actually need to spawn multiple audio threads per client in order to achieve this result.
If that is the issue, then it's just a matter of clarifying the thread_init_callback documentation.
EDIT: And indeed, on my machine, printing std::thread::current().id()
in the thread_init callback yields
Audio thread ThreadId(2) is ready.
Audio thread ThreadId(3) is ready.
Audio thread ThreadId(4) is ready.
from rust-jack.
Note that if there are multiple audio threads and they can work concurrently, some aspects of the jack-rs
API may need to change towards multi-thread-safety. For example, NotificationHandler
and ProcessHandler
would likely need to become Sync
.
from rust-jack.
Since JACK
can have many implementations (and has 2) we should follow the spec. Since the spec is not specific on this, we can't make guarantees about future implementations so its safer to require Sync
.
We should also update the example to use crossbeam::channel for communication since std channels are not Sync
on the receiver side.
from rust-jack.
Requiring Sync
is pretty bad, since it breaks all stateful process handlers (using Arc
is not an option because its spinlocks are not thread safe). Is it really possible to call the processing callback not only from different threads, but concurrently? If I understand https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_User_ClientThreads correctly, there are only 2 threads, one for notifications and one for processing (btw the link to the documentation above is broken)
from rust-jack.
using Arc is not an option because its spinlocks are not thread safe
Can you clarify what you mean by that ?
If I understand https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_User_ClientThreads correctly, there are only 2 threads, one for notifications and one for processing (btw the link to the documentation above is broken)
This is indeed consistent with one of the last footnotes at the end of this jack1 vs jack2 comparison, but not with the fact that my thread_init_callback was called from three different threads above. Not sure what to make of all this honestly, it would be great if a jack2 dev could clarify the situation here.
from rust-jack.
* using Arc is not an option because its blocking wait is not realtime thread safe
But never mind that, I just found out that Mutex
has a non-blocking try_lock
which works in a RT context.
from rust-jack.
Related Issues (20)
- better documentation for side effects of AsyncClient::drop HOT 2
- failure to link with pipewire-jack-audio-connection-kit-devel HOT 3
- Documentation missing HOT 5
- Loopback HOT 1
- Why is `Client`/`AsyncClient` not `Sync`? HOT 3
- ClosureProcessHandler API does not have a way to set a buffer_size callback HOT 3
- Client::connect_ports compiles if input and output ports are swapped
- dynamically load libjack at runtime instead of linking HOT 6
- Deactivating client causes a panic HOT 6
- Remove special treatment of jack_get_cycle_times HOT 1
- no Git tags for releases
- Support compile time linking. HOT 5
- Replace codegen in jack-sys/build.rs with macro
- Client::new() panics when JACK is not installed HOT 3
- Reporting latency
- aarch64 support? HOT 1
- local directories are leaked to binary
- Request capability to specify additional flags for AudioIn, AudioOut, MidiIn and MidiOut types
- Verbose/debug logging
- Who is maintaining this repo/crate? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-jack.