From bb63b6304e350b55da47e1cc705ce3831ffcde1f Mon Sep 17 00:00:00 2001 From: Stefan Otto Date: Wed, 20 May 2020 14:25:13 +0200 Subject: [PATCH] Fix autoMuteThreshold bug #394 --- app/public/config/config.example.js | 3 ++- app/src/RoomClient.js | 10 ++++--- app/src/localAudioAnalyzer.js | 42 +++++++++++++++++++++++++++++ app/src/reducers/settings.js | 1 - 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 app/src/localAudioAnalyzer.js diff --git a/app/public/config/config.example.js b/app/public/config/config.example.js index 7cbd401..84ed59e 100644 --- a/app/public/config/config.example.js +++ b/app/public/config/config.example.js @@ -89,7 +89,8 @@ var config = * unmuted. Next participant will join automatically muted * Default value is 4 * - * Set it to 0 to disable auto mute functionality, + * Set it to 0 to auto mute all, + * Set it to negative (-1) to never automatically auto mute * but use it with caution * full mesh audio strongly decrease room capacity! */ diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index 52ced0c..6a2d16c 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -3045,9 +3045,13 @@ export default class RoomClient if (!this._muted) { await this.enableMic(); - const { autoMuteThreshold } = store.getState().settings; - - if (autoMuteThreshold && peers.length > autoMuteThreshold) + let autoMuteThreshold = 4; + + if ('autoMuteThreshold' in window.config) + { + autoMuteThreshold = window.config.autoMuteThreshold; + } + if (autoMuteThreshold && peers.length >= autoMuteThreshold) this.muteMic(); } diff --git a/app/src/localAudioAnalyzer.js b/app/src/localAudioAnalyzer.js new file mode 100644 index 0000000..4f387c6 --- /dev/null +++ b/app/src/localAudioAnalyzer.js @@ -0,0 +1,42 @@ + + +class AudioAnalyzer extends EventEmitter + +{ + constructor() + { + if (prefix) + { + this._debug = debug(`${APP_NAME}:${prefix}`); + this._warn = debug(`${APP_NAME}:WARN:${prefix}`); + this._error = debug(`${APP_NAME}:ERROR:${prefix}`); + } + else + { + this._debug = debug(APP_NAME); + this._warn = debug(`${APP_NAME}:WARN`); + this._error = debug(`${APP_NAME}:ERROR`); + } + + /* eslint-disable no-console */ + this._debug.log = console.info.bind(console); + this._warn.log = console.warn.bind(console); + this._error.log = console.error.bind(console); + /* eslint-enable no-console */ + } + + get debug() + { + return this._debug; + } + + get warn() + { + return this._warn; + } + + get error() + { + return this._error; + } +} diff --git a/app/src/reducers/settings.js b/app/src/reducers/settings.js index 051b642..fcd80d4 100644 --- a/app/src/reducers/settings.js +++ b/app/src/reducers/settings.js @@ -22,7 +22,6 @@ const initialState = notificationSounds : true, buttonControlBar : window.config.buttonControlBar || false, drawerOverlayed : window.config.drawerOverlayed || true, - autoMuteThreshold : window.config.autoMuteThreshold || 4, ...window.config.defaultAudio };