changeset 2508:9b536838a962

Potential patch for #154
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 18 Oct 2016 10:33:17 +0100
parents ae445d57687a
children 04498bccfccf 8536e978ab6f 249a1152e525
files js/core.js
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Thu Oct 13 12:04:06 2016 +0100
+++ b/js/core.js	Tue Oct 18 10:33:17 2016 +0100
@@ -1361,7 +1361,7 @@
     // because web audio will optimise and any route which does not go to the destination gets ignored.
     this.outputGain = audioContext.createGain();
     this.fooGain = audioContext.createGain();
-    this.fooGain.gain = 0;
+    this.fooGain.gain.value = 0;
 
     // Use this to detect playback state: 0 - stopped, 1 - playing
     this.status = 0;
@@ -1381,6 +1381,14 @@
 
     this.pageStore = null;
 
+    // Chrome 53+ Error solution
+    // Empty buffer for keep-alive
+    var nullBuffer = audioContext.createBuffer(1, audioContext.sampleRate, audioContext.sampleRate);
+    this.nullBufferSource = audioContext.createBufferSource();
+    this.nullBufferSource.buffer = nullBuffer;
+    this.nullBufferSource.loop = true;
+    this.nullBufferSource.start(0);
+
     // Create store for new audioObjects
     this.audioObjects = [];
 
@@ -1745,6 +1753,7 @@
 
     // Connect buffer to the audio graph
     this.outputGain.connect(audioEngineContext.outputGain);
+    audioEngineContext.nullBufferSource.connect(this.outputGain);
 
     // the audiobuffer is not designed for multi-start playback
     // When stopeed, the buffer node is deleted and recreated with the stored buffer.
@@ -1833,9 +1842,10 @@
                     event.currentTarget.owner.stop(audioContext.currentTime + 1);
                 }
             };
+            this.outputGain.gain.cancelScheduledValues(audioContext.currentTime);
             if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) {
                 this.metric.startListening(audioEngineContext.timer.getTestTime());
-                this.outputGain.gain.setValueAtTime(this.onplayGain, 0.0);
+                this.outputGain.gain.setValueAtTime(this.onplayGain, startTime);
                 this.interfaceDOM.startPlayback();
             } else {
                 this.outputGain.gain.setValueAtTime(0.0, startTime);