-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cbdbfc5
properly detect `is_default`
wgibbs-rs 7e6ca1b
fix formatting issues
wgibbs-rs 5d7fcb2
fix requested changes
wgibbs-rs 4b2b638
Merge branch 'master' into is_default
wgibbs-rs 05fe95e
create helper function
wgibbs-rs e20b7b1
removed `is_default` from `Device` struct
wgibbs-rs 337516e
remove unnecessary clone operations
wgibbs-rs c55a6ce
Added changes to `CHANGELOG.md`
wgibbs-rs b3c6011
Merge branch 'master' into is_default
wgibbs-rs dc047ec
docs: lazy CoreAudio default device detection
roderickvd 6cccbc5
docs: keep newline between section header and next function
roderickvd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -159,18 +159,22 @@ impl DeviceTrait for Device { | |||||||||||||||||||||||||||||
| #[derive(Clone, PartialEq, Eq)] | ||||||||||||||||||||||||||||||
| pub struct Device { | ||||||||||||||||||||||||||||||
| pub(crate) audio_device_id: AudioDeviceID, | ||||||||||||||||||||||||||||||
| is_default: bool, | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| fn is_default_device(device: &Device) -> bool { | ||||||||||||||||||||||||||||||
| default_input_device() | ||||||||||||||||||||||||||||||
| .map(|d| d.audio_device_id == device.audio_device_id) | ||||||||||||||||||||||||||||||
| .unwrap_or(false) | ||||||||||||||||||||||||||||||
| || default_output_device() | ||||||||||||||||||||||||||||||
| .map(|d| d.audio_device_id == device.audio_device_id) | ||||||||||||||||||||||||||||||
| .unwrap_or(false) | ||||||||||||||||||||||||||||||
|
Comment on lines
+165
to
+170
|
||||||||||||||||||||||||||||||
| default_input_device() | |
| .map(|d| d.audio_device_id == device.audio_device_id) | |
| .unwrap_or(false) | |
| || default_output_device() | |
| .map(|d| d.audio_device_id == device.audio_device_id) | |
| .unwrap_or(false) | |
| if let Some(d) = default_input_device() { | |
| if d.audio_device_id == device.audio_device_id { | |
| return true; | |
| } | |
| } | |
| default_output_device() | |
| .map(|d| d.audio_device_id == device.audio_device_id) | |
| .unwrap_or(false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
is_default_device()function calls system APIs on every invocation. Consider caching the result or accepting that this function may be called frequently during stream operations, which could impact performance.