(wasm: OpusExports)
| 70 | private closed = false; |
| 71 | |
| 72 | constructor(wasm: OpusExports) { |
| 73 | this.wasm = wasm; |
| 74 | this.memory = new Uint8Array(wasm.memory.buffer); |
| 75 | this.packetPtr = wasm.malloc(MAX_PACKET_SIZE); |
| 76 | this.pcmPtr = wasm.malloc(PCM_BUFFER_SIZE); |
| 77 | this.encoderPtr = wasm.malloc(wasm.opus_encoder_get_size(CHANNELS)); |
| 78 | |
| 79 | ensureOk( |
| 80 | wasm.opus_encoder_init(this.encoderPtr, SAMPLE_RATE, CHANNELS, 2048), |
| 81 | this.memory, |
| 82 | wasm, |
| 83 | ); |
| 84 | |
| 85 | // The 120ms packet duration is determined by the PCM frame size we pass to |
| 86 | // opus_encode(). Avoid low-level CTL tuning here because incorrect request |
| 87 | // codes/enum values in the wasm build surface as "invalid argument" during |
| 88 | // session startup. |
| 89 | } |
| 90 | |
| 91 | private refreshMemory() { |
| 92 | if (this.memory.buffer !== this.wasm.memory.buffer) { |
nothing calls this directly
no test coverage detected