-
Notifications
You must be signed in to change notification settings - Fork 21
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
Client::new() returns error -50 after 6 calls #32
Comments
Hi @sourcebox, thanks for the report. I've been investigating it a bit. Apparently the With this code: impl Drop for Client {
fn drop(&mut self) {
println!("Dropping client ...");
let status = unsafe { MIDIClientDispose(self.object.0) };
println!("{}", status);
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test() {
let mut counter = 0;
loop {
let client = Client::new("test midi client");
counter += 1;
match client.as_ref() {
Ok(client) => {
println!("{}, {:?}", counter, client);
}
Err(error) => {
println!("{:?}", error);
break;
}
}
std::thread::sleep(std::time::Duration::from_millis(1000));
}
}
} I see this:
But reading the docs I just found a possible cause for the problem that it would be out of my control: https://developer.apple.com/documentation/coremidi/1495335-midiclientdispose#discussion
So apparently, clients are not supposed to be created and destroyed that frequently, but instead live for the whole lifecycle of your app. |
My application uses the midir crate that uses coremidi as a dependency. The original issue is tracked here Boddlnagg/midir#86
The reason for continously creating a client for scanning the ports because the cross-platform midir crate does not support change notifications yet.
While there is a workaround for the problem, it still would be nice to address the issue if possible. I would expect that the acquired client resource is closed at the end of each loop iteration as the variable goes out of scope.
Demo code:
The text was updated successfully, but these errors were encountered: