Use WritableStream for StreamTarget & integrate backpressure concepts

This commit is contained in:
Vanilagy
2024-11-28 22:06:49 +01:00
parent 527108f44e
commit 266fcd473e
19 changed files with 1078 additions and 741 deletions
+19 -1
View File
@@ -79,4 +79,22 @@ export const colorSpaceIsComplete = (colorSpace: VideoColorSpaceInit | undefined
export const isAllowSharedBufferSource = (x: unknown) => {
// Quite a mouthful:
return x instanceof ArrayBuffer || (typeof SharedArrayBuffer !== 'undefined' && x instanceof SharedArrayBuffer) || (ArrayBuffer.isView(x) && !(x instanceof DataView));
};
};
export class AsyncMutex {
currentPromise = Promise.resolve();
async acquire() {
let resolver: () => void;
let nextPromise = new Promise<void>(resolve => {
resolver = resolve;
});
let currentPromiseAlias = this.currentPromise;
this.currentPromise = nextPromise;
await currentPromiseAlias;
return resolver!;
}
}