fix: cover some device selection edge cases #1604
Merged
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.
This PR fixes some edge cases around device selection:
Selecting the
default
deviceChrome allows requesting user media with device id
default
. For the purposes of the SDK, we treat this device as if it didn't existed, and filter it out of device lists. However, it was still possible to select it manually.Now device id
default
is filtered out of media requests, so even if it is selected manually, it is replaced with an actual device id when device is unmuted.Selecting non-existing device id
Previously, selecting non-existing device (e.g.
call.camera.select('nonsense')
) resulted in the default device being selected. That could be a nasty surprise for a user.Now, either
select
method will throw (if device is already unmuted) or enabling the device will throw later.This takes us to the final change:
Error handler for device selectors
onError
callback added to audio and video device selectors, sinceselect
method can now throw in a rare case that the device list is stale.