From 7d767343d68c243ee40ffc5c5b34762f11dac0a2 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 9 Apr 2018 19:21:26 +0200 Subject: [PATCH] [lib.audio-manager] added stack max size --- parcel/lib/audio-manager.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/parcel/lib/audio-manager.js b/parcel/lib/audio-manager.js index 6641799..4f212f7 100644 --- a/parcel/lib/audio-manager.js +++ b/parcel/lib/audio-manager.js @@ -60,7 +60,7 @@ export default class AudioManager{ /* (7) Initialise coordinator to manage received */ this.stack = []; - this.stack_save = 0; + this.stack_size = 10; @@ -261,7 +261,11 @@ export default class AudioManager{ this.ws.send(buf16); /* (6) Read input buffer */ - this.stack.shift().start(this.ctx.currentTime); + this.stack.length > 0 && this.stack.shift().start(this.ctx.currentTime); + + /* (7) Pop stack if exceeded */ + this.stack.length > this.stack_size && this.stack.pop(); +