Skip to content

return DeviceNotFound when device is not there for set_recording_devi…#1155

Merged
xianshijing-lk merged 4 commits into
mainfrom
sxian/CLT-3006/return-devicenotfound-error-for-set-recording-device-set-playout
Jun 15, 2026
Merged

return DeviceNotFound when device is not there for set_recording_devi…#1155
xianshijing-lk merged 4 commits into
mainfrom
sxian/CLT-3006/return-devicenotfound-error-for-set-recording-device-set-playout

Conversation

@xianshijing-lk

Copy link
Copy Markdown
Contributor

…ce() / set_playout_device()

Before you submit your PR

Make sure the following is true before submitting your PR:

  • I have read the contributing guidelines and validated that this PR will be accepted.
  • I have read and followed the principles regarding breaking changes, testing, and code quality.

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

@xianshijing-lk xianshijing-lk requested a review from ladvoc as a code owner June 10, 2026 06:41
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Changeset

The following package versions will be affected by this PR:

Package Bump
livekit patch
livekit-ffi patch

@jhugman jhugman self-requested a review June 10, 2026 13:35

@jhugman jhugman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ with a couple of questions for my understanding.

Comment thread livekit/src/platform_audio/mod.rs Outdated
Comment on lines +726 to +729
#[cfg(not(any(target_os = "ios", target_os = "android")))]
if !self.playout_devices().any(|d| &d.id == id) {
return Err(AudioError::DeviceNotFound);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread livekit/src/platform_audio/mod.rs Outdated
Comment on lines +678 to +681
#[cfg(not(any(target_os = "ios", target_os = "android")))]
if !self.recording_devices().any(|d| &d.id == id) {
return Err(AudioError::DeviceNotFound);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be called from anywhere else, e.g. switch_recording_device()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@xianshijing-lk xianshijing-lk merged commit 283f6d8 into main Jun 15, 2026
22 checks passed
@xianshijing-lk xianshijing-lk deleted the sxian/CLT-3006/return-devicenotfound-error-for-set-recording-device-set-playout branch June 15, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants