[lib.audio-manager] fixed buffer read (send() ScriptProcessor) + receive() only pushes to stack

This commit is contained in:
xdrm-brackets 2018-04-09 19:11:00 +02:00
parent f7d6e530b4
commit a06e9c1789
1 changed files with 6 additions and 21 deletions

View File

@ -260,6 +260,10 @@ export default class AudioManager{
/* (5) Send buffer through websocket */ /* (5) Send buffer through websocket */
this.ws.send(buf16); this.ws.send(buf16);
/* (6) Read input buffer */
this.stack.shift().start(this.ctx.currentTime);
// DEBUG // DEBUG
this.dbg.data.packets_sent++; this.dbg.data.packets_sent++;
@ -291,27 +295,8 @@ export default class AudioManager{
source.connect(gain); source.connect(gain);
gain.connect(this.master); gain.connect(this.master);
/* (7) If not empty stack -> play stack */ /* (7) Push in buffer stack */
if( this.stack.length > this.stack_save ){ this.stack.push(source);
this.stack.shift().start(this.ctx.currentTime);
return this.stack.push(source);
}
/* (8) If empty stack -> play + chain */
// chain stack
source.onended = function(){
this.dbg.data.packets_received++;
this.dbg.data.kB_received += _buffer.length * 16. / 8 / 1024;
if( this.stack.length > this.stack_save )
this.stack.shift().start(this.ctx.curentTime);
}.bind(this);
// push in stack
source.start(this.ctx.currentTime);
} }