Import log instead of using it off of window
This commit is contained in:
parent
8eb0dd3116
commit
65ddf0a9e8
155 changed files with 3654 additions and 3433 deletions
|
@ -6,6 +6,7 @@ import PQueue from 'p-queue';
|
|||
import LRU from 'lru-cache';
|
||||
|
||||
import { WaveformCache } from '../types/Audio';
|
||||
import * as log from '../logging/log';
|
||||
|
||||
const MAX_WAVEFORM_COUNT = 1000;
|
||||
const MAX_PARALLEL_COMPUTE = 8;
|
||||
|
@ -84,11 +85,11 @@ async function doComputePeaks(
|
|||
): Promise<ComputePeaksResult> {
|
||||
const existing = waveformCache.get(url);
|
||||
if (existing) {
|
||||
window.log.info('GlobalAudioContext: waveform cache hit', url);
|
||||
log.info('GlobalAudioContext: waveform cache hit', url);
|
||||
return Promise.resolve(existing);
|
||||
}
|
||||
|
||||
window.log.info('GlobalAudioContext: waveform cache miss', url);
|
||||
log.info('GlobalAudioContext: waveform cache miss', url);
|
||||
|
||||
// Load and decode `url` into a raw PCM
|
||||
const response = await fetch(url);
|
||||
|
@ -98,7 +99,7 @@ async function doComputePeaks(
|
|||
|
||||
const peaks = new Array(barCount).fill(0);
|
||||
if (duration > MAX_AUDIO_DURATION) {
|
||||
window.log.info(
|
||||
log.info(
|
||||
`GlobalAudioContext: audio ${url} duration ${duration}s is too long`
|
||||
);
|
||||
const emptyResult = { peaks, duration };
|
||||
|
@ -151,14 +152,11 @@ export async function computePeaks(
|
|||
|
||||
const pending = inProgressMap.get(computeKey);
|
||||
if (pending) {
|
||||
window.log.info(
|
||||
'GlobalAudioContext: already computing peaks for',
|
||||
computeKey
|
||||
);
|
||||
log.info('GlobalAudioContext: already computing peaks for', computeKey);
|
||||
return pending;
|
||||
}
|
||||
|
||||
window.log.info('GlobalAudioContext: queue computing peaks for', computeKey);
|
||||
log.info('GlobalAudioContext: queue computing peaks for', computeKey);
|
||||
const promise = computeQueue.add(() => doComputePeaks(url, barCount));
|
||||
|
||||
inProgressMap.set(computeKey, promise);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue