fix: Handle out-of-range device index after GetDevicesInfo

When the specified device was not found in GetDevicesInfo,
SetPlayoutDevice/SetRecordingDevice will never return a (-1) error.

Bug: None
Change-Id: I9ac71cf72f7876c1c54ee593f184aa4007dba22f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/320500
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40768}
This commit is contained in:
Youfa 2023-09-17 16:23:31 +08:00 committed by WebRTC LUCI CQ
parent 2e7ed0d615
commit f8c70c9c34
2 changed files with 3 additions and 2 deletions

View file

@ -133,6 +133,7 @@ Xiaohong Xu <freemine@yeah.net>
Xiaolei Yu <dreifachstein@gmail.com> Xiaolei Yu <dreifachstein@gmail.com>
Xinchao Tian <tianxinchao@360.cn> Xinchao Tian <tianxinchao@360.cn>
Yaowen Guo <albertguo88@gmail.com> Yaowen Guo <albertguo88@gmail.com>
Youfa <vsyfar@gmail.com>
Yura Yaroshevich <yura.yaroshevich@gmail.com> Yura Yaroshevich <yura.yaroshevich@gmail.com>
Yuriy Pavlyshak <yuriy@appear.in> Yuriy Pavlyshak <yuriy@appear.in>
Yusuke Suzuki <utatane.tea@gmail.com> Yusuke Suzuki <utatane.tea@gmail.com>

View file

@ -588,7 +588,7 @@ int32_t AudioDeviceLinuxALSA::SetPlayoutDevice(uint16_t index) {
return -1; return -1;
} }
uint32_t nDevices = GetDevicesInfo(0, true); int32_t nDevices = GetDevicesInfo(0, true);
RTC_LOG(LS_VERBOSE) << "number of available audio output devices is " RTC_LOG(LS_VERBOSE) << "number of available audio output devices is "
<< nDevices; << nDevices;
@ -657,7 +657,7 @@ int32_t AudioDeviceLinuxALSA::SetRecordingDevice(uint16_t index) {
return -1; return -1;
} }
uint32_t nDevices = GetDevicesInfo(0, false); int32_t nDevices = GetDevicesInfo(0, false);
RTC_LOG(LS_VERBOSE) << "number of availiable audio input devices is " RTC_LOG(LS_VERBOSE) << "number of availiable audio input devices is "
<< nDevices; << nDevices;