Group calls: Make renderVideoFrame generate less garbage

This commit is contained in:
Jordan Rose 2021-12-10 16:21:28 -08:00 committed by GitHub
parent fed84be0b6
commit 683823a114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 21 deletions

View file

@ -12,12 +12,12 @@ import { FRAME_BUFFER_SIZE } from './constants';
* 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(): () => ArrayBuffer {
const ref = useRef<ArrayBuffer | null>(null);
export function useGetCallingFrameBuffer(): () => Buffer {
const ref = useRef<Buffer | null>(null);
return useCallback(() => {
if (!ref.current) {
ref.current = new ArrayBuffer(FRAME_BUFFER_SIZE);
ref.current = Buffer.alloc(FRAME_BUFFER_SIZE);
}
return ref.current;
}, []);