From a41eba1dff5f8e95ccfe7d13575ca8a4f87a5b8f Mon Sep 17 00:00:00 2001 From: kkapsner Date: Thu, 21 Jun 2018 00:19:12 +0200 Subject: [PATCH] Notification should show up for every function. --- lib/modifiedAudioAPI.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/modifiedAudioAPI.js b/lib/modifiedAudioAPI.js index b3dadeb..75fd96f 100644 --- a/lib/modifiedAudioAPI.js +++ b/lib/modifiedAudioAPI.js @@ -86,11 +86,11 @@ return status; } - let notified = false; - function notifyOnce(notify){ - if (!notified){ + let notified = new Map(); + function notifyOnce(name, notify){ + if (!notified.get(name)){ notify("fakedAudioReadout"); - notified = true; + notified.set(name, true); } } // changed functions and their fakes @@ -99,7 +99,7 @@ object: ["AnalyserNode"], fakeGenerator: function(prefs, notify, window, original){ return function getFloatFrequencyData(array){ - notifyOnce(notify); + notifyOnce("getFloatFrequencyData", notify); var ret = original.apply(this, window.Array.from(arguments)); fakeFloat32Array(array, window, prefs); return ret; @@ -110,7 +110,7 @@ object: ["AnalyserNode"], fakeGenerator: function(prefs, notify, window, original){ return function getByteFrequencyData(array){ - notifyOnce(notify); + notifyOnce("getByteFrequencyData", notify); var ret = original.apply(this, window.Array.from(arguments)); fakeUint8Array(array, window, prefs); return ret; @@ -118,12 +118,10 @@ } }, getFloatTimeDomainData: { - type: "readout", - getStatus: getStatus, object: ["AnalyserNode"], fakeGenerator: function(prefs, notify, window, original){ return function getFloatTimeDomainData(array){ - notifyOnce(notify); + notifyOnce("getFloatTimeDomainData", notify); var ret = original.apply(this, window.Array.from(arguments)); fakeFloat32Array(array, window, prefs); return ret; @@ -134,7 +132,7 @@ object: ["AnalyserNode"], fakeGenerator: function(prefs, notify, window, original){ return function getByteTimeDomainData(array){ - notifyOnce(notify); + notifyOnce("getByteTimeDomainData", notify); var ret = original.apply(this, window.Array.from(arguments)); fakeUint8Array(array, window, prefs); return ret; @@ -145,7 +143,7 @@ object: ["AudioBuffer"], fakeGenerator: function(prefs, notify, window, original){ return function getChannelData(channel){ - notifyOnce(notify); + notifyOnce("getChannelData", notify); var ret = original.apply(this, window.Array.from(arguments)); fakeFloat32Array(ret, window, prefs); return ret; @@ -156,7 +154,7 @@ object: ["AudioBuffer"], fakeGenerator: function(prefs, notify, window, original){ return function copyFromChannel(destination, channelNumber, startInChannel){ - notifyOnce(notify); + notifyOnce("copyFromChannel", notify); var ret = original.apply(this, window.Array.from(arguments)); fakeFloat32Array(destination, window, prefs); return ret; @@ -167,7 +165,7 @@ object: ["BiquadFilterNode", "IIRFilterNode"], fakeGenerator: function(prefs, notify, window, original){ return function getFrequencyResponse(frequencyArray, magResponseOutput, phaseResponseOutput){ - notifyOnce(notify); + notifyOnce("getFrequencyResponse", notify); var ret = original.apply(this, window.Array.from(arguments)); fakeFloat32Array(magResponseOutput, window, prefs); fakeFloat32Array(phaseResponseOutput, window, prefs);