Protect against NumberOfEnumeratedDevices and Get[In|Out]putDeviceNames returning inconsistent results.
It's possible for an device to be counted but getting its name fails, in which case the utility function returns true but would continue from its loop filling the AudioDeviceNames vector, leading to a smaller output than the later code expects. No-Try: True Bug: b/144729866 Change-Id: If902cada4ef2911bc24fbec0f169da75ff6e6a83 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160020 Commit-Queue: Henrik Andreassson <henrika@webrtc.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29840}
This commit is contained in:
parent
4dd56a3830
commit
83b286202b
@ -282,7 +282,7 @@ int CoreAudioBase::DeviceName(int index,
|
||||
AudioDeviceNames device_names;
|
||||
bool ok = IsInput() ? core_audio_utility::GetInputDeviceNames(&device_names)
|
||||
: core_audio_utility::GetOutputDeviceNames(&device_names);
|
||||
if (!ok) {
|
||||
if (!ok || static_cast<int>(device_names.size()) <= index) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to get the device name";
|
||||
return -1;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user