From e455c70e365c1a2f735dc89f5f7a6633d0d477e7 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sun, 26 Jun 2022 20:53:47 -0400 Subject: [PATCH] Merge pull request #3722 from nyanmisaka/fix-audio-ch (cherry picked from commit 0e0dd46c1b19b43c2ff8b703fe9be6fb4769b5ae) Signed-off-by: Bill Thornton --- src/scripts/browserDeviceProfile.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index a022c96b04..18892ae3ea 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -312,7 +312,7 @@ import browser from './browser'; return -1; } - function getPhysicalAudioChannels(options) { + function getPhysicalAudioChannels(options, videoTestElement) { const allowedAudioChannels = parseInt(userSettings.allowedAudioChannels(), 10); if (allowedAudioChannels > 0) { @@ -324,8 +324,14 @@ import browser from './browser'; } const isSurroundSoundSupportedBrowser = browser.safari || browser.chrome || browser.edgeChromium || browser.firefox || browser.tv || browser.ps4 || browser.xboxOne; + const isAc3Eac3Supported = supportsAc3(videoTestElement) || supportsEac3(videoTestElement); const speakerCount = getSpeakerCount(); + // AC3/EAC3 hinted that device is able to play dolby surround sound. + if (isAc3Eac3Supported && isSurroundSoundSupportedBrowser) { + return speakerCount > 6 ? speakerCount : 6; + } + if (speakerCount > 2) { if (isSurroundSoundSupportedBrowser) { return speakerCount; @@ -348,12 +354,12 @@ import browser from './browser'; export default function (options) { options = options || {}; - const physicalAudioChannels = getPhysicalAudioChannels(options); - const bitrateSetting = getMaxBitrate(); const videoTestElement = document.createElement('video'); + const physicalAudioChannels = getPhysicalAudioChannels(options, videoTestElement); + const canPlayVp8 = videoTestElement.canPlayType('video/webm; codecs="vp8"').replace(/no/, ''); const canPlayVp9 = videoTestElement.canPlayType('video/webm; codecs="vp9"').replace(/no/, ''); const webmAudioCodecs = ['vorbis'];