From 7c9464d0c3b83248c1a751ebdb2297118f483589 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sun, 22 Jan 2023 14:08:03 -0500 Subject: [PATCH] Backport pull request #4267 from jellyfin/release-10.8.z Fix AudioContext limit exceeded Original-merge: ea79d2651aa8237a433086284940059c3bf30b92 Merged-by: Bill Thornton Backported-by: Joshua M. Boniface --- 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 8eddeb6ba..a98f72e61 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) {