From 0a389256eb2c38322063b23be8d3593dc9d70731 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 16 Oct 2016 19:40:03 +0000 Subject: [PATCH] mute audio when buffer is empty --- htdocs/openwebrx.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index ed170ce..38138a1 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1409,9 +1409,21 @@ if (!AudioBuffer.prototype.copyToChannel) function audio_onprocess(e) { //console.log("audio onprocess"); - if(audio_buffering) return; - if(audio_prepared_buffers.length==0) { audio_buffer_progressbar_update(); /*add_problem("audio underrun");*/ audio_buffering=true; } - else { e.outputBuffer.copyToChannel(audio_prepared_buffers.shift(),0); } + if(audio_buffering) { + var silence = new Float32Array(4096); + e.outputBuffer.copyToChannel(silence, 0); + return; + } + if(audio_prepared_buffers.length==0) { + audio_buffer_progressbar_update(); + /*add_problem("audio underrun");*/ + audio_buffering=true; + var silence = new Float32Array(4096); + e.outputBuffer.copyToChannel(silence, 0); + } else { + var buf = audio_prepared_buffers.shift(); + e.outputBuffer.copyToChannel(buf,0); + } } var audio_buffer_progressbar_update_disabled=false;