1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Added cache for getChannelData

Fixes #310
This commit is contained in:
kkapsner 2019-02-07 20:12:12 +01:00
parent 53cdf8347e
commit e47f726abb
4 changed files with 17 additions and 13 deletions

View file

@ -154,6 +154,7 @@
return status;
}
const getChannelDataAlreadyFakedArrays = new WeakMap();
// changed functions and their fakes
scope.changedFunctions = {
getFloatFrequencyData: {
@ -218,9 +219,12 @@
return function getChannelData(channel){
return checkerWrapper(checker, this, arguments, function(args, check){
var {prefs, notify, window, original} = check;
notify("fakedAudioReadout");
var ret = original.apply(this, window.Array.from(args));
fakeFloat32Array(ret, window, prefs);
if (!getChannelDataAlreadyFakedArrays.get(ret)){
notify("fakedAudioReadout");
fakeFloat32Array(ret, window, prefs);
getChannelDataAlreadyFakedArrays.set(ret, true);
}
return ret;
});
};