diff --git a/app/ui.js b/app/ui.js index f45a1635..3ecaf7a1 100644 --- a/app/ui.js +++ b/app/ui.js @@ -189,6 +189,7 @@ const UI = { UI.initSetting('repeaterID', ''); UI.initSetting('reconnect', false); UI.initSetting('reconnect_delay', 5000); + UI.initSetting('enable_audio', true); }, // Adds a link to the label elements on the corresponding input elements setupSettingLabels() { @@ -385,6 +386,8 @@ const UI = { UI.addSettingChangeHandler('logging', UI.updateLogging); UI.addSettingChangeHandler('reconnect'); UI.addSettingChangeHandler('reconnect_delay'); + UI.addSettingChangeHandler('enable_audio'); + UI.addSettingChangeHandler('enable_audio', UI.updateEnableAudio); }, addFullscreenHandlers() { @@ -898,6 +901,7 @@ const UI = { UI.updateSetting('logging'); UI.updateSetting('reconnect'); UI.updateSetting('reconnect_delay'); + UI.updateSetting('enable_audio'); document.getElementById('noVNC_settings') .classList.add("noVNC_open"); @@ -1109,6 +1113,8 @@ const UI = { UI.rfb.showDotCursor = UI.getSetting('show_dot'); UI.updateViewOnly(); // requires UI.rfb + UI.updateEnableAudio(); // requires UI.rfb + }, disconnect() { @@ -1801,6 +1807,11 @@ const UI = { selectbox.options.add(optn); }, + updateEnableAudio() { + if (!UI.rfb) return; + UI.rfb.enable_audio(UI.getSetting('enable_audio')); + }, + /* ------^------- * /MISC * ============== diff --git a/core/rfb.js b/core/rfb.js index 561bc4a7..4f5a51d2 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -156,6 +156,7 @@ export default class RFB extends EventTargetMixin { this._qemuAudioSupported = false; this._page_had_user_interaction = false; + this._audio_enable = false; this._audio_next_start = 0; this._audio_sample_rate = 44100; this._audio_channels = 2; @@ -2787,7 +2788,7 @@ export default class RFB extends EventTargetMixin { } } - if (this._page_had_user_interaction) { + if (this._page_had_user_interaction && this._audio_enable) { let ctime = this._audio_context.currentTime; if (ctime > this._audio_next_start) { this._audio_next_start = ctime; @@ -2806,6 +2807,19 @@ export default class RFB extends EventTargetMixin { return true; } + enable_audio(value) { + if (this._audio_enable !== value) { + this._audio_enable = value; + if (this._qemuAudioSupported) { + if (this._audio_enable) { + RFB.messages.enableQemuAudioUpdates(this._sock, this._audio_channels, this._audio_sample_rate); + } else { + RFB.messages.disableQemuAudioUpdates(this._sock); + } + } + } + } + allow_audio() { this._page_had_user_interaction = true; } @@ -3419,6 +3433,14 @@ RFB.messages = { sock.flush(); }, + disableQemuAudioUpdates(sock, channels, sample_rate) { + sock.sQpush8(255); // msg-type + sock.sQpush8(1); // submessage-type + sock.sQpush16(1); // disable audio + + sock.flush(); + }, + enableQemuAudioUpdates(sock, channels, sample_rate) { sock.sQpush8(255); // msg-type diff --git a/vnc.html b/vnc.html index 82cacd58..f6cab3f9 100644 --- a/vnc.html +++ b/vnc.html @@ -219,6 +219,13 @@ View only +