mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 11:23:45 +02:00
Use WritableStream for StreamTarget & integrate backpressure concepts
This commit is contained in:
+19
-1
@@ -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!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user