From 21cf0f5f8e31bbf51ae415be6cedb7f07ed793d8 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sat, 7 Jan 2023 02:10:48 +0300 Subject: [PATCH] fix AudioContext limit exceeded --- src/scripts/browserDeviceProfile.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 94248a2838..ebe4e2ef0e 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -294,16 +294,24 @@ import browser from './browser'; (browser.tizen && isTizenFhd ? 20000000 : null))); } + 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) {