-
Notifications
You must be signed in to change notification settings - Fork 469
properly detect is_default in Device::new() for MacOS
#996
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
roderickvd
left a comment
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.
Good enhancement, or actually, fix.
If this device matches at least one device's ID, and no platform specific error occurred behind the scenes, we return true, otherwise we return false.
If we'd prefer to now return Result<Self, BackendSpecificError> I can implement this, though I didn't as I didn't have time. Just let me know if you'd prefer that, now that these errors can occur.
Yes, that'd be good.
Some further comments in the review. Particularly, we need to unify the default_output_device logic that's already in enumerate.rs.
|
Shoot! Hit "Close with commit." I'll see if I can get it back... Thanks for the help, that was really insightful. I fixed each remark you had, and made sure it still works on my machine. I rewrote the code I had, including the functions from Also, I did not change the return type to Let me know what you think, and I can update anything else you need. |
|
(Is this reopened now!?) |
|
Yes, it's reopened 😄 If you could resolve the merge conflict and look at Copilot's comments? I doubt the point about caching, but agree with that the helper function would be a cherry on top. |
|
I created the helper function, and gave my 2-cents on caching the default devices. Just let me know if there's anything else I should do! |
|
Having second thoughts about this This seems better because it:
Example race condition:
|
|
I like this idea. I wasn't 100% sure what you meant, so I interpreted it as removing I went back and replaced all instances of How does this sound? If I misinterpreted what you said, just let me know and I'll fix it! |
roderickvd
left a comment
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.
Yes! That is what I meant. Much cleaner - who thought something seemingly so simple would turn out into this conversation? 😄
If you could also run cargo fmt and add a CHANGELOG entry?
| use std::cell::RefCell; | ||
| use std::fmt; | ||
| use std::mem; | ||
| use std::ptr::{null, NonNull}; |
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.
Can you take a &Device here so we don't need to clone in audio_unit_from_device?
And I couldn't reproduce the issue with formatting. I'll check again in a moment.
|
I fixed the Also, I updated my rust edition to the latest version. Now, a warning appears. This is not related to my branch specifically, so I will leave it as is. If there's anything else you need, just let me know! |
|
Merged, thanks! |
I've introduced proper detection if a
Device::new()is actually default to the system.Previously, I hardcoded
is_defaultto be false, regardless of the device ID. Now, the function will gather both the default input and output device IDs, and compare them to this device. If this device matches at least one device's ID, and no platform specific error occurred behind the scenes, we return true, otherwise we return false.If we'd prefer to now return
Result<Self, BackendSpecificError>I can implement this, though I didn't as I didn't have time. Just let me know if you'd prefer that, now that these errors can occur.