return DeviceNotFound when device is not there for set_recording_devi…#1155
Conversation
…ce() / set_playout_device()
ChangesetThe following package versions will be affected by this PR:
|
jhugman
left a comment
There was a problem hiding this comment.
✅ with a couple of questions for my understanding.
| #[cfg(not(any(target_os = "ios", target_os = "android")))] | ||
| if !self.playout_devices().any(|d| &d.id == id) { | ||
| return Err(AudioError::DeviceNotFound); | ||
| } |
There was a problem hiding this comment.
This looks fine, from a Rust POV. I might suggest a helper method that shares the logic with the above, but this is minor.
Does similar logic need to exist in the switch_playout_device() function too?
There was a problem hiding this comment.
Good idea, I can make a helper function.
No, this logic is not needed by switch_playout_device() function, Claude added it there, and I intentionally removed it since I want switch_playout_device() to silently fall back to the default device.
| #[cfg(not(any(target_os = "ios", target_os = "android")))] | ||
| if !self.recording_devices().any(|d| &d.id == id) { | ||
| return Err(AudioError::DeviceNotFound); | ||
| } |
There was a problem hiding this comment.
Does this need to be called from anywhere else, e.g. switch_recording_device()?
There was a problem hiding this comment.
I intentionally removed those calls from witch_recording_device() to avoid causing it to fail unnecessarily. witch_recording_device() is invoked when devices are unplugged, and in those cases it will silently fall back to the default device.
…ce() / set_playout_device()
Before you submit your PR
Make sure the following is true before submitting your PR:
PR description
Return return DeviceNotFound when device is not there for set_recording_device() and set_playout_device()
Otherwise, the API will behave differently on different platforms.
Breaking changes
If this PR introduces breaking changes, list them here and document the rationale for introducing such a change.
MSRV
N/A
Testing
CI
Async
N/A