mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Rename files
This commit is contained in:
24
ts/calling/useGetCallingFrameBuffer.std.ts
Normal file
24
ts/calling/useGetCallingFrameBuffer.std.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { useRef, useCallback } from 'react';
|
||||
import { FRAME_BUFFER_SIZE } from './constants.std.js';
|
||||
|
||||
/**
|
||||
* A hook that returns a function. This function returns a "singleton" `ArrayBuffer` to be
|
||||
* used in call video rendering.
|
||||
*
|
||||
* This is most useful for group calls, where we can reuse the same frame buffer instead
|
||||
* of allocating one per participant. Be careful when using this buffer elsewhere, as it
|
||||
* is not cleaned up and may hold stale data.
|
||||
*/
|
||||
export function useGetCallingFrameBuffer(): () => Uint8Array {
|
||||
const ref = useRef<Uint8Array | null>(null);
|
||||
|
||||
return useCallback(() => {
|
||||
if (!ref.current) {
|
||||
ref.current = new Uint8Array(FRAME_BUFFER_SIZE);
|
||||
}
|
||||
return ref.current;
|
||||
}, []);
|
||||
}
|
||||
Reference in New Issue
Block a user