Comments (4)
I was finally able to work on this again, and it turns out that Arc<Destination>
works just fine
from coremidi.
@Boddlnagg that integer is an opaque handler to a CoreMIDI resource, if we clone it, then, there would be two owners for the same object, which violates the rules from the borrow checker.
Could you use an Arc<Destination>
?
I think I am doing something similar here:
- https://github.com/chris-zen/hero-studio/blob/master/app-native/src/midi/coremidi.rs#L81
- https://github.com/chris-zen/hero-studio/blob/master/app-native/src/midi/coremidi.rs#L117
The alternative would be to use certain features from the CoreMIDI API to retrieve the object unique id, and use it to create a new Destination instance (but this is not fully supported by the rust coremidi lib yet, although you could add the exports yourself).
from coremidi.
Yes, looking at the definition of Destination
, cloning would need to clone all the way down to the underlying Object
. And I thought it might be possible, because there's no Drop
implementation. So technically the ownership semantics is not encoded in the type (this is somewhat related to #8), but I do understand that this would be a little un-Rust-y. So it's totally okay if you don't want to go that route.
However, thank you for the hint towards Arc<Destination>
, I think that should actually work, and if it doesn't, I will use MIDIObjectFindByUniqueID
(I can add the export myself, but it would still be nice if you could add something like Destination::from_unique_id
, although I don't know whether that would need to be unsafe
because you don't know from a unique ID if it actually refers to the right kind of object, right?).
from coremidi.
Please try Arc<Destination>
and if it doesn't work for you, we can talk about Destination::from_unique_id
. This was in my mind before, but not as a priority thing.
About the unique id not existing anymore I guess this shouldn't be a problem as the factory method could return a Result
.
from coremidi.
Related Issues (16)
- Client is not Send HOT 9
- Notifications callback not called when devices are added or removed
- SIGILL in Tests on macOS 10.14
- Serious safety problems with callbacks HOT 1
- CoreFoundation objects over-released in Properties
- Undefined Behavior in `Client` and `Properties`
- Use the block crate and functions that take blocks instead of boxing callbacks. HOT 4
- Client::new() returns error -50 after 6 calls HOT 1
- Is Human Readable midi data support HOT 1
- Issue receiving midi packets when using CoreMIDI with Tauri HOT 5
- MIDIClientDispose causes trouble on iOS HOT 1
- Handle MIDIGetDestination/MIDIGetSource failure
- Report a vulnerability in chris-zen/coremidi HOT 2
- Why not use MIDIPacketListAdd? HOT 5
- Client can be dropped while port is open 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 coremidi.