Skip to content

Commit

Permalink
Do not dispose the client on drop to avoid the CoreMIDI server to shu…
Browse files Browse the repository at this point in the history
…tdown in iOS
  • Loading branch information
chris-zen committed Jun 30, 2024
1 parent 3a9f51a commit 9279aa7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,15 @@ impl Deref for Client {
}
}

impl Drop for Client {
fn drop(&mut self) {
unsafe { MIDIClientDispose(self.object.0) };
}
}
// According to Apple docs:
//
// > Don’t explicitly dispose of your client; the system automatically disposes all clients when an app terminates.
// > However, if you call this method to dispose the last or only client owned by an app, the MIDI server may exit
// > if there are no other clients remaining in the system. If this occurs, all subsequent calls by your app to
// > MIDIClientCreate and MIDIClientCreateWithBlock fail.
//
// impl Drop for Client {
// fn drop(&mut self) {
// unsafe { MIDIClientDispose(self.object.0) };
// }
// }

0 comments on commit 9279aa7

Please sign in to comment.