Loading files
54d761463This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/stack-chan-374381865.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
type AudioInputReader = {
read(byteLength?: number): ArrayBuffer | undefined
}
const MAX_READ_BYTES = 2 * 1024
export function readAudioInputChunk(input: AudioInputReader, availableBytes: number): Uint8Array | undefined {
const byteLength = Math.min(Math.max(0, Math.trunc(availableBytes)), MAX_READ_BYTES) & ~1
if (byteLength === 0) return
let buffer: ArrayBuffer | undefined
let requestedByteLength = byteLength
try {
buffer = input.read(byteLength)
} catch (initialError) {
let recovered = false
while (requestedByteLength >= 2) {
requestedByteLength = Math.max(2, (requestedByteLength >> 1) & ~1)
try {
buffer = input.read(requestedByteLength)
recovered = true
break
} catch {
if (requestedByteLength === 2) break
}
}
if (!recovered) throw initialError
}
if (!buffer) return
const boundedByteLength = Math.min(buffer.byteLength, requestedByteLength) & ~1
return boundedByteLength > 0 ? new Uint8Array(buffer, 0, boundedByteLength) : undefined
}
54d761463This file is pinned to the selected release. Download the original to open it in your design tool.