diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 8eddeb6ba8..a98f72e612 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -283,16 +283,24 @@ import browser from './browser'; return bitrate; } + let maxChannelCount = null; + function getSpeakerCount() { + if (maxChannelCount != null) { + return maxChannelCount; + } + + maxChannelCount = -1; + const AudioContext = window.AudioContext || window.webkitAudioContext || false; /* eslint-disable-line compat/compat */ if (AudioContext) { const audioCtx = new AudioContext(); - return audioCtx.destination.maxChannelCount; + maxChannelCount = audioCtx.destination.maxChannelCount; } - return -1; + return maxChannelCount; } function getPhysicalAudioChannels(options, videoTestElement) {